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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.HyperStack.ST.Stack | val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_get_bits_l #b_t bLen bBits b l i =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits -! bBits %. l) = v bBits - v bBits % v l);
[@inline_let] let bk = bBits -! bBits %. l in
assert (v bk == v bBits - v bBits % v l);
Math.Lemmas.lemma_mult_le_left (v l) (v i + 1) (v bBits / v l);
assert (v l * (v i + 1) <= v l * (v bBits / v l));
Math.Lemmas.distributivity_add_right (v l) (v i) 1;
assert (v l * v i + v l <= v bk);
assert (v (bk -! l *! i -! l) == v bk - v l * v i - v l);
let k = bk -! l *! i -! l in
assert (v k == v bk - v l * v i - v l);
Math.Lemmas.lemma_div_le (v k) (v bBits - 1) (bits b_t);
assert (v k / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v k) (v l);
BN.bn_get_bits bLen b k l | val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i))
let bn_get_bits_l #b_t bLen bBits b l i = | true | null | false | Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits -! bBits %. l) = v bBits - v bBits % v l);
[@@ inline_let ]let bk = bBits -! bBits %. l in
assert (v bk == v bBits - v bBits % v l);
Math.Lemmas.lemma_mult_le_left (v l) (v i + 1) (v bBits / v l);
assert (v l * (v i + 1) <= v l * (v bBits / v l));
Math.Lemmas.distributivity_add_right (v l) (v i) 1;
assert (v l * v i + v l <= v bk);
assert (v (bk -! l *! i -! l) == v bk - v l * v i - v l);
let k = bk -! l *! i -! l in
assert (v k == v bk - v l * v i - v l);
Math.Lemmas.lemma_div_le (v k) (v bBits - 1) (bits b_t);
assert (v k / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v k) (v l);
BN.bn_get_bits bLen b k l | {
"checked_file": "Hacl.Impl.Exponentiation.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.PrecompTable.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Exponentiation.fst"
} | [] | [
"Hacl.Impl.Exponentiation.Definitions.inttype_a",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_Subtraction",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.bits",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.l_and",
"Hacl.Bignum.bn_get_bits",
"Hacl.Bignum.Definitions.limb",
"Prims.unit",
"Hacl.Spec.Bignum.bn_get_bits_lemma",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims._assert",
"FStar.Math.Lemmas.lemma_div_le",
"Prims.eq2",
"Prims.int",
"FStar.Mul.op_Star",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Subtraction_Bang",
"Lib.IntTypes.op_Star_Bang",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Math.Lemmas.distributivity_add_right",
"FStar.Math.Lemmas.lemma_mult_le_left",
"Prims.op_Modulus",
"Lib.IntTypes.op_Percent_Dot",
"Prims.op_Equality",
"FStar.Math.Lemmas.euclidean_division_definition"
] | [] | module Hacl.Impl.Exponentiation
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module S = Lib.Exponentiation
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module SN = Hacl.Spec.Bignum
module BB = Hacl.Bignum.Base
module PT = Hacl.Impl.PrecompTable
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc =
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a)) in
[@inline_let]
let spec (h:mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\
snd res == k.to.refl (as_seq h a)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then
k.lmul ctx acc a acc; // acc = (acc * a) % n
k.lsqr ctx a a // a = (a * a) % n
)
inline_for_extraction noextract
val cswap2:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> bit:uint_t a_t SEC{v bit <= 1}
-> p1:lbuffer (uint_t a_t SEC) len
-> p2:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h p1 /\ live h p2 /\ disjoint p1 p2 /\
k.to.linv (as_seq h p1) /\ k.to.linv (as_seq h p2))
(ensures fun h0 _ h1 -> modifies (loc p1 |+| loc p2) h0 h1 /\
k.to.linv (as_seq h1 p1) /\ k.to.linv (as_seq h1 p2) /\
(k.to.refl (as_seq h1 p1), k.to.refl (as_seq h1 p2)) ==
S.cswap (v bit) (k.to.refl (as_seq h0 p1)) (k.to.refl (as_seq h0 p2)))
let cswap2 #a_t len ctx_len k bit p1 p2 =
let h0 = ST.get () in
BN.cswap2 len bit p1 p2;
SN.cswap2_lemma bit (as_seq h0 p1) (as_seq h0 p2)
val lemma_bit_xor_is_sum_mod2: #a_t:inttype_a -> a:uint_t a_t SEC -> b:uint_t a_t SEC -> Lemma
(requires v a <= 1 /\ v b <= 1)
(ensures v (a ^. b) == (v a + v b) % 2)
let lemma_bit_xor_is_sum_mod2 #a_t a b =
match a_t with
| U32 ->
logxor_spec a b;
assert_norm (UInt32.logxor 0ul 0ul == 0ul);
assert_norm (UInt32.logxor 0ul 1ul == 1ul);
assert_norm (UInt32.logxor 1ul 0ul == 1ul);
assert_norm (UInt32.logxor 1ul 1ul == 0ul)
| U64 ->
logxor_spec a b;
assert_norm (UInt64.logxor 0uL 0uL == 0uL);
assert_norm (UInt64.logxor 0uL 1uL == 1uL);
assert_norm (UInt64.logxor 1uL 0uL == 1uL);
assert_norm (UInt64.logxor 1uL 1uL == 0uL)
//r0 = acc; r1 = a
let lexp_mont_ladder_swap_consttime #a_t len ctx_len k ctx a bLen bBits b acc =
push_frame ();
let sw = create 1ul (uint #a_t #SEC 0) in
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec & nat) =
(k.to.refl (as_seq h0 acc), k.to.refl (as_seq h0 a), v (LSeq.index (as_seq h0 sw) 0)) in
[@inline_let]
let spec (h:mem) = S.exp_mont_ladder_swap_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc |+| loc sw) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
v (LSeq.index (as_seq h sw) 0) <= 1 /\
(let (acc1, a1, sw1) = Loops.repeati i (spec h0) (refl1 0) in
a1 == k.to.refl (as_seq h a) /\
acc1 == k.to.refl (as_seq h acc) /\
sw1 == v (LSeq.index (as_seq h sw) 0)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
let h2 = ST.get () in
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b (bBits -! i -! 1ul) in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v bBits - v i - 1);
let sw1 = bit ^. sw.(0ul) in
lemma_bit_xor_is_sum_mod2 #a_t bit (LSeq.index (as_seq h2 sw) 0);
cswap2 len ctx_len k sw1 acc a;
k.lmul ctx a acc a; // a = (a * acc) % n
k.lsqr ctx acc acc; // a = (a * a) % n
sw.(0ul) <- bit
);
let sw0 = sw.(0ul) in
cswap2 len ctx_len k sw0 acc a;
pop_frame ()
let lexp_pow2 #a_t len ctx_len k ctx a b res =
copy res a;
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 res) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc res) h0 h /\
k.to.linv (as_seq h res) /\
k.to.refl (as_seq h res) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx res res)
let lexp_pow2_in_place #a_t len ctx_len k ctx acc b =
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc acc) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx acc acc)
//---------------------------------------------------
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i)) | false | false | Hacl.Impl.Exponentiation.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i)) | [] | Hacl.Impl.Exponentiation.bn_get_bits_l | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
bLen: Lib.IntTypes.size_t ->
bBits:
Lib.IntTypes.size_t{(Lib.IntTypes.v bBits - 1) / Lib.IntTypes.bits b_t < Lib.IntTypes.v bLen} ->
b: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t b_t Lib.IntTypes.SEC) bLen ->
l: Lib.IntTypes.size_t{0 < Lib.IntTypes.v l /\ Lib.IntTypes.v l < Lib.IntTypes.bits b_t} ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v bBits / Lib.IntTypes.v l}
-> FStar.HyperStack.ST.Stack (Lib.IntTypes.uint_t b_t Lib.IntTypes.SEC) | {
"end_col": 27,
"end_line": 225,
"start_col": 2,
"start_line": 207
} |
Prims.Tot | val lmul_acc_pow_a_bits_l:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv | [
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
let h0 = ST.get () in
push_frame ();
let bits_l = bn_get_bits_l bLen bBits b l i in
assert (v bits_l < pow2 (v l));
pow_a_to_small_b ctx (as_seq h0 a) table bits_l tmp;
k.lmul ctx acc tmp acc;
pop_frame () | val lmul_acc_pow_a_bits_l:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv
let lmul_acc_pow_a_bits_l
#a_t
len
ctx_len
k
l
table_len
table_inv
pow_a_to_small_b
ctx
a
bLen
bBits
b
table
i
acc
tmp
= | false | null | false | let h0 = ST.get () in
push_frame ();
let bits_l = bn_get_bits_l bLen bBits b l i in
assert (v bits_l < pow2 (v l));
pow_a_to_small_b ctx (as_seq h0 a) table bits_l tmp;
k.lmul ctx acc tmp acc;
pop_frame () | {
"checked_file": "Hacl.Impl.Exponentiation.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.PrecompTable.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Exponentiation.fst"
} | [
"total"
] | [
"Hacl.Impl.Exponentiation.Definitions.inttype_a",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Exponentiation.Definitions.concrete_ops",
"Hacl.Impl.Exponentiation.size_window_t",
"Hacl.Impl.Exponentiation.table_len_t",
"Hacl.Impl.Exponentiation.table_inv_t",
"Hacl.Impl.Exponentiation.pow_a_to_small_b_st",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"Lib.Buffer.clbuffer",
"Lib.IntTypes.op_Star_Bang",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__lmul",
"FStar.Ghost.hide",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims._assert",
"Prims.pow2",
"Lib.IntTypes.int_t",
"Hacl.Impl.Exponentiation.bn_get_bits_l",
"FStar.HyperStack.ST.push_frame",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Impl.Exponentiation
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module S = Lib.Exponentiation
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module SN = Hacl.Spec.Bignum
module BB = Hacl.Bignum.Base
module PT = Hacl.Impl.PrecompTable
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc =
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a)) in
[@inline_let]
let spec (h:mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\
snd res == k.to.refl (as_seq h a)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then
k.lmul ctx acc a acc; // acc = (acc * a) % n
k.lsqr ctx a a // a = (a * a) % n
)
inline_for_extraction noextract
val cswap2:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> bit:uint_t a_t SEC{v bit <= 1}
-> p1:lbuffer (uint_t a_t SEC) len
-> p2:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h p1 /\ live h p2 /\ disjoint p1 p2 /\
k.to.linv (as_seq h p1) /\ k.to.linv (as_seq h p2))
(ensures fun h0 _ h1 -> modifies (loc p1 |+| loc p2) h0 h1 /\
k.to.linv (as_seq h1 p1) /\ k.to.linv (as_seq h1 p2) /\
(k.to.refl (as_seq h1 p1), k.to.refl (as_seq h1 p2)) ==
S.cswap (v bit) (k.to.refl (as_seq h0 p1)) (k.to.refl (as_seq h0 p2)))
let cswap2 #a_t len ctx_len k bit p1 p2 =
let h0 = ST.get () in
BN.cswap2 len bit p1 p2;
SN.cswap2_lemma bit (as_seq h0 p1) (as_seq h0 p2)
val lemma_bit_xor_is_sum_mod2: #a_t:inttype_a -> a:uint_t a_t SEC -> b:uint_t a_t SEC -> Lemma
(requires v a <= 1 /\ v b <= 1)
(ensures v (a ^. b) == (v a + v b) % 2)
let lemma_bit_xor_is_sum_mod2 #a_t a b =
match a_t with
| U32 ->
logxor_spec a b;
assert_norm (UInt32.logxor 0ul 0ul == 0ul);
assert_norm (UInt32.logxor 0ul 1ul == 1ul);
assert_norm (UInt32.logxor 1ul 0ul == 1ul);
assert_norm (UInt32.logxor 1ul 1ul == 0ul)
| U64 ->
logxor_spec a b;
assert_norm (UInt64.logxor 0uL 0uL == 0uL);
assert_norm (UInt64.logxor 0uL 1uL == 1uL);
assert_norm (UInt64.logxor 1uL 0uL == 1uL);
assert_norm (UInt64.logxor 1uL 1uL == 0uL)
//r0 = acc; r1 = a
let lexp_mont_ladder_swap_consttime #a_t len ctx_len k ctx a bLen bBits b acc =
push_frame ();
let sw = create 1ul (uint #a_t #SEC 0) in
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec & nat) =
(k.to.refl (as_seq h0 acc), k.to.refl (as_seq h0 a), v (LSeq.index (as_seq h0 sw) 0)) in
[@inline_let]
let spec (h:mem) = S.exp_mont_ladder_swap_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc |+| loc sw) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
v (LSeq.index (as_seq h sw) 0) <= 1 /\
(let (acc1, a1, sw1) = Loops.repeati i (spec h0) (refl1 0) in
a1 == k.to.refl (as_seq h a) /\
acc1 == k.to.refl (as_seq h acc) /\
sw1 == v (LSeq.index (as_seq h sw) 0)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
let h2 = ST.get () in
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b (bBits -! i -! 1ul) in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v bBits - v i - 1);
let sw1 = bit ^. sw.(0ul) in
lemma_bit_xor_is_sum_mod2 #a_t bit (LSeq.index (as_seq h2 sw) 0);
cswap2 len ctx_len k sw1 acc a;
k.lmul ctx a acc a; // a = (a * acc) % n
k.lsqr ctx acc acc; // a = (a * a) % n
sw.(0ul) <- bit
);
let sw0 = sw.(0ul) in
cswap2 len ctx_len k sw0 acc a;
pop_frame ()
let lexp_pow2 #a_t len ctx_len k ctx a b res =
copy res a;
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 res) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc res) h0 h /\
k.to.linv (as_seq h res) /\
k.to.refl (as_seq h res) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx res res)
let lexp_pow2_in_place #a_t len ctx_len k ctx acc b =
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc acc) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx acc acc)
//---------------------------------------------------
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i))
let bn_get_bits_l #b_t bLen bBits b l i =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits -! bBits %. l) = v bBits - v bBits % v l);
[@inline_let] let bk = bBits -! bBits %. l in
assert (v bk == v bBits - v bBits % v l);
Math.Lemmas.lemma_mult_le_left (v l) (v i + 1) (v bBits / v l);
assert (v l * (v i + 1) <= v l * (v bBits / v l));
Math.Lemmas.distributivity_add_right (v l) (v i) 1;
assert (v l * v i + v l <= v bk);
assert (v (bk -! l *! i -! l) == v bk - v l * v i - v l);
let k = bk -! l *! i -! l in
assert (v k == v bk - v l * v i - v l);
Math.Lemmas.lemma_div_le (v k) (v bBits - 1) (bits b_t);
assert (v k / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v k) (v l);
BN.bn_get_bits bLen b k l
inline_for_extraction noextract
val bn_get_bits_c:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t /\ 0 < v bBits % v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == (BD.bn_v h0 b / pow2 (v bBits / v l * v l)) % pow2 (v l))
let bn_get_bits_c #b_t bLen bBits b l =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits /. l *! l) == v bBits / v l * v l);
let i = bBits /. l *! l in
assert (v i == v bBits / v l * v l);
assert (v i <= v bBits - 1);
Math.Lemmas.lemma_div_le (v i) (v bBits - 1) (bits b_t);
assert (v i / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v i) (v l);
BN.bn_get_bits bLen b i l
//---------------------------------------------------
inline_for_extraction noextract
let lmul_acc_pow_a_bits_l_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.mul_acc_pow_a_bits_l #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc * a^b_i
inline_for_extraction noextract
val lmul_acc_pow_a_bits_l:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv | false | false | Hacl.Impl.Exponentiation.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lmul_acc_pow_a_bits_l:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv | [] | Hacl.Impl.Exponentiation.lmul_acc_pow_a_bits_l | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} ->
ctx_len: Lib.IntTypes.size_t ->
k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len ->
l: Hacl.Impl.Exponentiation.size_window_t a_t len ->
table_len: Hacl.Impl.Exponentiation.table_len_t len ->
table_inv: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len ->
pow_a_to_small_b:
Hacl.Impl.Exponentiation.pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv
-> Hacl.Impl.Exponentiation.lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv | {
"end_col": 14,
"end_line": 314,
"start_col": 120,
"start_line": 306
} |
Prims.Tot | val mk_lexp_fw_table:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_table_st a_t len ctx_len k l table_len table_inv | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_lexp_fw_table #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table res =
assert (v (bBits %. l) = v bBits % v l);
if bBits %. l <> 0ul then
lexp_fw_acc0 len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table res
else k.lone ctx res;
lexp_fw_loop len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table res | val mk_lexp_fw_table:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_table_st a_t len ctx_len k l table_len table_inv
let mk_lexp_fw_table
#a_t
len
ctx_len
k
l
table_len
table_inv
pow_a_to_small_b
ctx
a
bLen
bBits
b
table
res
= | false | null | false | assert (v (bBits %. l) = v bBits % v l);
if bBits %. l <> 0ul
then lexp_fw_acc0 len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table res
else k.lone ctx res;
lexp_fw_loop len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table res | {
"checked_file": "Hacl.Impl.Exponentiation.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.PrecompTable.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Exponentiation.fst"
} | [
"total"
] | [
"Hacl.Impl.Exponentiation.Definitions.inttype_a",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Exponentiation.Definitions.concrete_ops",
"Hacl.Impl.Exponentiation.size_window_t",
"Hacl.Impl.Exponentiation.table_len_t",
"Hacl.Impl.Exponentiation.table_inv_t",
"Hacl.Impl.Exponentiation.pow_a_to_small_b_st",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"Lib.Buffer.clbuffer",
"Lib.IntTypes.op_Star_Bang",
"Hacl.Impl.Exponentiation.lexp_fw_loop",
"Prims.unit",
"Prims.op_disEquality",
"FStar.UInt32.t",
"Lib.IntTypes.op_Percent_Dot",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Exponentiation.lexp_fw_acc0",
"Prims.bool",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__lone",
"Prims._assert",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus"
] | [] | module Hacl.Impl.Exponentiation
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module S = Lib.Exponentiation
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module SN = Hacl.Spec.Bignum
module BB = Hacl.Bignum.Base
module PT = Hacl.Impl.PrecompTable
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc =
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a)) in
[@inline_let]
let spec (h:mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\
snd res == k.to.refl (as_seq h a)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then
k.lmul ctx acc a acc; // acc = (acc * a) % n
k.lsqr ctx a a // a = (a * a) % n
)
inline_for_extraction noextract
val cswap2:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> bit:uint_t a_t SEC{v bit <= 1}
-> p1:lbuffer (uint_t a_t SEC) len
-> p2:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h p1 /\ live h p2 /\ disjoint p1 p2 /\
k.to.linv (as_seq h p1) /\ k.to.linv (as_seq h p2))
(ensures fun h0 _ h1 -> modifies (loc p1 |+| loc p2) h0 h1 /\
k.to.linv (as_seq h1 p1) /\ k.to.linv (as_seq h1 p2) /\
(k.to.refl (as_seq h1 p1), k.to.refl (as_seq h1 p2)) ==
S.cswap (v bit) (k.to.refl (as_seq h0 p1)) (k.to.refl (as_seq h0 p2)))
let cswap2 #a_t len ctx_len k bit p1 p2 =
let h0 = ST.get () in
BN.cswap2 len bit p1 p2;
SN.cswap2_lemma bit (as_seq h0 p1) (as_seq h0 p2)
val lemma_bit_xor_is_sum_mod2: #a_t:inttype_a -> a:uint_t a_t SEC -> b:uint_t a_t SEC -> Lemma
(requires v a <= 1 /\ v b <= 1)
(ensures v (a ^. b) == (v a + v b) % 2)
let lemma_bit_xor_is_sum_mod2 #a_t a b =
match a_t with
| U32 ->
logxor_spec a b;
assert_norm (UInt32.logxor 0ul 0ul == 0ul);
assert_norm (UInt32.logxor 0ul 1ul == 1ul);
assert_norm (UInt32.logxor 1ul 0ul == 1ul);
assert_norm (UInt32.logxor 1ul 1ul == 0ul)
| U64 ->
logxor_spec a b;
assert_norm (UInt64.logxor 0uL 0uL == 0uL);
assert_norm (UInt64.logxor 0uL 1uL == 1uL);
assert_norm (UInt64.logxor 1uL 0uL == 1uL);
assert_norm (UInt64.logxor 1uL 1uL == 0uL)
//r0 = acc; r1 = a
let lexp_mont_ladder_swap_consttime #a_t len ctx_len k ctx a bLen bBits b acc =
push_frame ();
let sw = create 1ul (uint #a_t #SEC 0) in
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec & nat) =
(k.to.refl (as_seq h0 acc), k.to.refl (as_seq h0 a), v (LSeq.index (as_seq h0 sw) 0)) in
[@inline_let]
let spec (h:mem) = S.exp_mont_ladder_swap_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc |+| loc sw) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
v (LSeq.index (as_seq h sw) 0) <= 1 /\
(let (acc1, a1, sw1) = Loops.repeati i (spec h0) (refl1 0) in
a1 == k.to.refl (as_seq h a) /\
acc1 == k.to.refl (as_seq h acc) /\
sw1 == v (LSeq.index (as_seq h sw) 0)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
let h2 = ST.get () in
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b (bBits -! i -! 1ul) in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v bBits - v i - 1);
let sw1 = bit ^. sw.(0ul) in
lemma_bit_xor_is_sum_mod2 #a_t bit (LSeq.index (as_seq h2 sw) 0);
cswap2 len ctx_len k sw1 acc a;
k.lmul ctx a acc a; // a = (a * acc) % n
k.lsqr ctx acc acc; // a = (a * a) % n
sw.(0ul) <- bit
);
let sw0 = sw.(0ul) in
cswap2 len ctx_len k sw0 acc a;
pop_frame ()
let lexp_pow2 #a_t len ctx_len k ctx a b res =
copy res a;
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 res) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc res) h0 h /\
k.to.linv (as_seq h res) /\
k.to.refl (as_seq h res) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx res res)
let lexp_pow2_in_place #a_t len ctx_len k ctx acc b =
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc acc) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx acc acc)
//---------------------------------------------------
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i))
let bn_get_bits_l #b_t bLen bBits b l i =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits -! bBits %. l) = v bBits - v bBits % v l);
[@inline_let] let bk = bBits -! bBits %. l in
assert (v bk == v bBits - v bBits % v l);
Math.Lemmas.lemma_mult_le_left (v l) (v i + 1) (v bBits / v l);
assert (v l * (v i + 1) <= v l * (v bBits / v l));
Math.Lemmas.distributivity_add_right (v l) (v i) 1;
assert (v l * v i + v l <= v bk);
assert (v (bk -! l *! i -! l) == v bk - v l * v i - v l);
let k = bk -! l *! i -! l in
assert (v k == v bk - v l * v i - v l);
Math.Lemmas.lemma_div_le (v k) (v bBits - 1) (bits b_t);
assert (v k / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v k) (v l);
BN.bn_get_bits bLen b k l
inline_for_extraction noextract
val bn_get_bits_c:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t /\ 0 < v bBits % v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == (BD.bn_v h0 b / pow2 (v bBits / v l * v l)) % pow2 (v l))
let bn_get_bits_c #b_t bLen bBits b l =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits /. l *! l) == v bBits / v l * v l);
let i = bBits /. l *! l in
assert (v i == v bBits / v l * v l);
assert (v i <= v bBits - 1);
Math.Lemmas.lemma_div_le (v i) (v bBits - 1) (bits b_t);
assert (v i / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v i) (v l);
BN.bn_get_bits bLen b i l
//---------------------------------------------------
inline_for_extraction noextract
let lmul_acc_pow_a_bits_l_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.mul_acc_pow_a_bits_l #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc * a^b_i
inline_for_extraction noextract
val lmul_acc_pow_a_bits_l:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv
let lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
let h0 = ST.get () in
push_frame ();
let bits_l = bn_get_bits_l bLen bBits b l i in
assert (v bits_l < pow2 (v l));
pow_a_to_small_b ctx (as_seq h0 a) table bits_l tmp;
k.lmul ctx acc tmp acc;
pop_frame ()
inline_for_extraction noextract
let lexp_fw_f_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.exp_fw_f #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc^(2^l) * a^b_i
inline_for_extraction noextract
val lexp_fw_f:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_f_st a_t len ctx_len k l table_len table_inv
let lexp_fw_f #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
lexp_pow2_in_place len ctx_len k ctx acc l;
lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp
inline_for_extraction noextract
let lexp_fw_loop_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> acc:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
Loops.repeati (v bBits / v l) (S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l)) (k.to.refl (as_seq h0 acc)))
inline_for_extraction noextract
val lexp_fw_loop:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_loop_st a_t len ctx_len k l table_len table_inv
let lexp_fw_loop #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table acc =
push_frame ();
let tmp = create len (uint #a_t #SEC 0) in
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@inline_let]
let spec (h:mem) = S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) in
[@inline_let]
let inv h (i:nat{i <= v bBits / v l}) =
modifies (loc acc |+| loc tmp) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeati i (spec h0) (refl1 0) /\
table_inv (as_seq h a) (as_seq h table) in
Loops.eq_repeati0 (v bBits / v l) (spec h0) (refl1 0);
Lib.Loops.for 0ul (bBits /. l) inv
(fun i ->
Loops.unfold_repeati (v bBits / v l) (spec h0) (refl1 0) (v i);
lexp_fw_f len ctx_len k l table_len table_inv pow_a_to_small_b
ctx a bLen bBits b table i acc tmp
);
pop_frame ()
inline_for_extraction noextract
let lexp_fw_acc0_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> acc:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h -> v bBits % v l <> 0 /\
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.exp_fw_acc0 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l))
inline_for_extraction noextract
val lexp_fw_acc0:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_acc0_st a_t len ctx_len k l table_len table_inv
let lexp_fw_acc0 #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table acc =
let h0 = ST.get () in
assert (v (bBits %. l) == v bBits % v l);
let bits_c = bn_get_bits_c bLen bBits b l in
pow_a_to_small_b ctx (as_seq h0 a) table bits_c acc | false | false | Hacl.Impl.Exponentiation.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_lexp_fw_table:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_table_st a_t len ctx_len k l table_len table_inv | [] | Hacl.Impl.Exponentiation.mk_lexp_fw_table | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} ->
ctx_len: Lib.IntTypes.size_t ->
k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len ->
l: Hacl.Impl.Exponentiation.size_window_t a_t len ->
table_len: Hacl.Impl.Exponentiation.table_len_t len ->
table_inv: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len ->
pow_a_to_small_b:
Hacl.Impl.Exponentiation.pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv
-> Hacl.Impl.Exponentiation.lexp_fw_table_st a_t len ctx_len k l table_len table_inv | {
"end_col": 96,
"end_line": 496,
"start_col": 2,
"start_line": 492
} |
FStar.HyperStack.ST.Stack | val lexp_rl_vartime:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> res:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h ctx /\
disjoint a res /\ disjoint b res /\ disjoint a b /\
disjoint ctx a /\ disjoint ctx res /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a))
(ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\
k.to.linv (as_seq h1 res) /\
k.to.refl (as_seq h1 res) ==
S.exp_rl #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc =
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a)) in
[@inline_let]
let spec (h:mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\
snd res == k.to.refl (as_seq h a)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then
k.lmul ctx acc a acc; // acc = (acc * a) % n
k.lsqr ctx a a // a = (a * a) % n
) | val lexp_rl_vartime:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> res:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h ctx /\
disjoint a res /\ disjoint b res /\ disjoint a b /\
disjoint ctx a /\ disjoint ctx res /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a))
(ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\
k.to.linv (as_seq h1 res) /\
k.to.refl (as_seq h1 res) ==
S.exp_rl #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b))
let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc = | true | null | false | k.lone ctx acc;
let h0 = ST.get () in
[@@ inline_let ]let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a))
in
[@@ inline_let ]let spec (h: mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@@ inline_let ]let inv h (i: nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\ k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\ snd res == k.to.refl (as_seq h a))
in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul
bBits
inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then k.lmul ctx acc a acc;
k.lsqr ctx a a) | {
"checked_file": "Hacl.Impl.Exponentiation.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.PrecompTable.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Exponentiation.fst"
} | [] | [
"Hacl.Impl.Exponentiation.Definitions.inttype_a",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Exponentiation.Definitions.concrete_ops",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"Lib.Loops.for",
"FStar.UInt32.__uint_to_t",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__lsqr",
"Prims.unit",
"Prims.op_Negation",
"Hacl.Spec.Bignum.Base.unsafe_bool_of_limb0",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__lmul",
"Prims.bool",
"Hacl.Spec.Bignum.bn_get_ith_bit_lemma",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.bn_get_ith_bit",
"Lib.LoopCombinators.unfold_repeati",
"FStar.Pervasives.Native.tuple2",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec",
"FStar.Ghost.reveal",
"Hacl.Impl.Exponentiation.Definitions.to_comm_monoid",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__to",
"Lib.LoopCombinators.eq_repeati0",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.logical",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv",
"Prims.eq2",
"FStar.Pervasives.Native.fst",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl",
"FStar.Pervasives.Native.snd",
"Lib.LoopCombinators.repeati",
"Lib.Exponentiation.exp_rl_f",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid",
"Hacl.Bignum.Definitions.bn_v",
"Prims.int",
"FStar.Pervasives.Native.Mktuple2",
"Hacl.Impl.Exponentiation.Definitions.refl",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__lone"
] | [] | module Hacl.Impl.Exponentiation
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module S = Lib.Exponentiation
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module SN = Hacl.Spec.Bignum
module BB = Hacl.Bignum.Base
module PT = Hacl.Impl.PrecompTable
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | false | Hacl.Impl.Exponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lexp_rl_vartime:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> res:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h ctx /\
disjoint a res /\ disjoint b res /\ disjoint a b /\
disjoint ctx a /\ disjoint ctx res /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a))
(ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\
k.to.linv (as_seq h1 res) /\
k.to.refl (as_seq h1 res) ==
S.exp_rl #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) | [] | Hacl.Impl.Exponentiation.lexp_rl_vartime | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} ->
ctx_len: Lib.IntTypes.size_t ->
k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len ->
ctx: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) ctx_len ->
a: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) len ->
bLen: Lib.IntTypes.size_t ->
bBits:
Lib.IntTypes.size_t{(Lib.IntTypes.v bBits - 1) / Lib.IntTypes.bits a_t < Lib.IntTypes.v bLen} ->
b: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) bLen ->
res: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) len
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 3,
"end_line": 54,
"start_col": 2,
"start_line": 25
} |
Prims.Tot | val lexp_fw_gen:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len{1 < v table_len /\ v table_len == pow2 (v l)}
-> lprecomp_get:pow_a_to_small_b_st a_t len ctx_len k l table_len
(table_inv_precomp len ctx_len k l table_len) ->
lexp_fw_st a_t len ctx_len k l | [
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lexp_fw_gen #a_t len ctx_len k l table_len lprecomp_get ctx a bLen bBits b res =
push_frame ();
Math.Lemmas.pow2_lt_compat 32 (v l);
lemma_pow2_is_divisible_by_2 (v l);
let table = create (table_len *! len) (uint #a_t #SEC 0) in
PT.lprecomp_table #a_t len ctx_len k ctx a table_len table;
[@inline_let]
let table_inv : table_inv_t a_t len table_len =
table_inv_precomp len ctx_len k l table_len in
let h1 = ST.get () in
assert (table_inv (as_seq h1 a) (as_seq h1 table));
mk_lexp_fw_table len ctx_len k l table_len
table_inv lprecomp_get
ctx a bLen bBits b (to_const table) res;
pop_frame () | val lexp_fw_gen:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len{1 < v table_len /\ v table_len == pow2 (v l)}
-> lprecomp_get:pow_a_to_small_b_st a_t len ctx_len k l table_len
(table_inv_precomp len ctx_len k l table_len) ->
lexp_fw_st a_t len ctx_len k l
let lexp_fw_gen #a_t len ctx_len k l table_len lprecomp_get ctx a bLen bBits b res = | false | null | false | push_frame ();
Math.Lemmas.pow2_lt_compat 32 (v l);
lemma_pow2_is_divisible_by_2 (v l);
let table = create (table_len *! len) (uint #a_t #SEC 0) in
PT.lprecomp_table #a_t len ctx_len k ctx a table_len table;
[@@ inline_let ]let table_inv:table_inv_t a_t len table_len =
table_inv_precomp len ctx_len k l table_len
in
let h1 = ST.get () in
assert (table_inv (as_seq h1 a) (as_seq h1 table));
mk_lexp_fw_table len ctx_len k l table_len table_inv lprecomp_get ctx a bLen bBits b
(to_const table) res;
pop_frame () | {
"checked_file": "Hacl.Impl.Exponentiation.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.PrecompTable.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Exponentiation.fst"
} | [
"total"
] | [
"Hacl.Impl.Exponentiation.Definitions.inttype_a",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Exponentiation.Definitions.concrete_ops",
"Hacl.Impl.Exponentiation.size_window_t",
"Hacl.Impl.Exponentiation.table_len_t",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.pow2",
"Hacl.Impl.Exponentiation.pow_a_to_small_b_st",
"Hacl.Impl.Exponentiation.table_inv_precomp",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.op_Division",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Exponentiation.mk_lexp_fw_table",
"Lib.Buffer.to_const",
"Lib.Buffer.MUT",
"Prims._assert",
"Lib.Buffer.as_seq",
"Lib.IntTypes.op_Star_Bang",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Exponentiation.table_inv_t",
"Hacl.Impl.PrecompTable.lprecomp_table",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.mul",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Hacl.Impl.Exponentiation.lemma_pow2_is_divisible_by_2",
"FStar.Math.Lemmas.pow2_lt_compat",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Exponentiation
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module S = Lib.Exponentiation
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module SN = Hacl.Spec.Bignum
module BB = Hacl.Bignum.Base
module PT = Hacl.Impl.PrecompTable
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc =
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a)) in
[@inline_let]
let spec (h:mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\
snd res == k.to.refl (as_seq h a)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then
k.lmul ctx acc a acc; // acc = (acc * a) % n
k.lsqr ctx a a // a = (a * a) % n
)
inline_for_extraction noextract
val cswap2:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> bit:uint_t a_t SEC{v bit <= 1}
-> p1:lbuffer (uint_t a_t SEC) len
-> p2:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h p1 /\ live h p2 /\ disjoint p1 p2 /\
k.to.linv (as_seq h p1) /\ k.to.linv (as_seq h p2))
(ensures fun h0 _ h1 -> modifies (loc p1 |+| loc p2) h0 h1 /\
k.to.linv (as_seq h1 p1) /\ k.to.linv (as_seq h1 p2) /\
(k.to.refl (as_seq h1 p1), k.to.refl (as_seq h1 p2)) ==
S.cswap (v bit) (k.to.refl (as_seq h0 p1)) (k.to.refl (as_seq h0 p2)))
let cswap2 #a_t len ctx_len k bit p1 p2 =
let h0 = ST.get () in
BN.cswap2 len bit p1 p2;
SN.cswap2_lemma bit (as_seq h0 p1) (as_seq h0 p2)
val lemma_bit_xor_is_sum_mod2: #a_t:inttype_a -> a:uint_t a_t SEC -> b:uint_t a_t SEC -> Lemma
(requires v a <= 1 /\ v b <= 1)
(ensures v (a ^. b) == (v a + v b) % 2)
let lemma_bit_xor_is_sum_mod2 #a_t a b =
match a_t with
| U32 ->
logxor_spec a b;
assert_norm (UInt32.logxor 0ul 0ul == 0ul);
assert_norm (UInt32.logxor 0ul 1ul == 1ul);
assert_norm (UInt32.logxor 1ul 0ul == 1ul);
assert_norm (UInt32.logxor 1ul 1ul == 0ul)
| U64 ->
logxor_spec a b;
assert_norm (UInt64.logxor 0uL 0uL == 0uL);
assert_norm (UInt64.logxor 0uL 1uL == 1uL);
assert_norm (UInt64.logxor 1uL 0uL == 1uL);
assert_norm (UInt64.logxor 1uL 1uL == 0uL)
//r0 = acc; r1 = a
let lexp_mont_ladder_swap_consttime #a_t len ctx_len k ctx a bLen bBits b acc =
push_frame ();
let sw = create 1ul (uint #a_t #SEC 0) in
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec & nat) =
(k.to.refl (as_seq h0 acc), k.to.refl (as_seq h0 a), v (LSeq.index (as_seq h0 sw) 0)) in
[@inline_let]
let spec (h:mem) = S.exp_mont_ladder_swap_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc |+| loc sw) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
v (LSeq.index (as_seq h sw) 0) <= 1 /\
(let (acc1, a1, sw1) = Loops.repeati i (spec h0) (refl1 0) in
a1 == k.to.refl (as_seq h a) /\
acc1 == k.to.refl (as_seq h acc) /\
sw1 == v (LSeq.index (as_seq h sw) 0)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
let h2 = ST.get () in
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b (bBits -! i -! 1ul) in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v bBits - v i - 1);
let sw1 = bit ^. sw.(0ul) in
lemma_bit_xor_is_sum_mod2 #a_t bit (LSeq.index (as_seq h2 sw) 0);
cswap2 len ctx_len k sw1 acc a;
k.lmul ctx a acc a; // a = (a * acc) % n
k.lsqr ctx acc acc; // a = (a * a) % n
sw.(0ul) <- bit
);
let sw0 = sw.(0ul) in
cswap2 len ctx_len k sw0 acc a;
pop_frame ()
let lexp_pow2 #a_t len ctx_len k ctx a b res =
copy res a;
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 res) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc res) h0 h /\
k.to.linv (as_seq h res) /\
k.to.refl (as_seq h res) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx res res)
let lexp_pow2_in_place #a_t len ctx_len k ctx acc b =
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc acc) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx acc acc)
//---------------------------------------------------
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i))
let bn_get_bits_l #b_t bLen bBits b l i =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits -! bBits %. l) = v bBits - v bBits % v l);
[@inline_let] let bk = bBits -! bBits %. l in
assert (v bk == v bBits - v bBits % v l);
Math.Lemmas.lemma_mult_le_left (v l) (v i + 1) (v bBits / v l);
assert (v l * (v i + 1) <= v l * (v bBits / v l));
Math.Lemmas.distributivity_add_right (v l) (v i) 1;
assert (v l * v i + v l <= v bk);
assert (v (bk -! l *! i -! l) == v bk - v l * v i - v l);
let k = bk -! l *! i -! l in
assert (v k == v bk - v l * v i - v l);
Math.Lemmas.lemma_div_le (v k) (v bBits - 1) (bits b_t);
assert (v k / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v k) (v l);
BN.bn_get_bits bLen b k l
inline_for_extraction noextract
val bn_get_bits_c:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t /\ 0 < v bBits % v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == (BD.bn_v h0 b / pow2 (v bBits / v l * v l)) % pow2 (v l))
let bn_get_bits_c #b_t bLen bBits b l =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits /. l *! l) == v bBits / v l * v l);
let i = bBits /. l *! l in
assert (v i == v bBits / v l * v l);
assert (v i <= v bBits - 1);
Math.Lemmas.lemma_div_le (v i) (v bBits - 1) (bits b_t);
assert (v i / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v i) (v l);
BN.bn_get_bits bLen b i l
//---------------------------------------------------
inline_for_extraction noextract
let lmul_acc_pow_a_bits_l_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.mul_acc_pow_a_bits_l #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc * a^b_i
inline_for_extraction noextract
val lmul_acc_pow_a_bits_l:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv
let lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
let h0 = ST.get () in
push_frame ();
let bits_l = bn_get_bits_l bLen bBits b l i in
assert (v bits_l < pow2 (v l));
pow_a_to_small_b ctx (as_seq h0 a) table bits_l tmp;
k.lmul ctx acc tmp acc;
pop_frame ()
inline_for_extraction noextract
let lexp_fw_f_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.exp_fw_f #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc^(2^l) * a^b_i
inline_for_extraction noextract
val lexp_fw_f:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_f_st a_t len ctx_len k l table_len table_inv
let lexp_fw_f #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
lexp_pow2_in_place len ctx_len k ctx acc l;
lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp
inline_for_extraction noextract
let lexp_fw_loop_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> acc:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
Loops.repeati (v bBits / v l) (S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l)) (k.to.refl (as_seq h0 acc)))
inline_for_extraction noextract
val lexp_fw_loop:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_loop_st a_t len ctx_len k l table_len table_inv
let lexp_fw_loop #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table acc =
push_frame ();
let tmp = create len (uint #a_t #SEC 0) in
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@inline_let]
let spec (h:mem) = S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) in
[@inline_let]
let inv h (i:nat{i <= v bBits / v l}) =
modifies (loc acc |+| loc tmp) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeati i (spec h0) (refl1 0) /\
table_inv (as_seq h a) (as_seq h table) in
Loops.eq_repeati0 (v bBits / v l) (spec h0) (refl1 0);
Lib.Loops.for 0ul (bBits /. l) inv
(fun i ->
Loops.unfold_repeati (v bBits / v l) (spec h0) (refl1 0) (v i);
lexp_fw_f len ctx_len k l table_len table_inv pow_a_to_small_b
ctx a bLen bBits b table i acc tmp
);
pop_frame ()
inline_for_extraction noextract
let lexp_fw_acc0_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> acc:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h -> v bBits % v l <> 0 /\
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.exp_fw_acc0 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l))
inline_for_extraction noextract
val lexp_fw_acc0:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_acc0_st a_t len ctx_len k l table_len table_inv
let lexp_fw_acc0 #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table acc =
let h0 = ST.get () in
assert (v (bBits %. l) == v bBits % v l);
let bits_c = bn_get_bits_c bLen bBits b l in
pow_a_to_small_b ctx (as_seq h0 a) table bits_c acc
let mk_lexp_fw_table #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table res =
assert (v (bBits %. l) = v bBits % v l);
if bBits %. l <> 0ul then
lexp_fw_acc0 len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table res
else k.lone ctx res;
lexp_fw_loop len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table res
//-------------------------------------
let lprecomp_get_vartime #a_t len ctx_len k l table_len ctx a table bits_l tmp =
PT.lprecomp_get_vartime #a_t len ctx_len k a table_len table bits_l tmp
let lprecomp_get_consttime #a_t len ctx_len k l table_len ctx a table bits_l tmp =
PT.lprecomp_get_consttime #a_t len ctx_len k a table_len table bits_l tmp
val lemma_pow2_is_divisible_by_2: l:pos -> Lemma (pow2 l % 2 = 0)
let lemma_pow2_is_divisible_by_2 l =
Math.Lemmas.pow2_plus 1 (l - 1);
assert_norm (pow2 1 = 2);
assert (pow2 l = 2 * pow2 (l - 1));
Math.Lemmas.lemma_mod_mul_distr_l 2 (pow2 (l - 1)) 2
inline_for_extraction noextract
val lexp_fw_gen:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len{1 < v table_len /\ v table_len == pow2 (v l)}
-> lprecomp_get:pow_a_to_small_b_st a_t len ctx_len k l table_len
(table_inv_precomp len ctx_len k l table_len) ->
lexp_fw_st a_t len ctx_len k l | false | false | Hacl.Impl.Exponentiation.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lexp_fw_gen:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len{1 < v table_len /\ v table_len == pow2 (v l)}
-> lprecomp_get:pow_a_to_small_b_st a_t len ctx_len k l table_len
(table_inv_precomp len ctx_len k l table_len) ->
lexp_fw_st a_t len ctx_len k l | [] | Hacl.Impl.Exponentiation.lexp_fw_gen | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} ->
ctx_len: Lib.IntTypes.size_t ->
k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len ->
l: Hacl.Impl.Exponentiation.size_window_t a_t len ->
table_len:
Hacl.Impl.Exponentiation.table_len_t len
{1 < Lib.IntTypes.v table_len /\ Lib.IntTypes.v table_len == Prims.pow2 (Lib.IntTypes.v l)} ->
lprecomp_get:
Hacl.Impl.Exponentiation.pow_a_to_small_b_st a_t
len
ctx_len
k
l
table_len
(Hacl.Impl.Exponentiation.table_inv_precomp len ctx_len k l table_len)
-> Hacl.Impl.Exponentiation.lexp_fw_st a_t len ctx_len k l | {
"end_col": 14,
"end_line": 545,
"start_col": 2,
"start_line": 529
} |
Prims.Tot | val lexp_fw_acc0:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_acc0_st a_t len ctx_len k l table_len table_inv | [
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lexp_fw_acc0 #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table acc =
let h0 = ST.get () in
assert (v (bBits %. l) == v bBits % v l);
let bits_c = bn_get_bits_c bLen bBits b l in
pow_a_to_small_b ctx (as_seq h0 a) table bits_c acc | val lexp_fw_acc0:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_acc0_st a_t len ctx_len k l table_len table_inv
let lexp_fw_acc0
#a_t
len
ctx_len
k
l
table_len
table_inv
pow_a_to_small_b
ctx
a
bLen
bBits
b
table
acc
= | false | null | false | let h0 = ST.get () in
assert (v (bBits %. l) == v bBits % v l);
let bits_c = bn_get_bits_c bLen bBits b l in
pow_a_to_small_b ctx (as_seq h0 a) table bits_c acc | {
"checked_file": "Hacl.Impl.Exponentiation.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.PrecompTable.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Exponentiation.fst"
} | [
"total"
] | [
"Hacl.Impl.Exponentiation.Definitions.inttype_a",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Exponentiation.Definitions.concrete_ops",
"Hacl.Impl.Exponentiation.size_window_t",
"Hacl.Impl.Exponentiation.table_len_t",
"Hacl.Impl.Exponentiation.table_inv_t",
"Hacl.Impl.Exponentiation.pow_a_to_small_b_st",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"Lib.Buffer.clbuffer",
"Lib.IntTypes.op_Star_Bang",
"FStar.Ghost.hide",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.IntTypes.int_t",
"Hacl.Impl.Exponentiation.bn_get_bits_c",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.op_Percent_Dot",
"Prims.op_Modulus",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Impl.Exponentiation
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module S = Lib.Exponentiation
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module SN = Hacl.Spec.Bignum
module BB = Hacl.Bignum.Base
module PT = Hacl.Impl.PrecompTable
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc =
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a)) in
[@inline_let]
let spec (h:mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\
snd res == k.to.refl (as_seq h a)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then
k.lmul ctx acc a acc; // acc = (acc * a) % n
k.lsqr ctx a a // a = (a * a) % n
)
inline_for_extraction noextract
val cswap2:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> bit:uint_t a_t SEC{v bit <= 1}
-> p1:lbuffer (uint_t a_t SEC) len
-> p2:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h p1 /\ live h p2 /\ disjoint p1 p2 /\
k.to.linv (as_seq h p1) /\ k.to.linv (as_seq h p2))
(ensures fun h0 _ h1 -> modifies (loc p1 |+| loc p2) h0 h1 /\
k.to.linv (as_seq h1 p1) /\ k.to.linv (as_seq h1 p2) /\
(k.to.refl (as_seq h1 p1), k.to.refl (as_seq h1 p2)) ==
S.cswap (v bit) (k.to.refl (as_seq h0 p1)) (k.to.refl (as_seq h0 p2)))
let cswap2 #a_t len ctx_len k bit p1 p2 =
let h0 = ST.get () in
BN.cswap2 len bit p1 p2;
SN.cswap2_lemma bit (as_seq h0 p1) (as_seq h0 p2)
val lemma_bit_xor_is_sum_mod2: #a_t:inttype_a -> a:uint_t a_t SEC -> b:uint_t a_t SEC -> Lemma
(requires v a <= 1 /\ v b <= 1)
(ensures v (a ^. b) == (v a + v b) % 2)
let lemma_bit_xor_is_sum_mod2 #a_t a b =
match a_t with
| U32 ->
logxor_spec a b;
assert_norm (UInt32.logxor 0ul 0ul == 0ul);
assert_norm (UInt32.logxor 0ul 1ul == 1ul);
assert_norm (UInt32.logxor 1ul 0ul == 1ul);
assert_norm (UInt32.logxor 1ul 1ul == 0ul)
| U64 ->
logxor_spec a b;
assert_norm (UInt64.logxor 0uL 0uL == 0uL);
assert_norm (UInt64.logxor 0uL 1uL == 1uL);
assert_norm (UInt64.logxor 1uL 0uL == 1uL);
assert_norm (UInt64.logxor 1uL 1uL == 0uL)
//r0 = acc; r1 = a
let lexp_mont_ladder_swap_consttime #a_t len ctx_len k ctx a bLen bBits b acc =
push_frame ();
let sw = create 1ul (uint #a_t #SEC 0) in
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec & nat) =
(k.to.refl (as_seq h0 acc), k.to.refl (as_seq h0 a), v (LSeq.index (as_seq h0 sw) 0)) in
[@inline_let]
let spec (h:mem) = S.exp_mont_ladder_swap_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc |+| loc sw) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
v (LSeq.index (as_seq h sw) 0) <= 1 /\
(let (acc1, a1, sw1) = Loops.repeati i (spec h0) (refl1 0) in
a1 == k.to.refl (as_seq h a) /\
acc1 == k.to.refl (as_seq h acc) /\
sw1 == v (LSeq.index (as_seq h sw) 0)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
let h2 = ST.get () in
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b (bBits -! i -! 1ul) in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v bBits - v i - 1);
let sw1 = bit ^. sw.(0ul) in
lemma_bit_xor_is_sum_mod2 #a_t bit (LSeq.index (as_seq h2 sw) 0);
cswap2 len ctx_len k sw1 acc a;
k.lmul ctx a acc a; // a = (a * acc) % n
k.lsqr ctx acc acc; // a = (a * a) % n
sw.(0ul) <- bit
);
let sw0 = sw.(0ul) in
cswap2 len ctx_len k sw0 acc a;
pop_frame ()
let lexp_pow2 #a_t len ctx_len k ctx a b res =
copy res a;
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 res) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc res) h0 h /\
k.to.linv (as_seq h res) /\
k.to.refl (as_seq h res) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx res res)
let lexp_pow2_in_place #a_t len ctx_len k ctx acc b =
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc acc) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx acc acc)
//---------------------------------------------------
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i))
let bn_get_bits_l #b_t bLen bBits b l i =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits -! bBits %. l) = v bBits - v bBits % v l);
[@inline_let] let bk = bBits -! bBits %. l in
assert (v bk == v bBits - v bBits % v l);
Math.Lemmas.lemma_mult_le_left (v l) (v i + 1) (v bBits / v l);
assert (v l * (v i + 1) <= v l * (v bBits / v l));
Math.Lemmas.distributivity_add_right (v l) (v i) 1;
assert (v l * v i + v l <= v bk);
assert (v (bk -! l *! i -! l) == v bk - v l * v i - v l);
let k = bk -! l *! i -! l in
assert (v k == v bk - v l * v i - v l);
Math.Lemmas.lemma_div_le (v k) (v bBits - 1) (bits b_t);
assert (v k / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v k) (v l);
BN.bn_get_bits bLen b k l
inline_for_extraction noextract
val bn_get_bits_c:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t /\ 0 < v bBits % v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == (BD.bn_v h0 b / pow2 (v bBits / v l * v l)) % pow2 (v l))
let bn_get_bits_c #b_t bLen bBits b l =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits /. l *! l) == v bBits / v l * v l);
let i = bBits /. l *! l in
assert (v i == v bBits / v l * v l);
assert (v i <= v bBits - 1);
Math.Lemmas.lemma_div_le (v i) (v bBits - 1) (bits b_t);
assert (v i / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v i) (v l);
BN.bn_get_bits bLen b i l
//---------------------------------------------------
inline_for_extraction noextract
let lmul_acc_pow_a_bits_l_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.mul_acc_pow_a_bits_l #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc * a^b_i
inline_for_extraction noextract
val lmul_acc_pow_a_bits_l:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv
let lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
let h0 = ST.get () in
push_frame ();
let bits_l = bn_get_bits_l bLen bBits b l i in
assert (v bits_l < pow2 (v l));
pow_a_to_small_b ctx (as_seq h0 a) table bits_l tmp;
k.lmul ctx acc tmp acc;
pop_frame ()
inline_for_extraction noextract
let lexp_fw_f_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.exp_fw_f #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc^(2^l) * a^b_i
inline_for_extraction noextract
val lexp_fw_f:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_f_st a_t len ctx_len k l table_len table_inv
let lexp_fw_f #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
lexp_pow2_in_place len ctx_len k ctx acc l;
lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp
inline_for_extraction noextract
let lexp_fw_loop_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> acc:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
Loops.repeati (v bBits / v l) (S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l)) (k.to.refl (as_seq h0 acc)))
inline_for_extraction noextract
val lexp_fw_loop:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_loop_st a_t len ctx_len k l table_len table_inv
let lexp_fw_loop #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table acc =
push_frame ();
let tmp = create len (uint #a_t #SEC 0) in
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@inline_let]
let spec (h:mem) = S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) in
[@inline_let]
let inv h (i:nat{i <= v bBits / v l}) =
modifies (loc acc |+| loc tmp) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeati i (spec h0) (refl1 0) /\
table_inv (as_seq h a) (as_seq h table) in
Loops.eq_repeati0 (v bBits / v l) (spec h0) (refl1 0);
Lib.Loops.for 0ul (bBits /. l) inv
(fun i ->
Loops.unfold_repeati (v bBits / v l) (spec h0) (refl1 0) (v i);
lexp_fw_f len ctx_len k l table_len table_inv pow_a_to_small_b
ctx a bLen bBits b table i acc tmp
);
pop_frame ()
inline_for_extraction noextract
let lexp_fw_acc0_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> acc:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h -> v bBits % v l <> 0 /\
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.exp_fw_acc0 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l))
inline_for_extraction noextract
val lexp_fw_acc0:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_acc0_st a_t len ctx_len k l table_len table_inv | false | false | Hacl.Impl.Exponentiation.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lexp_fw_acc0:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_acc0_st a_t len ctx_len k l table_len table_inv | [] | Hacl.Impl.Exponentiation.lexp_fw_acc0 | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} ->
ctx_len: Lib.IntTypes.size_t ->
k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len ->
l: Hacl.Impl.Exponentiation.size_window_t a_t len ->
table_len: Hacl.Impl.Exponentiation.table_len_t len ->
table_inv: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len ->
pow_a_to_small_b:
Hacl.Impl.Exponentiation.pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv
-> Hacl.Impl.Exponentiation.lexp_fw_acc0_st a_t len ctx_len k l table_len table_inv | {
"end_col": 53,
"end_line": 488,
"start_col": 105,
"start_line": 484
} |
Prims.Tot | val lexp_fw_loop:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_loop_st a_t len ctx_len k l table_len table_inv | [
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lexp_fw_loop #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table acc =
push_frame ();
let tmp = create len (uint #a_t #SEC 0) in
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@inline_let]
let spec (h:mem) = S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) in
[@inline_let]
let inv h (i:nat{i <= v bBits / v l}) =
modifies (loc acc |+| loc tmp) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeati i (spec h0) (refl1 0) /\
table_inv (as_seq h a) (as_seq h table) in
Loops.eq_repeati0 (v bBits / v l) (spec h0) (refl1 0);
Lib.Loops.for 0ul (bBits /. l) inv
(fun i ->
Loops.unfold_repeati (v bBits / v l) (spec h0) (refl1 0) (v i);
lexp_fw_f len ctx_len k l table_len table_inv pow_a_to_small_b
ctx a bLen bBits b table i acc tmp
);
pop_frame () | val lexp_fw_loop:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_loop_st a_t len ctx_len k l table_len table_inv
let lexp_fw_loop
#a_t
len
ctx_len
k
l
table_len
table_inv
pow_a_to_small_b
ctx
a
bLen
bBits
b
table
acc
= | false | null | false | push_frame ();
let tmp = create len (uint #a_t #SEC 0) in
let h0 = ST.get () in
[@@ inline_let ]let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@@ inline_let ]let spec (h: mem) =
S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l)
in
[@@ inline_let ]let inv h (i: nat{i <= v bBits / v l}) =
modifies (loc acc |+| loc tmp) h0 h /\ k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeati i (spec h0) (refl1 0) /\
table_inv (as_seq h a) (as_seq h table)
in
Loops.eq_repeati0 (v bBits / v l) (spec h0) (refl1 0);
Lib.Loops.for 0ul
(bBits /. l)
inv
(fun i ->
Loops.unfold_repeati (v bBits / v l) (spec h0) (refl1 0) (v i);
lexp_fw_f len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc
tmp);
pop_frame () | {
"checked_file": "Hacl.Impl.Exponentiation.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.PrecompTable.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Exponentiation.fst"
} | [
"total"
] | [
"Hacl.Impl.Exponentiation.Definitions.inttype_a",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Exponentiation.Definitions.concrete_ops",
"Hacl.Impl.Exponentiation.size_window_t",
"Hacl.Impl.Exponentiation.table_len_t",
"Hacl.Impl.Exponentiation.table_inv_t",
"Hacl.Impl.Exponentiation.pow_a_to_small_b_st",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"Lib.Buffer.clbuffer",
"Lib.IntTypes.op_Star_Bang",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Lib.Loops.for",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Slash_Dot",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Hacl.Impl.Exponentiation.lexp_fw_f",
"Lib.LoopCombinators.unfold_repeati",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec",
"FStar.Ghost.reveal",
"Hacl.Impl.Exponentiation.Definitions.to_comm_monoid",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__to",
"Lib.LoopCombinators.eq_repeati0",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.logical",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv",
"Lib.Buffer.as_seq",
"Prims.eq2",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl",
"Lib.LoopCombinators.repeati",
"Lib.Buffer.CONST",
"Lib.Exponentiation.exp_fw_f",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid",
"Hacl.Bignum.Definitions.bn_v",
"Prims.int",
"FStar.HyperStack.ST.get",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Exponentiation
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module S = Lib.Exponentiation
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module SN = Hacl.Spec.Bignum
module BB = Hacl.Bignum.Base
module PT = Hacl.Impl.PrecompTable
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc =
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a)) in
[@inline_let]
let spec (h:mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\
snd res == k.to.refl (as_seq h a)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then
k.lmul ctx acc a acc; // acc = (acc * a) % n
k.lsqr ctx a a // a = (a * a) % n
)
inline_for_extraction noextract
val cswap2:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> bit:uint_t a_t SEC{v bit <= 1}
-> p1:lbuffer (uint_t a_t SEC) len
-> p2:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h p1 /\ live h p2 /\ disjoint p1 p2 /\
k.to.linv (as_seq h p1) /\ k.to.linv (as_seq h p2))
(ensures fun h0 _ h1 -> modifies (loc p1 |+| loc p2) h0 h1 /\
k.to.linv (as_seq h1 p1) /\ k.to.linv (as_seq h1 p2) /\
(k.to.refl (as_seq h1 p1), k.to.refl (as_seq h1 p2)) ==
S.cswap (v bit) (k.to.refl (as_seq h0 p1)) (k.to.refl (as_seq h0 p2)))
let cswap2 #a_t len ctx_len k bit p1 p2 =
let h0 = ST.get () in
BN.cswap2 len bit p1 p2;
SN.cswap2_lemma bit (as_seq h0 p1) (as_seq h0 p2)
val lemma_bit_xor_is_sum_mod2: #a_t:inttype_a -> a:uint_t a_t SEC -> b:uint_t a_t SEC -> Lemma
(requires v a <= 1 /\ v b <= 1)
(ensures v (a ^. b) == (v a + v b) % 2)
let lemma_bit_xor_is_sum_mod2 #a_t a b =
match a_t with
| U32 ->
logxor_spec a b;
assert_norm (UInt32.logxor 0ul 0ul == 0ul);
assert_norm (UInt32.logxor 0ul 1ul == 1ul);
assert_norm (UInt32.logxor 1ul 0ul == 1ul);
assert_norm (UInt32.logxor 1ul 1ul == 0ul)
| U64 ->
logxor_spec a b;
assert_norm (UInt64.logxor 0uL 0uL == 0uL);
assert_norm (UInt64.logxor 0uL 1uL == 1uL);
assert_norm (UInt64.logxor 1uL 0uL == 1uL);
assert_norm (UInt64.logxor 1uL 1uL == 0uL)
//r0 = acc; r1 = a
let lexp_mont_ladder_swap_consttime #a_t len ctx_len k ctx a bLen bBits b acc =
push_frame ();
let sw = create 1ul (uint #a_t #SEC 0) in
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec & nat) =
(k.to.refl (as_seq h0 acc), k.to.refl (as_seq h0 a), v (LSeq.index (as_seq h0 sw) 0)) in
[@inline_let]
let spec (h:mem) = S.exp_mont_ladder_swap_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc |+| loc sw) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
v (LSeq.index (as_seq h sw) 0) <= 1 /\
(let (acc1, a1, sw1) = Loops.repeati i (spec h0) (refl1 0) in
a1 == k.to.refl (as_seq h a) /\
acc1 == k.to.refl (as_seq h acc) /\
sw1 == v (LSeq.index (as_seq h sw) 0)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
let h2 = ST.get () in
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b (bBits -! i -! 1ul) in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v bBits - v i - 1);
let sw1 = bit ^. sw.(0ul) in
lemma_bit_xor_is_sum_mod2 #a_t bit (LSeq.index (as_seq h2 sw) 0);
cswap2 len ctx_len k sw1 acc a;
k.lmul ctx a acc a; // a = (a * acc) % n
k.lsqr ctx acc acc; // a = (a * a) % n
sw.(0ul) <- bit
);
let sw0 = sw.(0ul) in
cswap2 len ctx_len k sw0 acc a;
pop_frame ()
let lexp_pow2 #a_t len ctx_len k ctx a b res =
copy res a;
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 res) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc res) h0 h /\
k.to.linv (as_seq h res) /\
k.to.refl (as_seq h res) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx res res)
let lexp_pow2_in_place #a_t len ctx_len k ctx acc b =
let h0 = ST.get () in
[@ inline_let]
let refl1 i : GTot k.to.a_spec = k.to.refl (as_seq h0 acc) in
[@ inline_let]
let spec h0 = S.sqr k.to.comm_monoid in
[@ inline_let]
let inv h (i:nat{i <= v b}) =
modifies (loc acc) h0 h /\
k.to.linv (as_seq h acc) /\
k.to.refl (as_seq h acc) == Loops.repeat i (spec h0) (refl1 0) in
Loops.eq_repeat0 (spec h0) (refl1 0);
Lib.Loops.for 0ul b inv
(fun j ->
Loops.unfold_repeat (v b) (spec h0) (refl1 0) (v j);
k.lsqr ctx acc acc)
//---------------------------------------------------
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val bn_get_bits_l:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t}
-> i:size_t{v i < v bBits / v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == S.get_bits_l (v bBits) (BD.bn_v h0 b) (v l) (v i))
let bn_get_bits_l #b_t bLen bBits b l i =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits -! bBits %. l) = v bBits - v bBits % v l);
[@inline_let] let bk = bBits -! bBits %. l in
assert (v bk == v bBits - v bBits % v l);
Math.Lemmas.lemma_mult_le_left (v l) (v i + 1) (v bBits / v l);
assert (v l * (v i + 1) <= v l * (v bBits / v l));
Math.Lemmas.distributivity_add_right (v l) (v i) 1;
assert (v l * v i + v l <= v bk);
assert (v (bk -! l *! i -! l) == v bk - v l * v i - v l);
let k = bk -! l *! i -! l in
assert (v k == v bk - v l * v i - v l);
Math.Lemmas.lemma_div_le (v k) (v bBits - 1) (bits b_t);
assert (v k / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v k) (v l);
BN.bn_get_bits bLen b k l
inline_for_extraction noextract
val bn_get_bits_c:
#b_t:inttype_a
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits b_t < v bLen}
-> b:lbuffer (uint_t b_t SEC) bLen
-> l:size_t{0 < v l /\ v l < bits b_t /\ 0 < v bBits % v l} ->
Stack (uint_t b_t SEC)
(requires fun h -> live h b /\
BD.bn_v h b < pow2 (v bBits))
(ensures fun h0 r h1 -> h0 == h1 /\
v r == (BD.bn_v h0 b / pow2 (v bBits / v l * v l)) % pow2 (v l))
let bn_get_bits_c #b_t bLen bBits b l =
Math.Lemmas.euclidean_division_definition (v bBits) (v l);
assert (v (bBits /. l *! l) == v bBits / v l * v l);
let i = bBits /. l *! l in
assert (v i == v bBits / v l * v l);
assert (v i <= v bBits - 1);
Math.Lemmas.lemma_div_le (v i) (v bBits - 1) (bits b_t);
assert (v i / bits b_t < v bLen);
let h0 = ST.get () in
SN.bn_get_bits_lemma (as_seq h0 b) (v i) (v l);
BN.bn_get_bits bLen b i l
//---------------------------------------------------
inline_for_extraction noextract
let lmul_acc_pow_a_bits_l_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.mul_acc_pow_a_bits_l #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc * a^b_i
inline_for_extraction noextract
val lmul_acc_pow_a_bits_l:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lmul_acc_pow_a_bits_l_st a_t len ctx_len k l table_len table_inv
let lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
let h0 = ST.get () in
push_frame ();
let bits_l = bn_get_bits_l bLen bBits b l i in
assert (v bits_l < pow2 (v l));
pow_a_to_small_b ctx (as_seq h0 a) table bits_l tmp;
k.lmul ctx acc tmp acc;
pop_frame ()
inline_for_extraction noextract
let lexp_fw_f_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> i:size_t{v i < v bBits / v l}
-> acc:lbuffer (uint_t a_t SEC) len
-> tmp:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
live h tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint tmp acc /\ disjoint tmp ctx /\ disjoint tmp table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc |+| loc tmp) h0 h1 /\
k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
S.exp_fw_f #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l) (v i) (k.to.refl (as_seq h0 acc)))
// acc <- acc^(2^l) * a^b_i
inline_for_extraction noextract
val lexp_fw_f:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_f_st a_t len ctx_len k l table_len table_inv
let lexp_fw_f #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp =
lexp_pow2_in_place len ctx_len k ctx acc l;
lmul_acc_pow_a_bits_l #a_t len ctx_len k l table_len table_inv pow_a_to_small_b ctx a bLen bBits b table i acc tmp
inline_for_extraction noextract
let lexp_fw_loop_st
(a_t:inttype_a)
(len:size_t{v len > 0})
(ctx_len:size_t)
(k:concrete_ops a_t len ctx_len)
(l:size_window_t a_t len)
(table_len:table_len_t len)
(table_inv:table_inv_t a_t len table_len) =
ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> table:clbuffer (uint_t a_t SEC) (table_len *! len)
-> acc:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h acc /\ live h ctx /\ live h table /\
disjoint a acc /\ disjoint a ctx /\ disjoint b acc /\
disjoint acc ctx /\ disjoint acc table /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
table_inv (as_seq h a) (as_seq h table))
(ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ k.to.linv (as_seq h1 acc) /\
k.to.refl (as_seq h1 acc) ==
Loops.repeati (v bBits / v l) (S.exp_fw_f k.to.comm_monoid (k.to.refl (as_seq h0 a))
(v bBits) (BD.bn_v h0 b) (v l)) (k.to.refl (as_seq h0 acc)))
inline_for_extraction noextract
val lexp_fw_loop:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_loop_st a_t len ctx_len k l table_len table_inv | false | false | Hacl.Impl.Exponentiation.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lexp_fw_loop:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> l:size_window_t a_t len
-> table_len:table_len_t len
-> table_inv:table_inv_t a_t len table_len
-> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv ->
lexp_fw_loop_st a_t len ctx_len k l table_len table_inv | [] | Hacl.Impl.Exponentiation.lexp_fw_loop | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} ->
ctx_len: Lib.IntTypes.size_t ->
k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len ->
l: Hacl.Impl.Exponentiation.size_window_t a_t len ->
table_len: Hacl.Impl.Exponentiation.table_len_t len ->
table_inv: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len ->
pow_a_to_small_b:
Hacl.Impl.Exponentiation.pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv
-> Hacl.Impl.Exponentiation.lexp_fw_loop_st a_t len ctx_len k l table_len table_inv | {
"end_col": 14,
"end_line": 439,
"start_col": 2,
"start_line": 415
} |
FStar.HyperStack.ST.Stack | val lexp_mont_ladder_swap_consttime:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> res:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h ctx /\
disjoint a res /\ disjoint b res /\ disjoint a b /\
disjoint ctx a /\ disjoint ctx res /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a))
(ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\
k.to.linv (as_seq h1 res) /\
k.to.refl (as_seq h1 res) ==
S.exp_mont_ladder_swap #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.PrecompTable",
"short_module": "PT"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lexp_mont_ladder_swap_consttime #a_t len ctx_len k ctx a bLen bBits b acc =
push_frame ();
let sw = create 1ul (uint #a_t #SEC 0) in
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec & nat) =
(k.to.refl (as_seq h0 acc), k.to.refl (as_seq h0 a), v (LSeq.index (as_seq h0 sw) 0)) in
[@inline_let]
let spec (h:mem) = S.exp_mont_ladder_swap_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc |+| loc sw) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
v (LSeq.index (as_seq h sw) 0) <= 1 /\
(let (acc1, a1, sw1) = Loops.repeati i (spec h0) (refl1 0) in
a1 == k.to.refl (as_seq h a) /\
acc1 == k.to.refl (as_seq h acc) /\
sw1 == v (LSeq.index (as_seq h sw) 0)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
let h2 = ST.get () in
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b (bBits -! i -! 1ul) in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v bBits - v i - 1);
let sw1 = bit ^. sw.(0ul) in
lemma_bit_xor_is_sum_mod2 #a_t bit (LSeq.index (as_seq h2 sw) 0);
cswap2 len ctx_len k sw1 acc a;
k.lmul ctx a acc a; // a = (a * acc) % n
k.lsqr ctx acc acc; // a = (a * a) % n
sw.(0ul) <- bit
);
let sw0 = sw.(0ul) in
cswap2 len ctx_len k sw0 acc a;
pop_frame () | val lexp_mont_ladder_swap_consttime:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> res:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h ctx /\
disjoint a res /\ disjoint b res /\ disjoint a b /\
disjoint ctx a /\ disjoint ctx res /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a))
(ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\
k.to.linv (as_seq h1 res) /\
k.to.refl (as_seq h1 res) ==
S.exp_mont_ladder_swap #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b))
let lexp_mont_ladder_swap_consttime #a_t len ctx_len k ctx a bLen bBits b acc = | true | null | false | push_frame ();
let sw = create 1ul (uint #a_t #SEC 0) in
k.lone ctx acc;
let h0 = ST.get () in
[@@ inline_let ]let refl1 i : GTot (k.to.a_spec & k.to.a_spec & nat) =
(k.to.refl (as_seq h0 acc), k.to.refl (as_seq h0 a), v (LSeq.index (as_seq h0 sw) 0))
in
[@@ inline_let ]let spec (h: mem) =
S.exp_mont_ladder_swap_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b)
in
[@@ inline_let ]let inv h (i: nat{i <= v bBits}) =
modifies (loc a |+| loc acc |+| loc sw) h0 h /\ k.to.linv (as_seq h a) /\ k.to.linv (as_seq h acc) /\
v (LSeq.index (as_seq h sw) 0) <= 1 /\
(let acc1, a1, sw1 = Loops.repeati i (spec h0) (refl1 0) in
a1 == k.to.refl (as_seq h a) /\ acc1 == k.to.refl (as_seq h acc) /\
sw1 == v (LSeq.index (as_seq h sw) 0))
in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul
bBits
inv
(fun i ->
let h2 = ST.get () in
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b (bBits -! i -! 1ul) in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v bBits - v i - 1);
let sw1 = bit ^. sw.(0ul) in
lemma_bit_xor_is_sum_mod2 #a_t bit (LSeq.index (as_seq h2 sw) 0);
cswap2 len ctx_len k sw1 acc a;
k.lmul ctx a acc a;
k.lsqr ctx acc acc;
sw.(0ul) <- bit);
let sw0 = sw.(0ul) in
cswap2 len ctx_len k sw0 acc a;
pop_frame () | {
"checked_file": "Hacl.Impl.Exponentiation.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.PrecompTable.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Exponentiation.fst"
} | [] | [
"Hacl.Impl.Exponentiation.Definitions.inttype_a",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Exponentiation.Definitions.concrete_ops",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.op_LessThan",
"Prims.op_Division",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Exponentiation.cswap2",
"Lib.IntTypes.int_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"FStar.UInt32.__uint_to_t",
"Lib.Loops.for",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__lsqr",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__lmul",
"Hacl.Impl.Exponentiation.lemma_bit_xor_is_sum_mod2",
"Lib.Sequence.index",
"Lib.Buffer.as_seq",
"Lib.IntTypes.op_Hat_Dot",
"Hacl.Spec.Bignum.bn_get_ith_bit_lemma",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.bn_get_ith_bit",
"Lib.IntTypes.op_Subtraction_Bang",
"Lib.LoopCombinators.unfold_repeati",
"FStar.Pervasives.Native.tuple3",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec",
"FStar.Ghost.reveal",
"Hacl.Impl.Exponentiation.Definitions.to_comm_monoid",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__to",
"Prims.nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.LoopCombinators.eq_repeati0",
"Prims.logical",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv",
"Prims.eq2",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.op_GreaterThanOrEqual",
"Lib.LoopCombinators.repeati",
"Lib.Exponentiation.exp_mont_ladder_swap_f",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid",
"Hacl.Bignum.Definitions.bn_v",
"FStar.Pervasives.Native.Mktuple3",
"Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__lone",
"Lib.Buffer.lbuffer_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Exponentiation
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module S = Lib.Exponentiation
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module SN = Hacl.Spec.Bignum
module BB = Hacl.Bignum.Base
module PT = Hacl.Impl.PrecompTable
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let lexp_rl_vartime #a_t len ctx_len k ctx a bLen bBits b acc =
k.lone ctx acc;
let h0 = ST.get () in
[@inline_let]
let refl1 i : GTot (k.to.a_spec & k.to.a_spec) =
(refl (as_seq h0 acc), refl (as_seq h0 a)) in
[@inline_let]
let spec (h:mem) = S.exp_rl_f k.to.comm_monoid (v bBits) (BD.bn_v h0 b) in
[@inline_let]
let inv h (i:nat{i <= v bBits}) =
modifies (loc a |+| loc acc) h0 h /\
k.to.linv (as_seq h a) /\
k.to.linv (as_seq h acc) /\
(let res = Loops.repeati i (spec h0) (refl1 0) in
fst res == k.to.refl (as_seq h acc) /\
snd res == k.to.refl (as_seq h a)) in
Loops.eq_repeati0 (v bBits) (spec h0) (refl1 0);
Lib.Loops.for 0ul bBits inv
(fun i ->
Loops.unfold_repeati (v bBits) (spec h0) (refl1 0) (v i);
let bit = BN.bn_get_ith_bit bLen b i in
SN.bn_get_ith_bit_lemma (as_seq h0 b) (v i);
if not (BB.unsafe_bool_of_limb0 bit) then
k.lmul ctx acc a acc; // acc = (acc * a) % n
k.lsqr ctx a a // a = (a * a) % n
)
inline_for_extraction noextract
val cswap2:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> bit:uint_t a_t SEC{v bit <= 1}
-> p1:lbuffer (uint_t a_t SEC) len
-> p2:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h p1 /\ live h p2 /\ disjoint p1 p2 /\
k.to.linv (as_seq h p1) /\ k.to.linv (as_seq h p2))
(ensures fun h0 _ h1 -> modifies (loc p1 |+| loc p2) h0 h1 /\
k.to.linv (as_seq h1 p1) /\ k.to.linv (as_seq h1 p2) /\
(k.to.refl (as_seq h1 p1), k.to.refl (as_seq h1 p2)) ==
S.cswap (v bit) (k.to.refl (as_seq h0 p1)) (k.to.refl (as_seq h0 p2)))
let cswap2 #a_t len ctx_len k bit p1 p2 =
let h0 = ST.get () in
BN.cswap2 len bit p1 p2;
SN.cswap2_lemma bit (as_seq h0 p1) (as_seq h0 p2)
val lemma_bit_xor_is_sum_mod2: #a_t:inttype_a -> a:uint_t a_t SEC -> b:uint_t a_t SEC -> Lemma
(requires v a <= 1 /\ v b <= 1)
(ensures v (a ^. b) == (v a + v b) % 2)
let lemma_bit_xor_is_sum_mod2 #a_t a b =
match a_t with
| U32 ->
logxor_spec a b;
assert_norm (UInt32.logxor 0ul 0ul == 0ul);
assert_norm (UInt32.logxor 0ul 1ul == 1ul);
assert_norm (UInt32.logxor 1ul 0ul == 1ul);
assert_norm (UInt32.logxor 1ul 1ul == 0ul)
| U64 ->
logxor_spec a b;
assert_norm (UInt64.logxor 0uL 0uL == 0uL);
assert_norm (UInt64.logxor 0uL 1uL == 1uL);
assert_norm (UInt64.logxor 1uL 0uL == 1uL);
assert_norm (UInt64.logxor 1uL 1uL == 0uL)
//r0 = acc; r1 = a | false | false | Hacl.Impl.Exponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lexp_mont_ladder_swap_consttime:
#a_t:inttype_a
-> len:size_t{v len > 0}
-> ctx_len:size_t
-> k:concrete_ops a_t len ctx_len
-> ctx:lbuffer (uint_t a_t SEC) ctx_len
-> a:lbuffer (uint_t a_t SEC) len
-> bLen:size_t
-> bBits:size_t{(v bBits - 1) / bits a_t < v bLen}
-> b:lbuffer (uint_t a_t SEC) bLen
-> res:lbuffer (uint_t a_t SEC) len ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h ctx /\
disjoint a res /\ disjoint b res /\ disjoint a b /\
disjoint ctx a /\ disjoint ctx res /\
BD.bn_v h b < pow2 (v bBits) /\
k.to.linv_ctx (as_seq h ctx) /\
k.to.linv (as_seq h a))
(ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\
k.to.linv (as_seq h1 res) /\
k.to.refl (as_seq h1 res) ==
S.exp_mont_ladder_swap #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) | [] | Hacl.Impl.Exponentiation.lexp_mont_ladder_swap_consttime | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} ->
ctx_len: Lib.IntTypes.size_t ->
k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len ->
ctx: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) ctx_len ->
a: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) len ->
bLen: Lib.IntTypes.size_t ->
bBits:
Lib.IntTypes.size_t{(Lib.IntTypes.v bBits - 1) / Lib.IntTypes.bits a_t < Lib.IntTypes.v bLen} ->
b: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) bLen ->
res: Lib.Buffer.lbuffer (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) len
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 145,
"start_col": 2,
"start_line": 103
} |
Prims.Tot | val mk_impl (a: hash_alg) (m: m_spec a) : impl | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|) | val mk_impl (a: hash_alg) (m: m_spec a) : impl
let mk_impl (a: hash_alg) (m: m_spec a) : impl = | false | null | false | (| a, m |) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.m_spec",
"Prims.Mkdtuple2",
"Hacl.Hash.Definitions.impl"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_impl (a: hash_alg) (m: m_spec a) : impl | [] | Hacl.Hash.Definitions.mk_impl | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> m: Hacl.Hash.Definitions.m_spec a -> Hacl.Hash.Definitions.impl | {
"end_col": 55,
"end_line": 52,
"start_col": 47,
"start_line": 52
} |
Prims.Tot | val get_alg (i: impl) : hash_alg | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a | val get_alg (i: impl) : hash_alg
let get_alg (i: impl) : hash_alg = | false | null | false | match i with | (| a , m |) -> a | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.m_spec"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_alg (i: impl) : hash_alg | [] | Hacl.Hash.Definitions.get_alg | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Spec.Hash.Definitions.hash_alg | {
"end_col": 28,
"end_line": 56,
"start_col": 2,
"start_line": 56
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 } | let blocks_t (a: hash_alg) = | false | null | false | b: B.buffer uint8 {B.length b % block_length a = 0} | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.block_length"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val blocks_t : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Hacl.Hash.Definitions.blocks_t | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 54,
"end_line": 198,
"start_col": 2,
"start_line": 198
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i))) | let init_st (i: impl) = | false | null | false | s: state i
-> ST.Stack unit
(requires (fun h -> B.live h s))
(ensures
(fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\ as_seq h1 s == Spec.Agile.Hash.init (get_alg i))) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Hacl.Hash.Definitions.state",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.live",
"Hacl.Hash.Definitions.impl_word",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.eq2",
"Spec.Hash.Definitions.words_state",
"Hacl.Hash.Definitions.get_alg",
"Hacl.Hash.Definitions.as_seq",
"Spec.Agile.Hash.init"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s)) | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val init_st : i: Hacl.Hash.Definitions.impl -> Type0 | [] | Hacl.Hash.Definitions.init_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Type0 | {
"end_col": 53,
"end_line": 232,
"start_col": 23,
"start_line": 227
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1)) | let alloca_st (i: impl) = | false | null | false | unit
-> ST.StackInline (state i)
(requires (fun h -> HS.is_stack_region (HS.get_tip h)))
(ensures
(fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\ B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\ B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1)) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Prims.unit",
"Hacl.Hash.Definitions.state",
"FStar.Monotonic.HyperStack.mem",
"Prims.b2t",
"FStar.Monotonic.HyperStack.is_stack_region",
"FStar.Monotonic.HyperStack.get_tip",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.eq2",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"Hacl.Hash.Definitions.impl_word",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.words_state",
"Hacl.Hash.Definitions.get_alg",
"Hacl.Hash.Definitions.as_seq",
"Spec.Agile.Hash.init",
"LowStar.Monotonic.Buffer.live",
"LowStar.Monotonic.Buffer.fresh_loc",
"LowStar.Monotonic.Buffer.loc_buffer"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *) | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val alloca_st : i: Hacl.Hash.Definitions.impl -> Type0 | [] | Hacl.Hash.Definitions.alloca_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Type0 | {
"end_col": 40,
"end_line": 213,
"start_col": 25,
"start_line": 205
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s)) | let malloc_st (i: impl) = | false | null | false | r: HS.rid
-> ST.ST (state i)
(requires (fun h -> ST.is_eternal_region r))
(ensures
(fun h0 s h1 ->
B.live h1 s /\ M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\ B.freeable s)) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"FStar.Monotonic.HyperHeap.rid",
"Hacl.Hash.Definitions.state",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.is_eternal_region",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Hacl.Hash.Definitions.impl_word",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"LowStar.Monotonic.Buffer.fresh_loc",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"LowStar.Monotonic.Buffer.loc_includes",
"LowStar.Monotonic.Buffer.loc_region_only",
"LowStar.Monotonic.Buffer.freeable"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1)) | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val malloc_st : i: Hacl.Hash.Definitions.impl -> Type0 | [] | Hacl.Hash.Definitions.malloc_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Type0 | {
"end_col": 18,
"end_line": 224,
"start_col": 25,
"start_line": 216
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fixed_len_impl = i:impl { not (is_shake (dfst i)) } | let fixed_len_impl = | false | null | false | i: impl{not (is_shake (dfst i))} | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Prims.b2t",
"Prims.op_Negation",
"Spec.Hash.Definitions.is_shake",
"FStar.Pervasives.dfst",
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.m_spec"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block)))
noextract inline_for_extraction
let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len))))
// Note: we cannot take more than 4GB of data because we are currently
// constrained by the size of buffers...
noextract inline_for_extraction
let update_multi_st (i:impl) =
s:state i ->
ev:extra_state (get_alg i) ->
blocks:blocks_t (get_alg i) ->
n:size_t { B.length blocks = block_length (get_alg i) * v n } ->
ST.Stack unit
(requires (fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\
B.live h s /\ B.live h blocks /\ B.disjoint s blocks))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks)))
noextract inline_for_extraction
let prev_len_t (a: hash_alg) =
if is_keccak a then
unit
else
prev_len:len_t a { len_v a prev_len % block_length a = 0 }
noextract inline_for_extraction
let prev_len_v #a (prev_len: prev_len_t a): Spec.Hash.Incremental.Definitions.prev_length_t a
=
if is_keccak a then
()
else
len_v a prev_len
noextract inline_for_extraction
let extra_state_of_prev_length #a (x: Spec.Hash.Incremental.Definitions.prev_length_t a): Spec.Agile.Hash.extra_state a =
match a with
| Blake2B | Blake2S -> x
| _ -> ()
noextract inline_for_extraction
let update_last_st (i:impl) =
let a = get_alg i in
s:state i ->
prev_len:prev_len_t a ->
input:B.buffer uint8 {
(if is_keccak a then True else (B.length input + len_v a prev_len) `less_than_max_input_length` a) /\
B.length input <= block_length a
} ->
input_len:size_t { B.length input = v input_len } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h input /\ B.disjoint s input /\
Spec.Agile.Hash.update_multi_pre a (extra_state_of_prev_length (prev_len_v prev_len)) (B.as_seq h input)))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Hash.Incremental.update_last a (as_seq h0 s)
(prev_len_v prev_len)
(B.as_seq h0 input))) | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fixed_len_impl : Type0 | [] | Hacl.Hash.Definitions.fixed_len_impl | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 55,
"end_line": 317,
"start_col": 21,
"start_line": 317
} |
|
Prims.Tot | val m_spec (a: hash_alg) : Type0 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit | val m_spec (a: hash_alg) : Type0
let m_spec (a: hash_alg) : Type0 = | false | null | false | match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> unit | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Prims.unit"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val m_spec (a: hash_alg) : Type0 | [] | Hacl.Hash.Definitions.m_spec | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 75,
"end_line": 26,
"start_col": 2,
"start_line": 21
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a } | let hash_t (a: fixed_len_alg) = | false | null | false | b: B.buffer uint8 {B.length b = hash_length a} | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.fixed_len_alg",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.hash_length"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 } | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_t : a: Spec.Hash.Definitions.fixed_len_alg -> Type0 | [] | Hacl.Hash.Definitions.hash_t | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.fixed_len_alg -> Type0 | {
"end_col": 79,
"end_line": 200,
"start_col": 32,
"start_line": 200
} |
|
Prims.Tot | val get_spec (i: impl) : m_spec (get_alg i) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m | val get_spec (i: impl) : m_spec (get_alg i)
let get_spec (i: impl) : m_spec (get_alg i) = | false | null | false | match i with | (| a , m |) -> m | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.m_spec",
"Hacl.Hash.Definitions.get_alg"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_spec (i: impl) : m_spec (get_alg i) | [] | Hacl.Hash.Definitions.get_spec | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Hacl.Hash.Definitions.m_spec (Hacl.Hash.Definitions.get_alg i) | {
"end_col": 28,
"end_line": 60,
"start_col": 2,
"start_line": 60
} |
Prims.Tot | val extra_state (a: hash_alg) : Type0 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit | val extra_state (a: hash_alg) : Type0
let extra_state (a: hash_alg) : Type0 = | false | null | false | match a with
| Blake2S -> s: uint_t U64 PUB {v s % block_length a = 0}
| Blake2B -> s: uint_t U128 PUB {v s % block_length a = 0}
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> unit | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.PUB",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Lib.IntTypes.v",
"Spec.Hash.Definitions.block_length",
"Lib.IntTypes.U128",
"Prims.unit"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val extra_state (a: hash_alg) : Type0 | [] | Hacl.Hash.Definitions.extra_state | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 75,
"end_line": 36,
"start_col": 2,
"start_line": 30
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len)))) | let pad_st (a: md_alg) = | false | null | false | len: len_t a -> dst: B.buffer uint8
-> ST.Stack unit
(requires
(fun h ->
(len_v a len) `less_than_max_input_length` a /\ B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures
(fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len)))) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.md_alg",
"Spec.Hash.Definitions.len_t",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"Spec.Hash.Definitions.len_v",
"LowStar.Monotonic.Buffer.live",
"LowStar.Buffer.trivial_preorder",
"Prims.op_Equality",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"Spec.Hash.Definitions.pad_length",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"FStar.Seq.Base.equal",
"LowStar.Monotonic.Buffer.as_seq",
"Spec.Hash.MD.pad"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block))) | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pad_st : a: Spec.Hash.Definitions.md_alg -> Type0 | [] | Hacl.Hash.Definitions.pad_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.md_alg -> Type0 | {
"end_col": 70,
"end_line": 255,
"start_col": 25,
"start_line": 247
} |
|
Prims.Tot | val ev_v (#a: hash_alg) (ev: extra_state a) : Spec.Hash.Definitions.extra_state a | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> () | val ev_v (#a: hash_alg) (ev: extra_state a) : Spec.Hash.Definitions.extra_state a
let ev_v (#a: hash_alg) (ev: extra_state a) : Spec.Hash.Definitions.extra_state a = | false | null | false | match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> () | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.extra_state",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.PUB",
"Lib.IntTypes.U128",
"Spec.Hash.Definitions.extra_state"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ev_v (#a: hash_alg) (ev: extra_state a) : Spec.Hash.Definitions.extra_state a | [] | Hacl.Hash.Definitions.ev_v | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ev: Hacl.Hash.Definitions.extra_state a -> Spec.Hash.Definitions.extra_state a | {
"end_col": 73,
"end_line": 46,
"start_col": 2,
"start_line": 40
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a | let impl_state_length (i: impl) = | false | null | false | [@@ inline_let ]let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> state_word_length a | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"FStar.UInt32.v",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Blake2.Core.row_len",
"Spec.Hash.Definitions.to_blake_alg",
"Hacl.Hash.Definitions.get_spec",
"Spec.Hash.Definitions.state_word_length",
"Prims.int",
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.get_alg"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val impl_state_length : i: Hacl.Hash.Definitions.impl -> Prims.int | [] | Hacl.Hash.Definitions.impl_state_length | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Prims.int | {
"end_col": 90,
"end_line": 80,
"start_col": 2,
"start_line": 74
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_st (a: fixed_len_alg) =
input:B.buffer uint8 ->
input_len:size_t { B.length input = v input_len } ->
dst:hash_t a->
ST.Stack unit
(requires (fun h ->
B.live h input /\
B.live h dst /\
B.disjoint input dst /\
B.length input `less_than_max_input_length` a))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Agile.Hash.hash a (B.as_seq h0 input)))) | let hash_st (a: fixed_len_alg) = | false | null | false | input: B.buffer uint8 -> input_len: size_t{B.length input = v input_len} -> dst: hash_t a
-> ST.Stack unit
(requires
(fun h ->
B.live h input /\ B.live h dst /\ B.disjoint input dst /\
(B.length input) `less_than_max_input_length` a))
(ensures
(fun h0 _ h1 ->
B.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Agile.Hash.hash a (B.as_seq h0 input)))) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.fixed_len_alg",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_t",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Monotonic.Buffer.disjoint",
"Spec.Hash.Definitions.less_than_max_input_length",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"FStar.Seq.Base.equal",
"LowStar.Monotonic.Buffer.as_seq",
"Spec.Agile.Hash.hash"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block)))
noextract inline_for_extraction
let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len))))
// Note: we cannot take more than 4GB of data because we are currently
// constrained by the size of buffers...
noextract inline_for_extraction
let update_multi_st (i:impl) =
s:state i ->
ev:extra_state (get_alg i) ->
blocks:blocks_t (get_alg i) ->
n:size_t { B.length blocks = block_length (get_alg i) * v n } ->
ST.Stack unit
(requires (fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\
B.live h s /\ B.live h blocks /\ B.disjoint s blocks))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks)))
noextract inline_for_extraction
let prev_len_t (a: hash_alg) =
if is_keccak a then
unit
else
prev_len:len_t a { len_v a prev_len % block_length a = 0 }
noextract inline_for_extraction
let prev_len_v #a (prev_len: prev_len_t a): Spec.Hash.Incremental.Definitions.prev_length_t a
=
if is_keccak a then
()
else
len_v a prev_len
noextract inline_for_extraction
let extra_state_of_prev_length #a (x: Spec.Hash.Incremental.Definitions.prev_length_t a): Spec.Agile.Hash.extra_state a =
match a with
| Blake2B | Blake2S -> x
| _ -> ()
noextract inline_for_extraction
let update_last_st (i:impl) =
let a = get_alg i in
s:state i ->
prev_len:prev_len_t a ->
input:B.buffer uint8 {
(if is_keccak a then True else (B.length input + len_v a prev_len) `less_than_max_input_length` a) /\
B.length input <= block_length a
} ->
input_len:size_t { B.length input = v input_len } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h input /\ B.disjoint s input /\
Spec.Agile.Hash.update_multi_pre a (extra_state_of_prev_length (prev_len_v prev_len)) (B.as_seq h input)))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Hash.Incremental.update_last a (as_seq h0 s)
(prev_len_v prev_len)
(B.as_seq h0 input)))
inline_for_extraction noextract
let fixed_len_impl = i:impl { not (is_shake (dfst i)) }
noextract inline_for_extraction
let finish_st (i:fixed_len_impl) =
s:state i -> dst:hash_t (get_alg i) -> ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h dst /\ B.disjoint s dst))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst `loc_union` loc_buffer s) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Agile.Hash.finish (get_alg i) (as_seq h0 s) ())))
noextract inline_for_extraction | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_st : a: Spec.Hash.Definitions.fixed_len_alg -> Type0 | [] | Hacl.Hash.Definitions.hash_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.fixed_len_alg -> Type0 | {
"end_col": 80,
"end_line": 341,
"start_col": 2,
"start_line": 330
} |
|
Prims.Tot | val hash_word_len (a: md_alg) : n: size_t{v n = hash_word_length a} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul | val hash_word_len (a: md_alg) : n: size_t{v n = hash_word_length a}
let hash_word_len (a: md_alg) : n: size_t{v n = hash_word_length a} = | false | null | false | match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.md_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.hash_word_length"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_word_len (a: md_alg) : n: size_t{v n = hash_word_length a} | [] | Hacl.Hash.Definitions.hash_word_len | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.md_alg
-> n: Lib.IntTypes.size_t{Lib.IntTypes.v n = Spec.Hash.Definitions.hash_word_length a} | {
"end_col": 19,
"end_line": 141,
"start_col": 2,
"start_line": 135
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_st (i:impl) =
s:state i ->
ev:extra_state (get_alg i) ->
blocks:blocks_t (get_alg i) ->
n:size_t { B.length blocks = block_length (get_alg i) * v n } ->
ST.Stack unit
(requires (fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\
B.live h s /\ B.live h blocks /\ B.disjoint s blocks))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks))) | let update_multi_st (i: impl) = | false | null | false |
s: state i ->
ev: extra_state (get_alg i) ->
blocks: blocks_t (get_alg i) ->
n: size_t{B.length blocks = block_length (get_alg i) * v n}
-> ST.Stack unit
(requires
(fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\ B.live h s /\
B.live h blocks /\ B.disjoint s blocks))
(ensures
(fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks))) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Hacl.Hash.Definitions.state",
"Hacl.Hash.Definitions.extra_state",
"Hacl.Hash.Definitions.get_alg",
"Hacl.Hash.Definitions.blocks_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"LowStar.Monotonic.Buffer.length",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"FStar.Mul.op_Star",
"Spec.Hash.Definitions.block_length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Spec.Agile.Hash.update_multi_pre",
"Hacl.Hash.Definitions.ev_v",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Monotonic.Buffer.live",
"Hacl.Hash.Definitions.impl_word",
"LowStar.Monotonic.Buffer.disjoint",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.eq2",
"Spec.Hash.Definitions.words_state",
"Hacl.Hash.Definitions.as_seq",
"Spec.Agile.Hash.update_multi"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block)))
noextract inline_for_extraction
let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len))))
// Note: we cannot take more than 4GB of data because we are currently
// constrained by the size of buffers...
noextract inline_for_extraction | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_multi_st : i: Hacl.Hash.Definitions.impl -> Type0 | [] | Hacl.Hash.Definitions.update_multi_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Type0 | {
"end_col": 95,
"end_line": 272,
"start_col": 2,
"start_line": 261
} |
|
Prims.Tot | val word_len (a: md_alg) : n: size_t{v n = word_length a} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul | val word_len (a: md_alg) : n: size_t{v n = word_length a}
let word_len (a: md_alg) : n: size_t{v n = word_length a} = | false | null | false | match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.md_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.word_length"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val word_len (a: md_alg) : n: size_t{v n = word_length a} | [] | Hacl.Hash.Definitions.word_len | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.md_alg
-> n: Lib.IntTypes.size_t{Lib.IntTypes.v n = Spec.Hash.Definitions.word_length a} | {
"end_col": 30,
"end_line": 117,
"start_col": 2,
"start_line": 115
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let prev_len_t (a: hash_alg) =
if is_keccak a then
unit
else
prev_len:len_t a { len_v a prev_len % block_length a = 0 } | let prev_len_t (a: hash_alg) = | false | null | false | if is_keccak a then unit else prev_len: len_t a {len_v a prev_len % block_length a = 0} | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.is_keccak",
"Prims.unit",
"Prims.bool",
"Spec.Hash.Definitions.len_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Spec.Hash.Definitions.len_v",
"Spec.Hash.Definitions.block_length"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block)))
noextract inline_for_extraction
let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len))))
// Note: we cannot take more than 4GB of data because we are currently
// constrained by the size of buffers...
noextract inline_for_extraction
let update_multi_st (i:impl) =
s:state i ->
ev:extra_state (get_alg i) ->
blocks:blocks_t (get_alg i) ->
n:size_t { B.length blocks = block_length (get_alg i) * v n } ->
ST.Stack unit
(requires (fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\
B.live h s /\ B.live h blocks /\ B.disjoint s blocks))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks)))
noextract inline_for_extraction | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val prev_len_t : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Hacl.Hash.Definitions.prev_len_t | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 62,
"end_line": 279,
"start_col": 2,
"start_line": 276
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a | let impl_word (i: impl) = | false | null | false | [@@ inline_let ]let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> word a | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Hacl.Impl.Blake2.Core.element_t",
"Spec.Hash.Definitions.to_blake_alg",
"Hacl.Hash.Definitions.get_spec",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.get_alg"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val impl_word : i: Hacl.Hash.Definitions.impl -> Type0 | [] | Hacl.Hash.Definitions.impl_word | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Type0 | {
"end_col": 77,
"end_line": 70,
"start_col": 2,
"start_line": 64
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block))) | let update_st (i: impl{is_md (get_alg i)}) = | false | null | false | s: state i -> block: B.buffer uint8 {B.length block = block_length (get_alg i)}
-> ST.Stack unit
(requires (fun h -> B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures
(fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block))) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Prims.b2t",
"Spec.Hash.Definitions.is_md",
"Hacl.Hash.Definitions.get_alg",
"Hacl.Hash.Definitions.state",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.block_length",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Hacl.Hash.Definitions.impl_word",
"LowStar.Monotonic.Buffer.disjoint",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.eq2",
"Spec.Hash.Definitions.words_state",
"Hacl.Hash.Definitions.as_seq",
"Spec.Agile.Hash.update",
"LowStar.Monotonic.Buffer.as_seq"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_st : i: Hacl.Hash.Definitions.impl{Spec.Hash.Definitions.is_md (Hacl.Hash.Definitions.get_alg i)}
-> Type0 | [] | Hacl.Hash.Definitions.update_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl{Spec.Hash.Definitions.is_md (Hacl.Hash.Definitions.get_alg i)}
-> Type0 | {
"end_col": 78,
"end_line": 244,
"start_col": 2,
"start_line": 236
} |
|
Prims.Tot | val prev_len_v (#a: _) (prev_len: prev_len_t a) : Spec.Hash.Incremental.Definitions.prev_length_t a | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let prev_len_v #a (prev_len: prev_len_t a): Spec.Hash.Incremental.Definitions.prev_length_t a
=
if is_keccak a then
()
else
len_v a prev_len | val prev_len_v (#a: _) (prev_len: prev_len_t a) : Spec.Hash.Incremental.Definitions.prev_length_t a
let prev_len_v #a (prev_len: prev_len_t a) : Spec.Hash.Incremental.Definitions.prev_length_t a = | false | null | false | if is_keccak a then () else len_v a prev_len | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.prev_len_t",
"Spec.Hash.Definitions.is_keccak",
"Prims.bool",
"Spec.Hash.Definitions.len_v",
"Spec.Hash.Incremental.Definitions.prev_length_t"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block)))
noextract inline_for_extraction
let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len))))
// Note: we cannot take more than 4GB of data because we are currently
// constrained by the size of buffers...
noextract inline_for_extraction
let update_multi_st (i:impl) =
s:state i ->
ev:extra_state (get_alg i) ->
blocks:blocks_t (get_alg i) ->
n:size_t { B.length blocks = block_length (get_alg i) * v n } ->
ST.Stack unit
(requires (fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\
B.live h s /\ B.live h blocks /\ B.disjoint s blocks))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks)))
noextract inline_for_extraction
let prev_len_t (a: hash_alg) =
if is_keccak a then
unit
else
prev_len:len_t a { len_v a prev_len % block_length a = 0 }
noextract inline_for_extraction
let prev_len_v #a (prev_len: prev_len_t a): Spec.Hash.Incremental.Definitions.prev_length_t a | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val prev_len_v (#a: _) (prev_len: prev_len_t a) : Spec.Hash.Incremental.Definitions.prev_length_t a | [] | Hacl.Hash.Definitions.prev_len_v | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | prev_len: Hacl.Hash.Definitions.prev_len_t a -> Spec.Hash.Incremental.Definitions.prev_length_t a | {
"end_col": 20,
"end_line": 287,
"start_col": 2,
"start_line": 284
} |
Prims.GTot | val as_seq (#i: impl) (h: HS.mem) (s: state i) : GTot (words_state (get_alg i)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s | val as_seq (#i: impl) (h: HS.mem) (s: state i) : GTot (words_state (get_alg i))
let as_seq (#i: impl) (h: HS.mem) (s: state i) : GTot (words_state (get_alg i)) = | false | null | false | match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> B.as_seq h s | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"sometrivial"
] | [
"Hacl.Hash.Definitions.impl",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Hash.Definitions.state",
"Hacl.Hash.Definitions.get_alg",
"Hacl.Impl.Blake2.Core.state_v",
"Spec.Blake2.Blake2S",
"Hacl.Hash.Definitions.get_spec",
"Spec.Blake2.Blake2B",
"LowStar.Monotonic.Buffer.as_seq",
"Hacl.Hash.Definitions.impl_word",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.words_state"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_seq (#i: impl) (h: HS.mem) (s: state i) : GTot (words_state (get_alg i)) | [] | Hacl.Hash.Definitions.as_seq | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> s: Hacl.Hash.Definitions.state i
-> Prims.GTot (Spec.Hash.Definitions.words_state (Hacl.Hash.Definitions.get_alg i)) | {
"end_col": 83,
"end_line": 111,
"start_col": 2,
"start_line": 105
} |
Prims.Tot | val block_len (a: hash_alg) : n: size_t{v n = block_length a} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul | val block_len (a: hash_alg) : n: size_t{v n = block_length a}
let block_len (a: hash_alg) : n: size_t{v n = block_length a} = | false | null | false | match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 ->
assert_norm ((rate SHA3_224 / 8 / 8) * 8 = 144);
144ul
| SHA3_256 ->
assert_norm ((rate SHA3_256 / 8 / 8) * 8 = 136);
136ul
| SHA3_384 ->
assert_norm ((rate SHA3_384 / 8 / 8) * 8 = 104);
104ul
| SHA3_512 ->
assert_norm ((rate SHA3_512 / 8 / 8) * 8 = 72);
72ul
| Shake128 ->
assert_norm ((rate Shake128 / 8 / 8) * 8 = 168);
168ul
| Shake256 ->
assert_norm ((rate Shake256 / 8 / 8) * 8 = 136);
136ul
| Blake2S -> 64ul
| Blake2B -> 128ul | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"Prims.op_Division",
"Spec.Hash.Definitions.rate",
"Spec.Hash.Definitions.SHA3_224",
"Spec.Hash.Definitions.SHA3_256",
"Spec.Hash.Definitions.SHA3_384",
"Spec.Hash.Definitions.SHA3_512",
"Spec.Hash.Definitions.Shake128",
"Spec.Hash.Definitions.Shake256",
"Lib.IntTypes.size_t",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.op_disEquality",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.block_length"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val block_len (a: hash_alg) : n: size_t{v n = block_length a} | [] | Hacl.Hash.Definitions.block_len | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg
-> n: Lib.IntTypes.size_t{Lib.IntTypes.v n = Spec.Hash.Definitions.block_length a} | {
"end_col": 20,
"end_line": 131,
"start_col": 2,
"start_line": 121
} |
Prims.Tot | val impl_state_len (i: impl) : s: size_t{size_v s == impl_state_length i} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul | val impl_state_len (i: impl) : s: size_t{size_v s == impl_state_length i}
let impl_state_len (i: impl) : s: size_t{size_v s == impl_state_length i} = | false | null | false | [@@ inline_let ]let a = get_alg i in
[@@ inline_let ]let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32 | Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256 | Blake2B, Blake2.M256 -> 4ul | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"FStar.UInt32.__uint_to_t",
"Spec.Hash.Definitions.hash_alg",
"FStar.Pervasives.Native.Mktuple2",
"Hacl.Impl.Blake2.Core.m_spec",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.size_v",
"Hacl.Hash.Definitions.impl_state_length",
"Prims.unit",
"Lib.IntTypes.mul_mod_lemma",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Blake2.Core.row_len",
"Spec.Hash.Definitions.to_blake_alg",
"Hacl.Hash.Definitions.get_spec",
"Hacl.Hash.Definitions.m_spec",
"Hacl.Hash.Definitions.get_alg"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val impl_state_len (i: impl) : s: size_t{size_v s == impl_state_length i} | [] | Hacl.Hash.Definitions.impl_state_len | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl
-> s: Lib.IntTypes.size_t{Lib.IntTypes.size_v s == Hacl.Hash.Definitions.impl_state_length i} | {
"end_col": 33,
"end_line": 97,
"start_col": 2,
"start_line": 84
} |
Prims.Tot | val extra_state_of_prev_length (#a: _) (x: Spec.Hash.Incremental.Definitions.prev_length_t a)
: Spec.Agile.Hash.extra_state a | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let extra_state_of_prev_length #a (x: Spec.Hash.Incremental.Definitions.prev_length_t a): Spec.Agile.Hash.extra_state a =
match a with
| Blake2B | Blake2S -> x
| _ -> () | val extra_state_of_prev_length (#a: _) (x: Spec.Hash.Incremental.Definitions.prev_length_t a)
: Spec.Agile.Hash.extra_state a
let extra_state_of_prev_length #a (x: Spec.Hash.Incremental.Definitions.prev_length_t a)
: Spec.Agile.Hash.extra_state a = | false | null | false | match a with
| Blake2B | Blake2S -> x
| _ -> () | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Incremental.Definitions.prev_length_t",
"Spec.Hash.Definitions.extra_state"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block)))
noextract inline_for_extraction
let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len))))
// Note: we cannot take more than 4GB of data because we are currently
// constrained by the size of buffers...
noextract inline_for_extraction
let update_multi_st (i:impl) =
s:state i ->
ev:extra_state (get_alg i) ->
blocks:blocks_t (get_alg i) ->
n:size_t { B.length blocks = block_length (get_alg i) * v n } ->
ST.Stack unit
(requires (fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\
B.live h s /\ B.live h blocks /\ B.disjoint s blocks))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks)))
noextract inline_for_extraction
let prev_len_t (a: hash_alg) =
if is_keccak a then
unit
else
prev_len:len_t a { len_v a prev_len % block_length a = 0 }
noextract inline_for_extraction
let prev_len_v #a (prev_len: prev_len_t a): Spec.Hash.Incremental.Definitions.prev_length_t a
=
if is_keccak a then
()
else
len_v a prev_len
noextract inline_for_extraction | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val extra_state_of_prev_length (#a: _) (x: Spec.Hash.Incremental.Definitions.prev_length_t a)
: Spec.Agile.Hash.extra_state a | [] | Hacl.Hash.Definitions.extra_state_of_prev_length | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.Hash.Incremental.Definitions.prev_length_t a -> Spec.Hash.Definitions.extra_state a | {
"end_col": 11,
"end_line": 293,
"start_col": 2,
"start_line": 291
} |
Prims.Tot | val hash_len (a: fixed_len_alg) : n: size_t{v n = hash_length a} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul | val hash_len (a: fixed_len_alg) : n: size_t{v n = hash_length a}
let hash_len (a: fixed_len_alg) : n: size_t{v n = hash_length a} = | false | null | false | match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.fixed_len_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.hash_length"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_len (a: fixed_len_alg) : n: size_t{v n = hash_length a} | [] | Hacl.Hash.Definitions.hash_len | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.fixed_len_alg
-> n: Lib.IntTypes.size_t{Lib.IntTypes.v n = Spec.Hash.Definitions.hash_length a} | {
"end_col": 20,
"end_line": 157,
"start_col": 2,
"start_line": 145
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let finish_st (i:fixed_len_impl) =
s:state i -> dst:hash_t (get_alg i) -> ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h dst /\ B.disjoint s dst))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst `loc_union` loc_buffer s) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Agile.Hash.finish (get_alg i) (as_seq h0 s) ()))) | let finish_st (i: fixed_len_impl) = | false | null | false | s: state i -> dst: hash_t (get_alg i)
-> ST.Stack unit
(requires (fun h -> B.live h s /\ B.live h dst /\ B.disjoint s dst))
(ensures
(fun h0 _ h1 ->
M.(modifies ((loc_buffer dst) `loc_union` (loc_buffer s)) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Agile.Hash.finish (get_alg i) (as_seq h0 s) ()))) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.fixed_len_impl",
"Hacl.Hash.Definitions.state",
"Hacl.Hash.Definitions.hash_t",
"Hacl.Hash.Definitions.get_alg",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Hacl.Hash.Definitions.impl_word",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.uint8",
"LowStar.Monotonic.Buffer.disjoint",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_buffer",
"FStar.Seq.Base.equal",
"LowStar.Monotonic.Buffer.as_seq",
"Spec.Agile.Hash.finish",
"Hacl.Hash.Definitions.as_seq"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block)))
noextract inline_for_extraction
let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len))))
// Note: we cannot take more than 4GB of data because we are currently
// constrained by the size of buffers...
noextract inline_for_extraction
let update_multi_st (i:impl) =
s:state i ->
ev:extra_state (get_alg i) ->
blocks:blocks_t (get_alg i) ->
n:size_t { B.length blocks = block_length (get_alg i) * v n } ->
ST.Stack unit
(requires (fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\
B.live h s /\ B.live h blocks /\ B.disjoint s blocks))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks)))
noextract inline_for_extraction
let prev_len_t (a: hash_alg) =
if is_keccak a then
unit
else
prev_len:len_t a { len_v a prev_len % block_length a = 0 }
noextract inline_for_extraction
let prev_len_v #a (prev_len: prev_len_t a): Spec.Hash.Incremental.Definitions.prev_length_t a
=
if is_keccak a then
()
else
len_v a prev_len
noextract inline_for_extraction
let extra_state_of_prev_length #a (x: Spec.Hash.Incremental.Definitions.prev_length_t a): Spec.Agile.Hash.extra_state a =
match a with
| Blake2B | Blake2S -> x
| _ -> ()
noextract inline_for_extraction
let update_last_st (i:impl) =
let a = get_alg i in
s:state i ->
prev_len:prev_len_t a ->
input:B.buffer uint8 {
(if is_keccak a then True else (B.length input + len_v a prev_len) `less_than_max_input_length` a) /\
B.length input <= block_length a
} ->
input_len:size_t { B.length input = v input_len } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h input /\ B.disjoint s input /\
Spec.Agile.Hash.update_multi_pre a (extra_state_of_prev_length (prev_len_v prev_len)) (B.as_seq h input)))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Hash.Incremental.update_last a (as_seq h0 s)
(prev_len_v prev_len)
(B.as_seq h0 input)))
inline_for_extraction noextract
let fixed_len_impl = i:impl { not (is_shake (dfst i)) }
noextract inline_for_extraction | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finish_st : i: Hacl.Hash.Definitions.fixed_len_impl -> Type0 | [] | Hacl.Hash.Definitions.finish_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.fixed_len_impl -> Type0 | {
"end_col": 87,
"end_line": 326,
"start_col": 2,
"start_line": 321
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_last_st (i:impl) =
let a = get_alg i in
s:state i ->
prev_len:prev_len_t a ->
input:B.buffer uint8 {
(if is_keccak a then True else (B.length input + len_v a prev_len) `less_than_max_input_length` a) /\
B.length input <= block_length a
} ->
input_len:size_t { B.length input = v input_len } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h input /\ B.disjoint s input /\
Spec.Agile.Hash.update_multi_pre a (extra_state_of_prev_length (prev_len_v prev_len)) (B.as_seq h input)))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Hash.Incremental.update_last a (as_seq h0 s)
(prev_len_v prev_len)
(B.as_seq h0 input))) | let update_last_st (i: impl) = | false | null | false | let a = get_alg i in
s: state i ->
prev_len: prev_len_t a ->
input:
B.buffer uint8
{ (if is_keccak a
then True
else (B.length input + len_v a prev_len) `less_than_max_input_length` a) /\
B.length input <= block_length a } ->
input_len: size_t{B.length input = v input_len}
-> ST.Stack unit
(requires
(fun h ->
B.live h s /\ B.live h input /\ B.disjoint s input /\
Spec.Agile.Hash.update_multi_pre a
(extra_state_of_prev_length (prev_len_v prev_len))
(B.as_seq h input)))
(ensures
(fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Hash.Incremental.update_last a
(as_seq h0 s)
(prev_len_v prev_len)
(B.as_seq h0 input))) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Hacl.Hash.Definitions.impl",
"Hacl.Hash.Definitions.state",
"Hacl.Hash.Definitions.prev_len_t",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.l_and",
"Spec.Hash.Definitions.is_keccak",
"Prims.l_True",
"Prims.bool",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"Prims.op_Addition",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.len_v",
"Prims.logical",
"Prims.op_LessThanOrEqual",
"Spec.Hash.Definitions.block_length",
"Lib.IntTypes.size_t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.live",
"Hacl.Hash.Definitions.impl_word",
"LowStar.Monotonic.Buffer.disjoint",
"Spec.Agile.Hash.update_multi_pre",
"Hacl.Hash.Definitions.extra_state_of_prev_length",
"Hacl.Hash.Definitions.prev_len_v",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.eq2",
"Lib.Sequence.seq",
"Spec.Hash.Definitions.word",
"Hacl.Hash.Definitions.get_alg",
"Prims.nat",
"FStar.Seq.Base.length",
"Spec.Hash.Definitions.state_word_length",
"Hacl.Hash.Definitions.as_seq",
"Spec.Hash.Incremental.Definitions.update_last",
"Spec.Hash.Definitions.hash_alg"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64
inline_for_extraction noextract
let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
noextract inline_for_extraction
let blocks_t (a: hash_alg) =
b:B.buffer uint8 { B.length b % block_length a = 0 }
let hash_t (a: fixed_len_alg) = b:B.buffer uint8 { B.length b = hash_length a }
(** The types of all stateful operations for a hash algorithm. *)
noextract inline_for_extraction
let alloca_st (i:impl) = unit -> ST.StackInline (state i)
(requires (fun h ->
HS.is_stack_region (HS.get_tip h)))
(ensures (fun h0 s h1 ->
M.(modifies M.loc_none h0 h1) /\
B.frameOf s == HS.get_tip h0 /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i) /\
B.live h1 s /\
B.fresh_loc (M.loc_buffer s) h0 h1))
noextract inline_for_extraction
let malloc_st (i:impl) = r:HS.rid -> ST.ST (state i)
(requires (fun h ->
ST.is_eternal_region r))
(ensures (fun h0 s h1 ->
B.live h1 s /\
M.(modifies M.loc_none h0 h1) /\
B.fresh_loc (M.loc_addr_of_buffer s) h0 h1 /\
M.(loc_includes (loc_region_only true r) (loc_addr_of_buffer s)) /\
B.freeable s))
noextract inline_for_extraction
let init_st (i:impl) = s:state i -> ST.Stack unit
(requires (fun h ->
B.live h s))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s == Spec.Agile.Hash.init (get_alg i)))
noextract inline_for_extraction
let update_st (i:impl{is_md (get_alg i)}) =
s:state i ->
block:B.buffer uint8 { B.length block = block_length (get_alg i) } ->
ST.Stack unit
(requires (fun h ->
B.live h s /\ B.live h block /\ B.disjoint s block))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update (get_alg i) (as_seq h0 s) (B.as_seq h0 block)))
noextract inline_for_extraction
let pad_st (a: md_alg) = len:len_t a -> dst:B.buffer uint8 ->
ST.Stack unit
(requires (fun h ->
len_v a len `less_than_max_input_length` a /\
B.live h dst /\
B.length dst = pad_length a (len_v a len)))
(ensures (fun h0 _ h1 ->
M.(modifies (loc_buffer dst) h0 h1) /\
Seq.equal (B.as_seq h1 dst) (Spec.Hash.MD.pad a (len_v a len))))
// Note: we cannot take more than 4GB of data because we are currently
// constrained by the size of buffers...
noextract inline_for_extraction
let update_multi_st (i:impl) =
s:state i ->
ev:extra_state (get_alg i) ->
blocks:blocks_t (get_alg i) ->
n:size_t { B.length blocks = block_length (get_alg i) * v n } ->
ST.Stack unit
(requires (fun h ->
Spec.Agile.Hash.update_multi_pre (get_alg i) (ev_v ev) (B.as_seq h blocks) /\
B.live h s /\ B.live h blocks /\ B.disjoint s blocks))
(ensures (fun h0 _ h1 ->
B.(modifies (loc_buffer s) h0 h1) /\
as_seq h1 s ==
Spec.Agile.Hash.update_multi (get_alg i) (as_seq h0 s) (ev_v ev) (B.as_seq h0 blocks)))
noextract inline_for_extraction
let prev_len_t (a: hash_alg) =
if is_keccak a then
unit
else
prev_len:len_t a { len_v a prev_len % block_length a = 0 }
noextract inline_for_extraction
let prev_len_v #a (prev_len: prev_len_t a): Spec.Hash.Incremental.Definitions.prev_length_t a
=
if is_keccak a then
()
else
len_v a prev_len
noextract inline_for_extraction
let extra_state_of_prev_length #a (x: Spec.Hash.Incremental.Definitions.prev_length_t a): Spec.Agile.Hash.extra_state a =
match a with
| Blake2B | Blake2S -> x
| _ -> () | false | true | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_last_st : i: Hacl.Hash.Definitions.impl -> Type0 | [] | Hacl.Hash.Definitions.update_last_st | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Hacl.Hash.Definitions.impl -> Type0 | {
"end_col": 63,
"end_line": 314,
"start_col": 29,
"start_line": 296
} |
|
Prims.Tot | val max_input_len64 (a: _) : U64.(x: t{0 < v x /\ (v x) `less_than_max_input_length` a}) | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max_input_len64 a: U64.(x:t { 0 < v x /\ v x `less_than_max_input_length` a }) =
let _ = allow_inversion hash_alg in
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384 | SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 ->
// TODO: relax this?
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1)) | val max_input_len64 (a: _) : U64.(x: t{0 < v x /\ (v x) `less_than_max_input_length` a})
let max_input_len64 a : U64.(x: t{0 < v x /\ (v x) `less_than_max_input_length` a}) = | false | null | false | let _ = allow_inversion hash_alg in
match a with
| MD5
| SHA1
| SHA2_224
| SHA2_256 ->
assert_norm (0 < pow2 61 - 1 && pow2 61 < pow2 64);
normalize_term_spec (pow2 61 - 1);
U64.uint_to_t (normalize_term (pow2 61 - 1))
| SHA2_384
| SHA2_512 ->
assert_norm (pow2 64 < pow2 125 - 1);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2S ->
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| Blake2B ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1))
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 ->
assert_norm (pow2 64 < pow2 128);
normalize_term_spec (pow2 64 - 1);
U64.uint_to_t (normalize_term (pow2 64 - 1)) | {
"checked_file": "Hacl.Hash.Definitions.fst.checked",
"dependencies": [
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Hash.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"FStar.UInt64.uint_to_t",
"FStar.Pervasives.normalize_term",
"FStar.UInt.uint_t",
"FStar.UInt64.n",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.unit",
"FStar.Pervasives.normalize_term_spec",
"Prims.int",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"FStar.UInt64.t",
"Prims.l_and",
"FStar.UInt64.v",
"Spec.Hash.Definitions.less_than_max_input_length",
"FStar.Pervasives.allow_inversion"
] | [] | module Hacl.Hash.Definitions
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module M = LowStar.Modifies
module B = LowStar.Buffer
module Blake2 = Hacl.Impl.Blake2.Core
open Lib.IntTypes
open Spec.Hash.Definitions
open FStar.Mul
#set-options "--z3rlimit 25 --fuel 0 --ifuel 1"
(** The low-level types that our clients need to be aware of, in order to
successfully call this module. *)
inline_for_extraction noextract
let m_spec (a:hash_alg) : Type0 =
match a with
| Blake2S | Blake2B -> Blake2.m_spec
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let extra_state (a:hash_alg) : Type0 =
match a with
| Blake2S -> s:uint_t U64 PUB{ v s % block_length a = 0 }
| Blake2B -> s:uint_t U128 PUB{ v s % block_length a = 0 }
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> unit
inline_for_extraction noextract
let ev_v (#a:hash_alg) (ev:extra_state a) : Spec.Hash.Definitions.extra_state a =
match a with
| Blake2S -> v #U64 #PUB ev
| Blake2B -> v #U128 #PUB ev
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction
type impl = a:hash_alg & m_spec a
inline_for_extraction noextract
let mk_impl (a:hash_alg) (m:m_spec a) : impl = (|a, m|)
inline_for_extraction noextract
let get_alg (i:impl) : hash_alg =
match i with (|a, m|) -> a
inline_for_extraction noextract
let get_spec (i:impl) : m_spec (get_alg i) =
match i with (|a, m|) -> m
inline_for_extraction noextract
let impl_word (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> Blake2.element_t (to_blake_alg a) (get_spec i)
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> word a
inline_for_extraction noextract
let impl_state_length (i:impl) =
[@inline_let] let a = get_alg i in
match a with
| Blake2S | Blake2B -> UInt32.v (4ul *. Blake2.row_len (to_blake_alg a) (get_spec i))
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> state_word_length a
inline_for_extraction noextract
let impl_state_len (i:impl) : s:size_t{size_v s == impl_state_length i} =
[@inline_let] let a = get_alg i in
[@inline_let] let m = get_spec i in
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 | SHA2_256 | SHA2_384 | SHA2_512 -> 8ul
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> 25ul
| _ ->
(**) mul_mod_lemma 4ul (Blake2.row_len (to_blake_alg a) (get_spec i));
match a, m with
| Blake2S, Blake2.M32
| Blake2B, Blake2.M32 | Blake2B, Blake2.M128 -> 16ul
| Blake2S, Blake2.M128 | Blake2S, Blake2.M256
| Blake2B, Blake2.M256 -> 4ul
inline_for_extraction noextract
type state (i:impl) =
b:B.buffer (impl_word i) { B.length b = impl_state_length i }
inline_for_extraction noextract
let as_seq (#i:impl) (h:HS.mem) (s:state i) : GTot (words_state (get_alg i)) =
match get_alg i with
| Blake2S -> Blake2.state_v #Spec.Blake2.Blake2S #(get_spec i) h s
| Blake2B -> Blake2.state_v #Spec.Blake2.Blake2B #(get_spec i) h s
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> B.as_seq h s
inline_for_extraction
let word_len (a: md_alg) : n:size_t { v n = word_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 4ul
| SHA2_384 | SHA2_512 -> 8ul
inline_for_extraction
let block_len (a: hash_alg): n:size_t { v n = block_length a } =
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 -> 64ul
| SHA2_384 | SHA2_512 -> 128ul
| SHA3_224 -> assert_norm (rate SHA3_224/8/8*8 = 144); 144ul
| SHA3_256 -> assert_norm (rate SHA3_256/8/8*8 = 136); 136ul
| SHA3_384 -> assert_norm (rate SHA3_384/8/8*8 = 104); 104ul
| SHA3_512 -> assert_norm (rate SHA3_512/8/8*8 = 72); 72ul
| Shake128 -> assert_norm (rate Shake128/8/8*8 = 168); 168ul
| Shake256 -> assert_norm (rate Shake256/8/8*8 = 136); 136ul
| Blake2S -> 64ul
| Blake2B -> 128ul
inline_for_extraction
let hash_word_len (a: md_alg): n:size_t { v n = hash_word_length a } =
match a with
| MD5 -> 4ul
| SHA1 -> 5ul
| SHA2_224 -> 7ul
| SHA2_256 -> 8ul
| SHA2_384 -> 6ul
| SHA2_512 -> 8ul
inline_for_extraction
let hash_len (a: fixed_len_alg): n:size_t { v n = hash_length a } =
match a with
| MD5 -> 16ul
| SHA1 -> 20ul
| SHA2_224 -> 28ul
| SHA2_256 -> 32ul
| SHA2_384 -> 48ul
| SHA2_512 -> 64ul
| Blake2S -> 32ul
| Blake2B -> 64ul
| SHA3_224 -> 28ul
| SHA3_256 -> 32ul
| SHA3_384 -> 48ul
| SHA3_512 -> 64ul
/// Maximum input length, but fitting on a 64-bit integer (since the streaming
/// module doesn't bother taking into account lengths that are greater than
/// that). The comment previously was:
///
/// Note that we keep the total length at run-time, on 64 bits, but require that
/// it abides by the size requirements for the smaller hashes -- we're not
/// interested at this stage in having an agile type for lengths that would be
/// up to 2^125 for SHA384/512.
module U64 = FStar.UInt64 | false | false | Hacl.Hash.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val max_input_len64 (a: _) : U64.(x: t{0 < v x /\ (v x) `less_than_max_input_length` a}) | [] | Hacl.Hash.Definitions.max_input_len64 | {
"file_name": "code/hash/Hacl.Hash.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg
-> x:
FStar.UInt64.t
{ 0 < FStar.UInt64.v x /\
Spec.Hash.Definitions.less_than_max_input_length (FStar.UInt64.v x) a } | {
"end_col": 50,
"end_line": 194,
"start_col": 84,
"start_line": 171
} |
FStar.Pervasives.Lemma | val relate_modifies (args:list arg) (m0 m1:ME.vale_full_heap)
: Lemma
(requires
ME.modifies (VSig.mloc_modified_args args) (ME.get_vale_heap m0) (ME.get_vale_heap m1))
(ensures
B.modifies (loc_modified_args args)
(hs_of_mem (as_mem m0.vf_heap))
(hs_of_mem (as_mem m1.vf_heap))) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let relate_modifies args m0 m1 = loc_eq args | val relate_modifies (args:list arg) (m0 m1:ME.vale_full_heap)
: Lemma
(requires
ME.modifies (VSig.mloc_modified_args args) (ME.get_vale_heap m0) (ME.get_vale_heap m1))
(ensures
B.modifies (loc_modified_args args)
(hs_of_mem (as_mem m0.vf_heap))
(hs_of_mem (as_mem m1.vf_heap)))
let relate_modifies args m0 m1 = | false | null | true | loc_eq args | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Prims.list",
"Vale.Interop.Base.arg",
"Vale.X64.Memory.vale_full_heap",
"Vale.AsLowStar.MemoryHelpers.loc_eq",
"Prims.unit"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl | false | false | Vale.AsLowStar.MemoryHelpers.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 relate_modifies (args:list arg) (m0 m1:ME.vale_full_heap)
: Lemma
(requires
ME.modifies (VSig.mloc_modified_args args) (ME.get_vale_heap m0) (ME.get_vale_heap m1))
(ensures
B.modifies (loc_modified_args args)
(hs_of_mem (as_mem m0.vf_heap))
(hs_of_mem (as_mem m1.vf_heap))) | [] | Vale.AsLowStar.MemoryHelpers.relate_modifies | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
args: Prims.list Vale.Interop.Base.arg ->
m0: Vale.X64.Memory.vale_full_heap ->
m1: Vale.X64.Memory.vale_full_heap
-> FStar.Pervasives.Lemma
(requires
Vale.X64.Memory.modifies (Vale.AsLowStar.ValeSig.mloc_modified_args args)
(Vale.X64.Memory.get_vale_heap m0)
(Vale.X64.Memory.get_vale_heap m1))
(ensures
LowStar.Monotonic.Buffer.modifies (Vale.Interop.Base.loc_modified_args args)
(Vale.Interop.Heap_s.hs_of_mem (Vale.X64.MemoryAdapters.as_mem (Mkvale_full_heap?.vf_heap m0
)))
(Vale.Interop.Heap_s.hs_of_mem (Vale.X64.MemoryAdapters.as_mem (Mkvale_full_heap?.vf_heap m1
)))) | {
"end_col": 44,
"end_line": 39,
"start_col": 33,
"start_line": 39
} |
FStar.Pervasives.Lemma | val lemma_as_mem_as_vale_mem (h:interop_heap) : Lemma
(ensures as_mem (create_initial_vale_heap h) == h)
[SMTPat (as_mem (create_initial_vale_heap h))] | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_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_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | val lemma_as_mem_as_vale_mem (h:interop_heap) : Lemma
(ensures as_mem (create_initial_vale_heap h) == h)
[SMTPat (as_mem (create_initial_vale_heap h))]
let lemma_as_mem_as_vale_mem h = | false | null | true | FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Interop.Heap_s.interop_heap",
"FStar.Pervasives.reveal_opaque",
"Vale.X64.Memory.vale_full_heap",
"Vale.X64.Memory.vale_heap",
"Vale.X64.Memory.get_vale_heap",
"Prims.unit"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | false | false | Vale.AsLowStar.MemoryHelpers.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_as_mem_as_vale_mem (h:interop_heap) : Lemma
(ensures as_mem (create_initial_vale_heap h) == h)
[SMTPat (as_mem (create_initial_vale_heap h))] | [] | Vale.AsLowStar.MemoryHelpers.lemma_as_mem_as_vale_mem | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: Vale.Interop.Heap_s.interop_heap
-> FStar.Pervasives.Lemma
(ensures
Vale.X64.MemoryAdapters.as_mem (Vale.X64.MemoryAdapters.create_initial_vale_heap h) == h)
[SMTPat (Vale.X64.MemoryAdapters.as_mem (Vale.X64.MemoryAdapters.create_initial_vale_heap h))] | {
"end_col": 101,
"end_line": 46,
"start_col": 33,
"start_line": 46
} |
FStar.Pervasives.Lemma | val lemma_valid_layout_buffer_id (t:base_typ) (b:ME.buffer t) (layout:vale_heap_layout) (write:bool) : Lemma
(requires True)
(ensures ME.valid_layout_buffer_id t b layout None write)
[SMTPat (ME.valid_layout_buffer_id t b layout None write)] | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_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_valid_layout_buffer_id t b layout write =
reveal_opaque (`%ME.valid_layout_buffer_id) ME.valid_layout_buffer_id | val lemma_valid_layout_buffer_id (t:base_typ) (b:ME.buffer t) (layout:vale_heap_layout) (write:bool) : Lemma
(requires True)
(ensures ME.valid_layout_buffer_id t b layout None write)
[SMTPat (ME.valid_layout_buffer_id t b layout None write)]
let lemma_valid_layout_buffer_id t b layout write = | false | null | true | reveal_opaque (`%ME.valid_layout_buffer_id) ME.valid_layout_buffer_id | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.X64.Memory.buffer",
"Vale.Arch.HeapImpl.vale_heap_layout",
"Prims.bool",
"FStar.Pervasives.reveal_opaque",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.heaplet_id",
"Vale.Def.Prop_s.prop0",
"Vale.X64.Memory.valid_layout_buffer_id",
"Prims.unit"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = ()
let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let buffer_as_seq_reveal2 src t x va_s = ()
let immbuffer_as_seq_reveal2 src t x va_s = ()
let buffer_addr_reveal src t x args h0 = ()
let immbuffer_addr_reveal src t x args h0 = ()
let fuel_eq = ()
let decls_eval_code_reveal c va_s0 va_s1 f = ()
let as_vale_buffer_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_buffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_immbuffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let modifies_same_roots s h0 h1 = ()
let modifies_equal_domains s h0 h1 = ()
let loc_disjoint_sym x y = ()
#set-options "--z3rlimit 20"
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
=
FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
// assert (mem == mk_mem args h0);
let raw_taint = IX64.(mk_taint args IX64.init_taint) in
// assert (taint_map == create_memtaint (_ih mem) (args_b8 args) raw_taint);
ME.valid_memtaint mem (args_b8 args) raw_taint;
// assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a:arg). List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x. List.memP x args /\ Some? (IX64.taint_of_arg x) ==>
LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args
let buffer_writeable_reveal src t x = ()
let buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let imm_buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let buffer_as_seq_invert src t h s b =
let db = get_downview b in
DV.length_eq db;
assert (Seq.equal
(ME.buffer_as_seq s (as_vale_buffer b))
(LSig.uint_to_nat_seq_t t (UV.as_seq h (UV.mk_buffer db (LSig.view_of_base_typ t)))))
let buffer_as_seq_reveal_tuint128 src x va_s = ()
let immbuffer_as_seq_reveal_tuint128 src x va_s = ()
let bounded_buffer_addrs_one src t h b s = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let bounded_buffer_addrs_all src t h b = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let same_down_up_buffer_length src b =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_div (B.length b) (view_n src)
let down_up_buffer_read_reveal src h s b i =
let db = get_downview b in
let n:pos = view_n src in
let up_view = (LSig.view_of_base_typ src) in
let ub = UV.mk_buffer db up_view in
same_down_up_buffer_length src b;
UV.length_eq ub;
UV.get_sel h ub i;
FStar.Math.Lemmas.lemma_mult_lt_right n i (DV.length db / n);
FStar.Math.Lemmas.multiply_fractions (DV.length db) n;
FStar.Math.Lemmas.nat_times_nat_is_nat i n;
assert (low_buffer_read src src h b i ==
UV.View?.get up_view (Seq.slice (DV.as_seq h db) (i*n) (i*n + n)));
DV.put_sel h db (i*n);
let aux () : Lemma (n * ((i*n)/n) == i*n) =
FStar.Math.Lemmas.cancel_mul_div i n
in aux()
let same_buffer_same_upviews #src #bt b h0 h1 =
let dv = get_downview b in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i:nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1;
DV.length_eq dv;
Vale.Lib.BufferViewHelpers.lemma_uv_equal (LSig.view_of_base_typ bt) dv h0 h1
let same_immbuffer_same_upviews #src #bt b h0 h1 =
let dv = get_downview b in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i:nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1;
DV.length_eq dv;
Vale.Lib.BufferViewHelpers.lemma_uv_equal (LSig.view_of_base_typ bt) dv h0 h1 | false | false | Vale.AsLowStar.MemoryHelpers.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_valid_layout_buffer_id (t:base_typ) (b:ME.buffer t) (layout:vale_heap_layout) (write:bool) : Lemma
(requires True)
(ensures ME.valid_layout_buffer_id t b layout None write)
[SMTPat (ME.valid_layout_buffer_id t b layout None write)] | [] | Vale.AsLowStar.MemoryHelpers.lemma_valid_layout_buffer_id | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
b: Vale.X64.Memory.buffer t ->
layout: Vale.Arch.HeapImpl.vale_heap_layout ->
write: Prims.bool
-> FStar.Pervasives.Lemma
(ensures Vale.X64.Memory.valid_layout_buffer_id t b layout FStar.Pervasives.Native.None write)
[
SMTPat (Vale.X64.Memory.valid_layout_buffer_id t b layout FStar.Pervasives.Native.None write
)
] | {
"end_col": 71,
"end_line": 173,
"start_col": 2,
"start_line": 173
} |
FStar.Pervasives.Lemma | val bounded_buffer_addrs_all (src t:base_typ) (m:HS.mem) (b:buf_t src t{B.live m b}) : Lemma
(forall (h:ME.vale_heap) (vb:ME.buffer t).{:pattern ME.buffer_addr #t vb h}
vb == as_vale_buffer b ==>
ME.buffer_addr #t vb h + DV.length (get_downview b) < Vale.Def.Words_s.pow2_64) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bounded_buffer_addrs_all src t h b = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred | val bounded_buffer_addrs_all (src t:base_typ) (m:HS.mem) (b:buf_t src t{B.live m b}) : Lemma
(forall (h:ME.vale_heap) (vb:ME.buffer t).{:pattern ME.buffer_addr #t vb h}
vb == as_vale_buffer b ==>
ME.buffer_addr #t vb h + DV.length (get_downview b) < Vale.Def.Words_s.pow2_64)
let bounded_buffer_addrs_all src t h b = | false | null | true | FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.buf_t",
"LowStar.Monotonic.Buffer.live",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.Buffer.trivial_preorder",
"FStar.Pervasives.reveal_opaque",
"Vale.Interop.Types.b8",
"Vale.Def.Words_s.nat64",
"Prims.logical",
"Vale.Interop.Types.addr_map_pred",
"Prims.unit"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = ()
let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let buffer_as_seq_reveal2 src t x va_s = ()
let immbuffer_as_seq_reveal2 src t x va_s = ()
let buffer_addr_reveal src t x args h0 = ()
let immbuffer_addr_reveal src t x args h0 = ()
let fuel_eq = ()
let decls_eval_code_reveal c va_s0 va_s1 f = ()
let as_vale_buffer_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_buffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_immbuffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let modifies_same_roots s h0 h1 = ()
let modifies_equal_domains s h0 h1 = ()
let loc_disjoint_sym x y = ()
#set-options "--z3rlimit 20"
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
=
FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
// assert (mem == mk_mem args h0);
let raw_taint = IX64.(mk_taint args IX64.init_taint) in
// assert (taint_map == create_memtaint (_ih mem) (args_b8 args) raw_taint);
ME.valid_memtaint mem (args_b8 args) raw_taint;
// assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a:arg). List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x. List.memP x args /\ Some? (IX64.taint_of_arg x) ==>
LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args
let buffer_writeable_reveal src t x = ()
let buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let imm_buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let buffer_as_seq_invert src t h s b =
let db = get_downview b in
DV.length_eq db;
assert (Seq.equal
(ME.buffer_as_seq s (as_vale_buffer b))
(LSig.uint_to_nat_seq_t t (UV.as_seq h (UV.mk_buffer db (LSig.view_of_base_typ t)))))
let buffer_as_seq_reveal_tuint128 src x va_s = ()
let immbuffer_as_seq_reveal_tuint128 src x va_s = ()
let bounded_buffer_addrs_one src t h b s = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred | false | false | Vale.AsLowStar.MemoryHelpers.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bounded_buffer_addrs_all (src t:base_typ) (m:HS.mem) (b:buf_t src t{B.live m b}) : Lemma
(forall (h:ME.vale_heap) (vb:ME.buffer t).{:pattern ME.buffer_addr #t vb h}
vb == as_vale_buffer b ==>
ME.buffer_addr #t vb h + DV.length (get_downview b) < Vale.Def.Words_s.pow2_64) | [] | Vale.AsLowStar.MemoryHelpers.bounded_buffer_addrs_all | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src: Vale.Arch.HeapTypes_s.base_typ ->
t: Vale.Arch.HeapTypes_s.base_typ ->
m: FStar.Monotonic.HyperStack.mem ->
b: Vale.Interop.Base.buf_t src t {LowStar.Monotonic.Buffer.live m b}
-> FStar.Pervasives.Lemma
(ensures
forall (h: Vale.X64.Memory.vale_heap) (vb: Vale.X64.Memory.buffer t).
{:pattern Vale.X64.Memory.buffer_addr vb h}
vb == Vale.X64.MemoryAdapters.as_vale_buffer b ==>
Vale.X64.Memory.buffer_addr vb h +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b) <
Vale.Def.Words_s.pow2_64) | {
"end_col": 103,
"end_line": 119,
"start_col": 41,
"start_line": 119
} |
FStar.Pervasives.Lemma | val bounded_buffer_addrs_one (src t:base_typ) (h:HS.mem) (b:buf_t src t{B.live h b}) (s:ME.vale_heap) : Lemma
(ME.buffer_addr #t (as_vale_buffer b) s + DV.length (get_downview b) < Vale.Def.Words_s.pow2_64) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bounded_buffer_addrs_one src t h b s = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred | val bounded_buffer_addrs_one (src t:base_typ) (h:HS.mem) (b:buf_t src t{B.live h b}) (s:ME.vale_heap) : Lemma
(ME.buffer_addr #t (as_vale_buffer b) s + DV.length (get_downview b) < Vale.Def.Words_s.pow2_64)
let bounded_buffer_addrs_one src t h b s = | false | null | true | FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.buf_t",
"LowStar.Monotonic.Buffer.live",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.Buffer.trivial_preorder",
"Vale.X64.Memory.vale_heap",
"FStar.Pervasives.reveal_opaque",
"Vale.Interop.Types.b8",
"Vale.Def.Words_s.nat64",
"Prims.logical",
"Vale.Interop.Types.addr_map_pred",
"Prims.unit"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = ()
let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let buffer_as_seq_reveal2 src t x va_s = ()
let immbuffer_as_seq_reveal2 src t x va_s = ()
let buffer_addr_reveal src t x args h0 = ()
let immbuffer_addr_reveal src t x args h0 = ()
let fuel_eq = ()
let decls_eval_code_reveal c va_s0 va_s1 f = ()
let as_vale_buffer_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_buffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_immbuffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let modifies_same_roots s h0 h1 = ()
let modifies_equal_domains s h0 h1 = ()
let loc_disjoint_sym x y = ()
#set-options "--z3rlimit 20"
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
=
FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
// assert (mem == mk_mem args h0);
let raw_taint = IX64.(mk_taint args IX64.init_taint) in
// assert (taint_map == create_memtaint (_ih mem) (args_b8 args) raw_taint);
ME.valid_memtaint mem (args_b8 args) raw_taint;
// assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a:arg). List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x. List.memP x args /\ Some? (IX64.taint_of_arg x) ==>
LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args
let buffer_writeable_reveal src t x = ()
let buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let imm_buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let buffer_as_seq_invert src t h s b =
let db = get_downview b in
DV.length_eq db;
assert (Seq.equal
(ME.buffer_as_seq s (as_vale_buffer b))
(LSig.uint_to_nat_seq_t t (UV.as_seq h (UV.mk_buffer db (LSig.view_of_base_typ t)))))
let buffer_as_seq_reveal_tuint128 src x va_s = ()
let immbuffer_as_seq_reveal_tuint128 src x va_s = () | false | false | Vale.AsLowStar.MemoryHelpers.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bounded_buffer_addrs_one (src t:base_typ) (h:HS.mem) (b:buf_t src t{B.live h b}) (s:ME.vale_heap) : Lemma
(ME.buffer_addr #t (as_vale_buffer b) s + DV.length (get_downview b) < Vale.Def.Words_s.pow2_64) | [] | Vale.AsLowStar.MemoryHelpers.bounded_buffer_addrs_one | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src: Vale.Arch.HeapTypes_s.base_typ ->
t: Vale.Arch.HeapTypes_s.base_typ ->
h: FStar.Monotonic.HyperStack.mem ->
b: Vale.Interop.Base.buf_t src t {LowStar.Monotonic.Buffer.live h b} ->
s: Vale.X64.Memory.vale_heap
-> FStar.Pervasives.Lemma
(ensures
Vale.X64.Memory.buffer_addr (Vale.X64.MemoryAdapters.as_vale_buffer b) s +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b) <
Vale.Def.Words_s.pow2_64) | {
"end_col": 105,
"end_line": 117,
"start_col": 43,
"start_line": 117
} |
FStar.Pervasives.Lemma | val buffer_readable_reveal
(#max_arity:nat)
(src bt:base_typ)
(x:buf_t src bt)
(args:IX64.arity_ok max_arity arg)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma (
let mem = mk_mem args h0 in
ME.buffer_readable (create_initial_vale_heap mem) (as_vale_buffer x) <==>
List.memP (mut_to_b8 src x) (ptrs_of_mem mem)) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | val buffer_readable_reveal
(#max_arity:nat)
(src bt:base_typ)
(x:buf_t src bt)
(args:IX64.arity_ok max_arity arg)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma (
let mem = mk_mem args h0 in
ME.buffer_readable (create_initial_vale_heap mem) (as_vale_buffer x) <==>
List.memP (mut_to_b8 src x) (ptrs_of_mem mem))
let buffer_readable_reveal #max_arity src bt x args h0 = | false | null | true | FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buf_t",
"Vale.Interop.X64.arity_ok",
"Vale.Interop.Base.arg",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"FStar.Pervasives.reveal_opaque",
"Vale.X64.Memory.vale_full_heap",
"Vale.X64.Memory.vale_heap",
"Vale.X64.Memory.get_vale_heap",
"Prims.unit"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = () | false | false | Vale.AsLowStar.MemoryHelpers.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 buffer_readable_reveal
(#max_arity:nat)
(src bt:base_typ)
(x:buf_t src bt)
(args:IX64.arity_ok max_arity arg)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma (
let mem = mk_mem args h0 in
ME.buffer_readable (create_initial_vale_heap mem) (as_vale_buffer x) <==>
List.memP (mut_to_b8 src x) (ptrs_of_mem mem)) | [] | Vale.AsLowStar.MemoryHelpers.buffer_readable_reveal | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src: Vale.Arch.HeapTypes_s.base_typ ->
bt: Vale.Arch.HeapTypes_s.base_typ ->
x: Vale.Interop.Base.buf_t src bt ->
args: Vale.Interop.X64.arity_ok max_arity Vale.Interop.Base.arg ->
h0: FStar.Monotonic.HyperStack.mem{Vale.Interop.Base.mem_roots_p h0 args}
-> FStar.Pervasives.Lemma
(ensures
(let mem = Vale.Interop.Base.mk_mem args h0 in
Vale.X64.Memory.buffer_readable (Vale.X64.MemoryAdapters.create_initial_vale_heap mem)
(Vale.X64.MemoryAdapters.as_vale_buffer x) <==>
FStar.List.Tot.Base.memP (Vale.Interop.Base.mut_to_b8 src x)
(Vale.Interop.Heap_s.ptrs_of_mem mem))) | {
"end_col": 125,
"end_line": 44,
"start_col": 57,
"start_line": 44
} |
FStar.Pervasives.Lemma | val as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
: Lemma (V.buffer_length (as_vale_immbuffer x) == (B.length x * view_n src) / view_n t)
[SMTPat (V.buffer_length (as_vale_immbuffer x))] | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t)) | val as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
: Lemma (V.buffer_length (as_vale_immbuffer x) == (B.length x * view_n src) / view_n t)
[SMTPat (V.buffer_length (as_vale_immbuffer x))]
let as_vale_immbuffer_len (#src #t: base_typ) (x: ibuf_t src t) = | false | null | true | let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t)) | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.ibuf_t",
"LowStar.BufferView.Up.length_eq",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.BufferView.Up.mk_buffer",
"FStar.UInt8.t",
"Vale.X64.Memory.uint_view",
"Prims.unit",
"LowStar.BufferView.Down.length_eq",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"LowStar.ImmutableBuffer.immutable_preorder"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t)) | false | false | Vale.AsLowStar.MemoryHelpers.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 as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
: Lemma (V.buffer_length (as_vale_immbuffer x) == (B.length x * view_n src) / view_n t)
[SMTPat (V.buffer_length (as_vale_immbuffer x))] | [] | Vale.AsLowStar.MemoryHelpers.as_vale_immbuffer_len | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Vale.Interop.Base.ibuf_t src t
-> FStar.Pervasives.Lemma
(ensures
Vale.X64.Decls.buffer_length (Vale.X64.MemoryAdapters.as_vale_immbuffer x) ==
LowStar.Monotonic.Buffer.length x * Vale.Interop.Types.view_n src /
Vale.Interop.Types.view_n t)
[SMTPat (Vale.X64.Decls.buffer_length (Vale.X64.MemoryAdapters.as_vale_immbuffer x))] | {
"end_col": 50,
"end_line": 29,
"start_col": 4,
"start_line": 27
} |
FStar.Pervasives.Lemma | val as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
: Lemma (V.buffer_length (as_vale_buffer x) == (B.length x * view_n src) / view_n t)
[SMTPat (V.buffer_length (as_vale_buffer x))] | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t)) | val as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
: Lemma (V.buffer_length (as_vale_buffer x) == (B.length x * view_n src) / view_n t)
[SMTPat (V.buffer_length (as_vale_buffer x))]
let as_vale_buffer_len (#src #t: base_typ) (x: buf_t src t) = | false | null | true | let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t)) | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buf_t",
"LowStar.BufferView.Up.length_eq",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.BufferView.Up.mk_buffer",
"FStar.UInt8.t",
"Vale.X64.Memory.uint_view",
"Prims.unit",
"LowStar.BufferView.Down.length_eq",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"LowStar.Buffer.trivial_preorder"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters | false | false | Vale.AsLowStar.MemoryHelpers.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 as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
: Lemma (V.buffer_length (as_vale_buffer x) == (B.length x * view_n src) / view_n t)
[SMTPat (V.buffer_length (as_vale_buffer x))] | [] | Vale.AsLowStar.MemoryHelpers.as_vale_buffer_len | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Vale.Interop.Base.buf_t src t
-> FStar.Pervasives.Lemma
(ensures
Vale.X64.Decls.buffer_length (Vale.X64.MemoryAdapters.as_vale_buffer x) ==
LowStar.Monotonic.Buffer.length x * Vale.Interop.Types.view_n src /
Vale.Interop.Types.view_n t)
[SMTPat (Vale.X64.Decls.buffer_length (Vale.X64.MemoryAdapters.as_vale_buffer x))] | {
"end_col": 50,
"end_line": 24,
"start_col": 4,
"start_line": 22
} |
FStar.Pervasives.Lemma | val same_down_up_buffer_length (src:base_typ) (b:buf_t src src) : Lemma
(B.length b == DV.length (get_downview b) / view_n src) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_down_up_buffer_length src b =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_div (B.length b) (view_n src) | val same_down_up_buffer_length (src:base_typ) (b:buf_t src src) : Lemma
(B.length b == DV.length (get_downview b) / view_n src)
let same_down_up_buffer_length src b = | false | null | true | let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_div (B.length b) (view_n src) | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buf_t",
"FStar.Math.Lemmas.cancel_mul_div",
"LowStar.Monotonic.Buffer.length",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.Buffer.trivial_preorder",
"Vale.Interop.Types.view_n",
"Prims.unit",
"LowStar.BufferView.Down.length_eq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = ()
let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let buffer_as_seq_reveal2 src t x va_s = ()
let immbuffer_as_seq_reveal2 src t x va_s = ()
let buffer_addr_reveal src t x args h0 = ()
let immbuffer_addr_reveal src t x args h0 = ()
let fuel_eq = ()
let decls_eval_code_reveal c va_s0 va_s1 f = ()
let as_vale_buffer_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_buffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_immbuffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let modifies_same_roots s h0 h1 = ()
let modifies_equal_domains s h0 h1 = ()
let loc_disjoint_sym x y = ()
#set-options "--z3rlimit 20"
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
=
FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
// assert (mem == mk_mem args h0);
let raw_taint = IX64.(mk_taint args IX64.init_taint) in
// assert (taint_map == create_memtaint (_ih mem) (args_b8 args) raw_taint);
ME.valid_memtaint mem (args_b8 args) raw_taint;
// assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a:arg). List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x. List.memP x args /\ Some? (IX64.taint_of_arg x) ==>
LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args
let buffer_writeable_reveal src t x = ()
let buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let imm_buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let buffer_as_seq_invert src t h s b =
let db = get_downview b in
DV.length_eq db;
assert (Seq.equal
(ME.buffer_as_seq s (as_vale_buffer b))
(LSig.uint_to_nat_seq_t t (UV.as_seq h (UV.mk_buffer db (LSig.view_of_base_typ t)))))
let buffer_as_seq_reveal_tuint128 src x va_s = ()
let immbuffer_as_seq_reveal_tuint128 src x va_s = ()
let bounded_buffer_addrs_one src t h b s = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let bounded_buffer_addrs_all src t h b = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred | false | false | Vale.AsLowStar.MemoryHelpers.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val same_down_up_buffer_length (src:base_typ) (b:buf_t src src) : Lemma
(B.length b == DV.length (get_downview b) / view_n src) | [] | Vale.AsLowStar.MemoryHelpers.same_down_up_buffer_length | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | src: Vale.Arch.HeapTypes_s.base_typ -> b: Vale.Interop.Base.buf_t src src
-> FStar.Pervasives.Lemma
(ensures
LowStar.Monotonic.Buffer.length b ==
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b) /
Vale.Interop.Types.view_n src) | {
"end_col": 60,
"end_line": 124,
"start_col": 38,
"start_line": 121
} |
FStar.Pervasives.Lemma | val loc_eq (args: list arg) : Lemma (VSig.mloc_modified_args args == loc_modified_args args) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl | val loc_eq (args: list arg) : Lemma (VSig.mloc_modified_args args == loc_modified_args args)
let rec loc_eq (args: list arg) : Lemma (VSig.mloc_modified_args args == loc_modified_args args) = | false | null | true | match args with
| [] -> ()
| hd :: tl -> loc_eq tl | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Prims.list",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.MemoryHelpers.loc_eq",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"LowStar.Monotonic.Buffer.loc",
"Vale.AsLowStar.ValeSig.mloc_modified_args",
"Vale.Interop.Base.loc_modified_args",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg) | false | false | Vale.AsLowStar.MemoryHelpers.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 loc_eq (args: list arg) : Lemma (VSig.mloc_modified_args args == loc_modified_args args) | [
"recursion"
] | Vale.AsLowStar.MemoryHelpers.loc_eq | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | args: Prims.list Vale.Interop.Base.arg
-> FStar.Pervasives.Lemma
(ensures
Vale.AsLowStar.ValeSig.mloc_modified_args args == Vale.Interop.Base.loc_modified_args args) | {
"end_col": 27,
"end_line": 37,
"start_col": 4,
"start_line": 35
} |
FStar.Pervasives.Lemma | val same_immbuffer_same_upviews (#src #bt:base_typ) (b:ibuf_t src bt) (h0 h1:HS.mem) : Lemma
(requires Seq.equal (B.as_seq h0 b) (B.as_seq h1 b))
(ensures (
let db = get_downview b in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
Seq.equal (UV.as_seq h0 ub) (UV.as_seq h1 ub))) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_immbuffer_same_upviews #src #bt b h0 h1 =
let dv = get_downview b in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i:nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1;
DV.length_eq dv;
Vale.Lib.BufferViewHelpers.lemma_uv_equal (LSig.view_of_base_typ bt) dv h0 h1 | val same_immbuffer_same_upviews (#src #bt:base_typ) (b:ibuf_t src bt) (h0 h1:HS.mem) : Lemma
(requires Seq.equal (B.as_seq h0 b) (B.as_seq h1 b))
(ensures (
let db = get_downview b in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
Seq.equal (UV.as_seq h0 ub) (UV.as_seq h1 ub)))
let same_immbuffer_same_upviews #src #bt b h0 h1 = | false | null | true | let dv = get_downview b in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i: nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in
Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1;
DV.length_eq dv;
Vale.Lib.BufferViewHelpers.lemma_uv_equal (LSig.view_of_base_typ bt) dv h0 h1 | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.ibuf_t",
"FStar.Monotonic.HyperStack.mem",
"Vale.Lib.BufferViewHelpers.lemma_uv_equal",
"FStar.UInt8.t",
"Vale.Interop.Types.base_typ_as_type",
"Vale.AsLowStar.LowStarSig.view_of_base_typ",
"Prims.unit",
"LowStar.BufferView.Down.length_eq",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowStar.BufferView.Down.length",
"Prims.eq2",
"FStar.Seq.Base.index",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowStar.BufferView.Down.get_sel",
"LowStar.BufferView.Down.as_seq_sel",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Down.as_seq",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"LowStar.ImmutableBuffer.immutable_preorder"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = ()
let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let buffer_as_seq_reveal2 src t x va_s = ()
let immbuffer_as_seq_reveal2 src t x va_s = ()
let buffer_addr_reveal src t x args h0 = ()
let immbuffer_addr_reveal src t x args h0 = ()
let fuel_eq = ()
let decls_eval_code_reveal c va_s0 va_s1 f = ()
let as_vale_buffer_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_buffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_immbuffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let modifies_same_roots s h0 h1 = ()
let modifies_equal_domains s h0 h1 = ()
let loc_disjoint_sym x y = ()
#set-options "--z3rlimit 20"
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
=
FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
// assert (mem == mk_mem args h0);
let raw_taint = IX64.(mk_taint args IX64.init_taint) in
// assert (taint_map == create_memtaint (_ih mem) (args_b8 args) raw_taint);
ME.valid_memtaint mem (args_b8 args) raw_taint;
// assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a:arg). List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x. List.memP x args /\ Some? (IX64.taint_of_arg x) ==>
LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args
let buffer_writeable_reveal src t x = ()
let buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let imm_buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let buffer_as_seq_invert src t h s b =
let db = get_downview b in
DV.length_eq db;
assert (Seq.equal
(ME.buffer_as_seq s (as_vale_buffer b))
(LSig.uint_to_nat_seq_t t (UV.as_seq h (UV.mk_buffer db (LSig.view_of_base_typ t)))))
let buffer_as_seq_reveal_tuint128 src x va_s = ()
let immbuffer_as_seq_reveal_tuint128 src x va_s = ()
let bounded_buffer_addrs_one src t h b s = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let bounded_buffer_addrs_all src t h b = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let same_down_up_buffer_length src b =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_div (B.length b) (view_n src)
let down_up_buffer_read_reveal src h s b i =
let db = get_downview b in
let n:pos = view_n src in
let up_view = (LSig.view_of_base_typ src) in
let ub = UV.mk_buffer db up_view in
same_down_up_buffer_length src b;
UV.length_eq ub;
UV.get_sel h ub i;
FStar.Math.Lemmas.lemma_mult_lt_right n i (DV.length db / n);
FStar.Math.Lemmas.multiply_fractions (DV.length db) n;
FStar.Math.Lemmas.nat_times_nat_is_nat i n;
assert (low_buffer_read src src h b i ==
UV.View?.get up_view (Seq.slice (DV.as_seq h db) (i*n) (i*n + n)));
DV.put_sel h db (i*n);
let aux () : Lemma (n * ((i*n)/n) == i*n) =
FStar.Math.Lemmas.cancel_mul_div i n
in aux()
let same_buffer_same_upviews #src #bt b h0 h1 =
let dv = get_downview b in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i:nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1;
DV.length_eq dv;
Vale.Lib.BufferViewHelpers.lemma_uv_equal (LSig.view_of_base_typ bt) dv h0 h1 | false | false | Vale.AsLowStar.MemoryHelpers.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val same_immbuffer_same_upviews (#src #bt:base_typ) (b:ibuf_t src bt) (h0 h1:HS.mem) : Lemma
(requires Seq.equal (B.as_seq h0 b) (B.as_seq h1 b))
(ensures (
let db = get_downview b in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
Seq.equal (UV.as_seq h0 ub) (UV.as_seq h1 ub))) | [] | Vale.AsLowStar.MemoryHelpers.same_immbuffer_same_upviews | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.Interop.Base.ibuf_t src bt ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h0 b)
(LowStar.Monotonic.Buffer.as_seq h1 b))
(ensures
(let db = Vale.Interop.Types.get_downview b in
[@@ FStar.Pervasives.inline_let ]let _ = LowStar.BufferView.Down.length_eq db in
let ub =
LowStar.BufferView.Up.mk_buffer db (Vale.AsLowStar.LowStarSig.view_of_base_typ bt)
in
FStar.Seq.Base.equal (LowStar.BufferView.Up.as_seq h0 ub)
(LowStar.BufferView.Up.as_seq h1 ub))) | {
"end_col": 81,
"end_line": 170,
"start_col": 50,
"start_line": 158
} |
FStar.Pervasives.Lemma | val buffer_as_seq_reveal
(src t:ME.base_typ)
(x:buf_t src t)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma
(let y = as_vale_buffer x in
let db = get_downview x in
DV.length_eq db;
let mem = mk_mem args h0 in
Seq.equal
(LSig.nat_to_uint_seq_t t (ME.buffer_as_seq (create_initial_vale_heap mem) y))
(UV.as_seq h0 (UV.mk_buffer db (LSig.view_of_base_typ t)))) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | val buffer_as_seq_reveal
(src t:ME.base_typ)
(x:buf_t src t)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma
(let y = as_vale_buffer x in
let db = get_downview x in
DV.length_eq db;
let mem = mk_mem args h0 in
Seq.equal
(LSig.nat_to_uint_seq_t t (ME.buffer_as_seq (create_initial_vale_heap mem) y))
(UV.as_seq h0 (UV.mk_buffer db (LSig.view_of_base_typ t))))
let buffer_as_seq_reveal src t x args h0 = | false | null | true | FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buf_t",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"FStar.Pervasives.reveal_opaque",
"Vale.X64.Memory.vale_full_heap",
"Vale.X64.Memory.vale_heap",
"Vale.X64.Memory.get_vale_heap",
"Prims.unit"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | false | false | Vale.AsLowStar.MemoryHelpers.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 buffer_as_seq_reveal
(src t:ME.base_typ)
(x:buf_t src t)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma
(let y = as_vale_buffer x in
let db = get_downview x in
DV.length_eq db;
let mem = mk_mem args h0 in
Seq.equal
(LSig.nat_to_uint_seq_t t (ME.buffer_as_seq (create_initial_vale_heap mem) y))
(UV.as_seq h0 (UV.mk_buffer db (LSig.view_of_base_typ t)))) | [] | Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src: Vale.Arch.HeapTypes_s.base_typ ->
t: Vale.Arch.HeapTypes_s.base_typ ->
x: Vale.Interop.Base.buf_t src t ->
args: Vale.Interop.X64.arg_list ->
h0: FStar.Monotonic.HyperStack.mem{Vale.Interop.Base.mem_roots_p h0 args}
-> FStar.Pervasives.Lemma
(ensures
(let y = Vale.X64.MemoryAdapters.as_vale_buffer x in
let db = Vale.Interop.Types.get_downview x in
[@@ FStar.Pervasives.inline_let ]let _ = LowStar.BufferView.Down.length_eq db in
let mem = Vale.Interop.Base.mk_mem args h0 in
FStar.Seq.Base.equal (Vale.AsLowStar.LowStarSig.nat_to_uint_seq_t t
(Vale.X64.Memory.buffer_as_seq (Vale.X64.MemoryAdapters.create_initial_vale_heap mem)
y))
(LowStar.BufferView.Up.as_seq h0
(LowStar.BufferView.Up.mk_buffer db (Vale.AsLowStar.LowStarSig.view_of_base_typ t))))) | {
"end_col": 111,
"end_line": 48,
"start_col": 43,
"start_line": 48
} |
FStar.Pervasives.Lemma | val same_buffer_same_upviews (#src #bt:base_typ) (b:buf_t src bt) (h0 h1:HS.mem) : Lemma
(requires Seq.equal (B.as_seq h0 b) (B.as_seq h1 b))
(ensures (
let db = get_downview b in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
Seq.equal (UV.as_seq h0 ub) (UV.as_seq h1 ub))) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_buffer_same_upviews #src #bt b h0 h1 =
let dv = get_downview b in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i:nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1;
DV.length_eq dv;
Vale.Lib.BufferViewHelpers.lemma_uv_equal (LSig.view_of_base_typ bt) dv h0 h1 | val same_buffer_same_upviews (#src #bt:base_typ) (b:buf_t src bt) (h0 h1:HS.mem) : Lemma
(requires Seq.equal (B.as_seq h0 b) (B.as_seq h1 b))
(ensures (
let db = get_downview b in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
Seq.equal (UV.as_seq h0 ub) (UV.as_seq h1 ub)))
let same_buffer_same_upviews #src #bt b h0 h1 = | false | null | true | let dv = get_downview b in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i: nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in
Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1;
DV.length_eq dv;
Vale.Lib.BufferViewHelpers.lemma_uv_equal (LSig.view_of_base_typ bt) dv h0 h1 | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buf_t",
"FStar.Monotonic.HyperStack.mem",
"Vale.Lib.BufferViewHelpers.lemma_uv_equal",
"FStar.UInt8.t",
"Vale.Interop.Types.base_typ_as_type",
"Vale.AsLowStar.LowStarSig.view_of_base_typ",
"Prims.unit",
"LowStar.BufferView.Down.length_eq",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowStar.BufferView.Down.length",
"Prims.eq2",
"FStar.Seq.Base.index",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowStar.BufferView.Down.get_sel",
"LowStar.BufferView.Down.as_seq_sel",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Down.as_seq",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"LowStar.Buffer.trivial_preorder"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = ()
let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let buffer_as_seq_reveal2 src t x va_s = ()
let immbuffer_as_seq_reveal2 src t x va_s = ()
let buffer_addr_reveal src t x args h0 = ()
let immbuffer_addr_reveal src t x args h0 = ()
let fuel_eq = ()
let decls_eval_code_reveal c va_s0 va_s1 f = ()
let as_vale_buffer_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_buffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_immbuffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let modifies_same_roots s h0 h1 = ()
let modifies_equal_domains s h0 h1 = ()
let loc_disjoint_sym x y = ()
#set-options "--z3rlimit 20"
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
=
FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
// assert (mem == mk_mem args h0);
let raw_taint = IX64.(mk_taint args IX64.init_taint) in
// assert (taint_map == create_memtaint (_ih mem) (args_b8 args) raw_taint);
ME.valid_memtaint mem (args_b8 args) raw_taint;
// assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a:arg). List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x. List.memP x args /\ Some? (IX64.taint_of_arg x) ==>
LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args
let buffer_writeable_reveal src t x = ()
let buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let imm_buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let buffer_as_seq_invert src t h s b =
let db = get_downview b in
DV.length_eq db;
assert (Seq.equal
(ME.buffer_as_seq s (as_vale_buffer b))
(LSig.uint_to_nat_seq_t t (UV.as_seq h (UV.mk_buffer db (LSig.view_of_base_typ t)))))
let buffer_as_seq_reveal_tuint128 src x va_s = ()
let immbuffer_as_seq_reveal_tuint128 src x va_s = ()
let bounded_buffer_addrs_one src t h b s = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let bounded_buffer_addrs_all src t h b = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let same_down_up_buffer_length src b =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_div (B.length b) (view_n src)
let down_up_buffer_read_reveal src h s b i =
let db = get_downview b in
let n:pos = view_n src in
let up_view = (LSig.view_of_base_typ src) in
let ub = UV.mk_buffer db up_view in
same_down_up_buffer_length src b;
UV.length_eq ub;
UV.get_sel h ub i;
FStar.Math.Lemmas.lemma_mult_lt_right n i (DV.length db / n);
FStar.Math.Lemmas.multiply_fractions (DV.length db) n;
FStar.Math.Lemmas.nat_times_nat_is_nat i n;
assert (low_buffer_read src src h b i ==
UV.View?.get up_view (Seq.slice (DV.as_seq h db) (i*n) (i*n + n)));
DV.put_sel h db (i*n);
let aux () : Lemma (n * ((i*n)/n) == i*n) =
FStar.Math.Lemmas.cancel_mul_div i n
in aux() | false | false | Vale.AsLowStar.MemoryHelpers.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val same_buffer_same_upviews (#src #bt:base_typ) (b:buf_t src bt) (h0 h1:HS.mem) : Lemma
(requires Seq.equal (B.as_seq h0 b) (B.as_seq h1 b))
(ensures (
let db = get_downview b in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
Seq.equal (UV.as_seq h0 ub) (UV.as_seq h1 ub))) | [] | Vale.AsLowStar.MemoryHelpers.same_buffer_same_upviews | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.Interop.Base.buf_t src bt ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h0 b)
(LowStar.Monotonic.Buffer.as_seq h1 b))
(ensures
(let db = Vale.Interop.Types.get_downview b in
[@@ FStar.Pervasives.inline_let ]let _ = LowStar.BufferView.Down.length_eq db in
let ub =
LowStar.BufferView.Up.mk_buffer db (Vale.AsLowStar.LowStarSig.view_of_base_typ bt)
in
FStar.Seq.Base.equal (LowStar.BufferView.Up.as_seq h0 ub)
(LowStar.BufferView.Up.as_seq h1 ub))) | {
"end_col": 81,
"end_line": 156,
"start_col": 47,
"start_line": 144
} |
FStar.Pervasives.Lemma | val immbuffer_as_seq_reveal
(src t:ME.base_typ)
(x:ibuf_t src t)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma
(let y = as_vale_immbuffer x in
let db = get_downview x in
DV.length_eq db;
let mem = mk_mem args h0 in
Seq.equal
(LSig.nat_to_uint_seq_t t (ME.buffer_as_seq (create_initial_vale_heap mem) y))
(UV.as_seq h0 (UV.mk_buffer db (LSig.view_of_base_typ t)))) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | val immbuffer_as_seq_reveal
(src t:ME.base_typ)
(x:ibuf_t src t)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma
(let y = as_vale_immbuffer x in
let db = get_downview x in
DV.length_eq db;
let mem = mk_mem args h0 in
Seq.equal
(LSig.nat_to_uint_seq_t t (ME.buffer_as_seq (create_initial_vale_heap mem) y))
(UV.as_seq h0 (UV.mk_buffer db (LSig.view_of_base_typ t))))
let immbuffer_as_seq_reveal src t x args h0 = | false | null | true | FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.ibuf_t",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"FStar.Pervasives.reveal_opaque",
"Vale.X64.Memory.vale_full_heap",
"Vale.X64.Memory.vale_heap",
"Vale.X64.Memory.get_vale_heap",
"Prims.unit"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = () | false | false | Vale.AsLowStar.MemoryHelpers.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 immbuffer_as_seq_reveal
(src t:ME.base_typ)
(x:ibuf_t src t)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args}) : Lemma
(let y = as_vale_immbuffer x in
let db = get_downview x in
DV.length_eq db;
let mem = mk_mem args h0 in
Seq.equal
(LSig.nat_to_uint_seq_t t (ME.buffer_as_seq (create_initial_vale_heap mem) y))
(UV.as_seq h0 (UV.mk_buffer db (LSig.view_of_base_typ t)))) | [] | Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src: Vale.Arch.HeapTypes_s.base_typ ->
t: Vale.Arch.HeapTypes_s.base_typ ->
x: Vale.Interop.Base.ibuf_t src t ->
args: Vale.Interop.X64.arg_list ->
h0: FStar.Monotonic.HyperStack.mem{Vale.Interop.Base.mem_roots_p h0 args}
-> FStar.Pervasives.Lemma
(ensures
(let y = Vale.X64.MemoryAdapters.as_vale_immbuffer x in
let db = Vale.Interop.Types.get_downview x in
[@@ FStar.Pervasives.inline_let ]let _ = LowStar.BufferView.Down.length_eq db in
let mem = Vale.Interop.Base.mk_mem args h0 in
FStar.Seq.Base.equal (Vale.AsLowStar.LowStarSig.nat_to_uint_seq_t t
(Vale.X64.Memory.buffer_as_seq (Vale.X64.MemoryAdapters.create_initial_vale_heap mem)
y))
(LowStar.BufferView.Up.as_seq h0
(LowStar.BufferView.Up.mk_buffer db (Vale.AsLowStar.LowStarSig.view_of_base_typ t))))) | {
"end_col": 114,
"end_line": 49,
"start_col": 46,
"start_line": 49
} |
FStar.Pervasives.Lemma | val core_create_lemma_taint_hyp
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s)) | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
=
FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
// assert (mem == mk_mem args h0);
let raw_taint = IX64.(mk_taint args IX64.init_taint) in
// assert (taint_map == create_memtaint (_ih mem) (args_b8 args) raw_taint);
ME.valid_memtaint mem (args_b8 args) raw_taint;
// assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a:arg). List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x. List.memP x args /\ Some? (IX64.taint_of_arg x) ==>
LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args | val core_create_lemma_taint_hyp
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args: IX64.arg_list)
(h0: HS.mem{mem_roots_p h0 args})
: Lemma
(ensures
(let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s)) = | false | null | true | FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
let raw_taint = let open IX64 in mk_taint args IX64.init_taint in
ME.valid_memtaint mem (args_b8 args) raw_taint;
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a: arg).
List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x.
List.memP x args /\ Some? (IX64.taint_of_arg x) ==> LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"FStar.BigOps.big_and'_forall",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.LowStarSig.taint_hyp_arg",
"Prims.unit",
"Prims._assert",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_and",
"FStar.List.Tot.Base.memP",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Vale.Arch.HeapTypes_s.taint",
"Vale.Interop.X64.taint_of_arg",
"FStar.Classical.forall_intro",
"Vale.Interop.Types.b8",
"Prims.l_iff",
"Vale.Interop.Base.args_b8",
"Prims.l_Exists",
"Vale.Interop.Base.valid_base_type",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Base",
"Prims.l_False",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.TD_Buffer",
"Prims.eq2",
"Vale.Interop.Base.mut_to_b8",
"Vale.Interop.Base.TD_ImmBuffer",
"Vale.Interop.Base.imm_to_b8",
"Prims.logical",
"Vale.Interop.Base.args_b8_mem",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Vale.Interop.X64.taint_arg_b8",
"Vale.Interop.X64.mk_taint",
"Vale.Interop.X64.init_taint",
"Vale.Interop.X64.mk_taint_equiv",
"Vale.X64.Memory.valid_taint_b8",
"Vale.X64.Memory.valid_memtaint",
"Vale.Interop.X64.taint_map",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.X64.Memory.get_vale_heap",
"Vale.X64.State.__proj__Mkvale_state__item__vs_heap",
"Vale.Arch.HeapTypes_s.memTaint_t",
"Vale.Arch.HeapImpl.full_heap_taint",
"Vale.X64.Decls.vale_state_with_inv",
"Vale.AsLowStar.LowStarSig.create_initial_vale_state",
"FStar.Pervasives.reveal_opaque",
"Vale.X64.Memory.vale_full_heap",
"Vale.X64.Memory.vale_heap",
"Prims.l_True",
"Prims.squash",
"Vale.AsLowStar.LowStarSig.taint_hyp",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = ()
let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let buffer_as_seq_reveal2 src t x va_s = ()
let immbuffer_as_seq_reveal2 src t x va_s = ()
let buffer_addr_reveal src t x args h0 = ()
let immbuffer_addr_reveal src t x args h0 = ()
let fuel_eq = ()
let decls_eval_code_reveal c va_s0 va_s1 f = ()
let as_vale_buffer_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_buffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_immbuffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let modifies_same_roots s h0 h1 = ()
let modifies_equal_domains s h0 h1 = ()
let loc_disjoint_sym x y = ()
#set-options "--z3rlimit 20"
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s)) | false | false | Vale.AsLowStar.MemoryHelpers.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val core_create_lemma_taint_hyp
(#max_arity:nat)
(#arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s)) | [] | Vale.AsLowStar.MemoryHelpers.core_create_lemma_taint_hyp | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
args: Vale.Interop.X64.arg_list ->
h0: FStar.Monotonic.HyperStack.mem{Vale.Interop.Base.mem_roots_p h0 args}
-> FStar.Pervasives.Lemma
(ensures
(let va_s = Vale.AsLowStar.LowStarSig.create_initial_vale_state args h0 in
Vale.AsLowStar.LowStarSig.taint_hyp args va_s)) | {
"end_col": 66,
"end_line": 90,
"start_col": 2,
"start_line": 74
} |
FStar.Pervasives.Lemma | val down_up_buffer_read_reveal (src:base_typ) (h:HS.mem) (s:ME.vale_heap) (b:(buf_t src src){B.live h b}) (i:nat{i < DV.length (get_downview b) / view_n src}) : Lemma
(requires (
DV.length_eq (get_downview b);
same_down_up_buffer_length src b;
Seq.equal
(LSig.nat_to_uint_seq_t src (ME.buffer_as_seq s (as_vale_buffer b)))
(UV.as_seq h (UV.mk_buffer (get_downview b) (LSig.view_of_base_typ src)))))
(ensures LSig.nat_to_uint src (ME.buffer_read (as_vale_buffer b) i s) ==
Seq.index (B.as_seq h b) i)
[SMTPat (ME.buffer_read (as_vale_buffer b) i s); SMTPat (Seq.index (B.as_seq h b) i)] | [
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Vale.X64.Lemmas",
"short_module": "VL"
},
{
"abbrev": true,
"full_module": "Vale.X64.StateLemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_Sems",
"short_module": "VSS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory_Sems",
"short_module": "MES"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let down_up_buffer_read_reveal src h s b i =
let db = get_downview b in
let n:pos = view_n src in
let up_view = (LSig.view_of_base_typ src) in
let ub = UV.mk_buffer db up_view in
same_down_up_buffer_length src b;
UV.length_eq ub;
UV.get_sel h ub i;
FStar.Math.Lemmas.lemma_mult_lt_right n i (DV.length db / n);
FStar.Math.Lemmas.multiply_fractions (DV.length db) n;
FStar.Math.Lemmas.nat_times_nat_is_nat i n;
assert (low_buffer_read src src h b i ==
UV.View?.get up_view (Seq.slice (DV.as_seq h db) (i*n) (i*n + n)));
DV.put_sel h db (i*n);
let aux () : Lemma (n * ((i*n)/n) == i*n) =
FStar.Math.Lemmas.cancel_mul_div i n
in aux() | val down_up_buffer_read_reveal (src:base_typ) (h:HS.mem) (s:ME.vale_heap) (b:(buf_t src src){B.live h b}) (i:nat{i < DV.length (get_downview b) / view_n src}) : Lemma
(requires (
DV.length_eq (get_downview b);
same_down_up_buffer_length src b;
Seq.equal
(LSig.nat_to_uint_seq_t src (ME.buffer_as_seq s (as_vale_buffer b)))
(UV.as_seq h (UV.mk_buffer (get_downview b) (LSig.view_of_base_typ src)))))
(ensures LSig.nat_to_uint src (ME.buffer_read (as_vale_buffer b) i s) ==
Seq.index (B.as_seq h b) i)
[SMTPat (ME.buffer_read (as_vale_buffer b) i s); SMTPat (Seq.index (B.as_seq h b) i)]
let down_up_buffer_read_reveal src h s b i = | false | null | true | let db = get_downview b in
let n:pos = view_n src in
let up_view = (LSig.view_of_base_typ src) in
let ub = UV.mk_buffer db up_view in
same_down_up_buffer_length src b;
UV.length_eq ub;
UV.get_sel h ub i;
FStar.Math.Lemmas.lemma_mult_lt_right n i (DV.length db / n);
FStar.Math.Lemmas.multiply_fractions (DV.length db) n;
FStar.Math.Lemmas.nat_times_nat_is_nat i n;
assert (low_buffer_read src src h b i ==
UV.View?.get up_view (Seq.slice (DV.as_seq h db) (i * n) (i * n + n)));
DV.put_sel h db (i * n);
let aux () : Lemma (n * ((i * n) / n) == i * n) = FStar.Math.Lemmas.cancel_mul_div i n in
aux () | {
"checked_file": "Vale.AsLowStar.MemoryHelpers.fst.checked",
"dependencies": [
"Vale.X64.StateLemmas.fst.checked",
"Vale.X64.Stack_Sems.fst.checked",
"Vale.X64.Stack_i.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.MemoryAdapters.fst.checked",
"Vale.X64.Memory_Sems.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Memory.fst.checked",
"Vale.X64.Decls.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.MemoryHelpers.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"FStar.Monotonic.HyperStack.mem",
"Vale.X64.Memory.vale_heap",
"Vale.Interop.Base.buf_t",
"LowStar.Monotonic.Buffer.live",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.Buffer.trivial_preorder",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Division",
"LowStar.BufferView.Down.length",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.view_n",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.int",
"Prims.op_Multiply",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Math.Lemmas.cancel_mul_div",
"FStar.Mul.op_Star",
"LowStar.BufferView.Down.put_sel",
"Prims._assert",
"Vale.AsLowStar.MemoryHelpers.low_buffer_read",
"LowStar.BufferView.Up.__proj__View__item__get",
"FStar.Seq.Base.slice",
"LowStar.BufferView.Down.as_seq",
"Prims.op_Addition",
"FStar.Math.Lemmas.nat_times_nat_is_nat",
"FStar.Math.Lemmas.multiply_fractions",
"FStar.Math.Lemmas.lemma_mult_lt_right",
"LowStar.BufferView.Up.get_sel",
"LowStar.BufferView.Up.length_eq",
"Vale.AsLowStar.MemoryHelpers.same_down_up_buffer_length",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.mk_buffer",
"LowStar.BufferView.Up.view",
"Vale.AsLowStar.LowStarSig.view_of_base_typ",
"Prims.pos",
"LowStar.BufferView.Down.buffer"
] | [] | module Vale.AsLowStar.MemoryHelpers
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module ME = Vale.X64.Memory
module VSig = Vale.AsLowStar.ValeSig
module IX64 = Vale.Interop.X64
friend Vale.X64.Memory
friend Vale.X64.Memory_Sems
friend Vale.X64.Stack_i
friend Vale.X64.Stack_Sems
friend Vale.X64.Decls
friend Vale.X64.StateLemmas
friend Vale.X64.MemoryAdapters
let as_vale_buffer_len (#src #t:base_typ) (x:buf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let as_vale_immbuffer_len (#src #t:base_typ) (x:ibuf_t src t)
= let db = get_downview x in
DV.length_eq db;
UV.length_eq (UV.mk_buffer db (ME.uint_view t))
let state_eq_down_mem (va_s1:V.va_state) (s1:_) = ()
let rec loc_eq (args:list arg)
: Lemma (VSig.mloc_modified_args args == loc_modified_args args)
= match args with
| [] -> ()
| hd :: tl -> loc_eq tl
let relate_modifies args m0 m1 = loc_eq args
let reveal_readable #src #t x s = ()
let reveal_imm_readable #src #t x s = ()
let readable_live #src #t x s = ()
let readable_imm_live #src #t x s = ()
let buffer_readable_reveal #max_arity src bt x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
//let get_heap_mk_mem_reveal args h0 = ()
let lemma_as_mem_as_vale_mem h = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let mk_stack_reveal stack = ()
let buffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let immbuffer_as_seq_reveal src t x args h0 = FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap
let buffer_as_seq_reveal2 src t x va_s = ()
let immbuffer_as_seq_reveal2 src t x va_s = ()
let buffer_addr_reveal src t x args h0 = ()
let immbuffer_addr_reveal src t x args h0 = ()
let fuel_eq = ()
let decls_eval_code_reveal c va_s0 va_s1 f = ()
let as_vale_buffer_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_buffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let as_vale_immbuffer_imm_disjoint #src1 #src2 #t1 #t2 x y = ()
let modifies_same_roots s h0 h1 = ()
let modifies_equal_domains s h0 h1 = ()
let loc_disjoint_sym x y = ()
#set-options "--z3rlimit 20"
let core_create_lemma_taint_hyp
#max_arity
#arg_reg
(args:IX64.arg_list)
(h0:HS.mem{mem_roots_p h0 args})
: Lemma
(ensures (let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
LSig.taint_hyp args va_s))
=
FStar.Pervasives.reveal_opaque (`%ME.get_vale_heap) ME.get_vale_heap;
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let taint_map = full_heap_taint va_s.VS.vs_heap in
let mem = ME.get_vale_heap va_s.VS.vs_heap in
// assert (mem == mk_mem args h0);
let raw_taint = IX64.(mk_taint args IX64.init_taint) in
// assert (taint_map == create_memtaint (_ih mem) (args_b8 args) raw_taint);
ME.valid_memtaint mem (args_b8 args) raw_taint;
// assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
assert (forall x. List.memP x (args_b8 args) ==> ME.valid_taint_b8 x mem taint_map (raw_taint x));
Classical.forall_intro (IX64.mk_taint_equiv args);
assert (forall (a:arg). List.memP a args /\ Some? (IX64.taint_of_arg a) ==>
Some?.v (IX64.taint_of_arg a) == raw_taint (IX64.taint_arg_b8 a));
Classical.forall_intro (args_b8_mem args);
assert (forall x. List.memP x args /\ Some? (IX64.taint_of_arg x) ==>
LSig.taint_hyp_arg mem taint_map x);
BigOps.big_and'_forall (LSig.taint_hyp_arg mem taint_map) args
let buffer_writeable_reveal src t x = ()
let buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let imm_buffer_read_reveal src t h s b i =
let db = get_downview b in
DV.length_eq db;
let b_v = UV.mk_buffer db (LSig.view_of_base_typ t) in
UV.as_seq_sel h b_v i
let buffer_as_seq_invert src t h s b =
let db = get_downview b in
DV.length_eq db;
assert (Seq.equal
(ME.buffer_as_seq s (as_vale_buffer b))
(LSig.uint_to_nat_seq_t t (UV.as_seq h (UV.mk_buffer db (LSig.view_of_base_typ t)))))
let buffer_as_seq_reveal_tuint128 src x va_s = ()
let immbuffer_as_seq_reveal_tuint128 src x va_s = ()
let bounded_buffer_addrs_one src t h b s = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let bounded_buffer_addrs_all src t h b = FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred
let same_down_up_buffer_length src b =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_div (B.length b) (view_n src) | false | false | Vale.AsLowStar.MemoryHelpers.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val down_up_buffer_read_reveal (src:base_typ) (h:HS.mem) (s:ME.vale_heap) (b:(buf_t src src){B.live h b}) (i:nat{i < DV.length (get_downview b) / view_n src}) : Lemma
(requires (
DV.length_eq (get_downview b);
same_down_up_buffer_length src b;
Seq.equal
(LSig.nat_to_uint_seq_t src (ME.buffer_as_seq s (as_vale_buffer b)))
(UV.as_seq h (UV.mk_buffer (get_downview b) (LSig.view_of_base_typ src)))))
(ensures LSig.nat_to_uint src (ME.buffer_read (as_vale_buffer b) i s) ==
Seq.index (B.as_seq h b) i)
[SMTPat (ME.buffer_read (as_vale_buffer b) i s); SMTPat (Seq.index (B.as_seq h b) i)] | [] | Vale.AsLowStar.MemoryHelpers.down_up_buffer_read_reveal | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.MemoryHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src: Vale.Arch.HeapTypes_s.base_typ ->
h: FStar.Monotonic.HyperStack.mem ->
s: Vale.X64.Memory.vale_heap ->
b: Vale.Interop.Base.buf_t src src {LowStar.Monotonic.Buffer.live h b} ->
i:
Prims.nat
{ i <
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b) /
Vale.Interop.Types.view_n src }
-> FStar.Pervasives.Lemma
(requires
(LowStar.BufferView.Down.length_eq (Vale.Interop.Types.get_downview b);
[@@ FStar.Pervasives.inline_let ]let _ =
Vale.AsLowStar.MemoryHelpers.same_down_up_buffer_length src b
in
FStar.Seq.Base.equal (Vale.AsLowStar.LowStarSig.nat_to_uint_seq_t src
(Vale.X64.Memory.buffer_as_seq s (Vale.X64.MemoryAdapters.as_vale_buffer b)))
(LowStar.BufferView.Up.as_seq h
(LowStar.BufferView.Up.mk_buffer (Vale.Interop.Types.get_downview b)
(Vale.AsLowStar.LowStarSig.view_of_base_typ src)))))
(ensures
Vale.AsLowStar.LowStarSig.nat_to_uint src
(Vale.X64.Memory.buffer_read (Vale.X64.MemoryAdapters.as_vale_buffer b) i s) ==
FStar.Seq.Base.index (LowStar.Monotonic.Buffer.as_seq h b) i)
[
SMTPat (Vale.X64.Memory.buffer_read (Vale.X64.MemoryAdapters.as_vale_buffer b) i s);
SMTPat (FStar.Seq.Base.index (LowStar.Monotonic.Buffer.as_seq h b) i)
] | {
"end_col": 10,
"end_line": 142,
"start_col": 44,
"start_line": 126
} |
FStar.HyperStack.ST.ST | val shrink:
#a:Type -> vec:vector a ->
new_size:uint32_t{new_size <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 -> live h0 vec /\ freeable vec))
(ensures (fun h0 r h1 ->
live h1 vec /\ live h1 r /\ size_of r = new_size /\
frameOf r = frameOf vec /\
hmap_dom_eq h0 h1 /\
freeable r /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector r /\
S.equal (S.slice (V.as_seq h0 vec) 0 (U32.v new_size))
(S.slice (V.as_seq h1 r) 0 (U32.v new_size)))) | [
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Modifies",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shrink #a vec new_size =
Vec new_size (Vec?.cap vec) (Vec?.vs vec) | val shrink:
#a:Type -> vec:vector a ->
new_size:uint32_t{new_size <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 -> live h0 vec /\ freeable vec))
(ensures (fun h0 r h1 ->
live h1 vec /\ live h1 r /\ size_of r = new_size /\
frameOf r = frameOf vec /\
hmap_dom_eq h0 h1 /\
freeable r /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector r /\
S.equal (S.slice (V.as_seq h0 vec) 0 (U32.v new_size))
(S.slice (V.as_seq h1 r) 0 (U32.v new_size))))
let shrink #a vec new_size = | true | null | false | Vec new_size (Vec?.cap vec) (Vec?.vs vec) | {
"checked_file": "MerkleTree.Low.VectorExtras.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Hacl.Hash.Lemmas.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.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.VectorExtras.fst"
} | [] | [
"LowStar.Vector.vector",
"LowStar.Vector.uint32_t",
"Prims.b2t",
"FStar.Integers.op_Less_Equals",
"FStar.Integers.Unsigned",
"FStar.Integers.W32",
"LowStar.Vector.size_of",
"LowStar.Vector.Vec",
"LowStar.Vector.__proj__Vec__item__cap",
"LowStar.Vector.__proj__Vec__item__vs"
] | [] | module MerkleTree.Low.VectorExtras
module B = LowStar.Buffer
module S = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
open LowStar.BufferOps
open Hacl.Hash.Lemmas
open FStar.Integers
open LowStar.Modifies
open LowStar.Regional
open LowStar.Vector
open LowStar.RVector
module V = LowStar.Vector
module RV = LowStar.RVector
(** Some extra functions on top of LowStar.Vector... used for Merkle Tree. *)
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
inline_for_extraction
let move_left #a (b: B.buffer a) (dst src: U32.t) (l: U32.t): HST.Stack unit
(requires fun h0 ->
B.live h0 b /\
U32.v src + U32.v l <= B.length b /\
U32.v dst <= U32.v src)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\ (
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
S.slice b1 dst (dst + l) `S.equal` S.slice b0 src (src + l)))
=
let h0 = HST.get () in
[@inline_let]
let inv (h: HS.mem) (i: nat) =
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
i <= l /\
B.(modifies (loc_buffer b) h0 h) /\
S.slice b1 dst (dst + i) `S.equal` S.slice b0 src (src + i) /\
S.slice b1 (src + i) (src + l) `S.equal` S.slice b0 (src + i) (src + l)
in
let f (i: U32.t { U32.(0 <= v i /\ v i < v l) }): HST.Stack unit
(requires fun h0 -> inv h0 (U32.v i))
(ensures fun h0 _ h1 -> U32.(inv h0 (v i) /\ inv h1 (v i + 1)))
=
let h00 = HST.get () in
calc (==) {
S.index (B.as_seq h0 b) U32.(v src + v i);
(==) {}
S.index (S.slice (B.as_seq h0 b) U32.(v src + v i) U32.(v src + v l)) 0;
(==) {}
S.index (S.slice (B.as_seq h00 b) U32.(v src + v i) U32.(v src + v l)) 0;
(==) {}
S.index (B.as_seq h00 b) U32.(v src + v i);
};
b.(dst `U32.add` i) <- b.(src `U32.add` i);
let h = HST.get () in
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
let i = U32.v i in
calc (S.equal) {
S.slice b1 dst (dst + (i + 1));
(S.equal) { lemma_slice_ijk b1 dst (dst + i) (dst + i + 1) }
S.slice b1 dst (dst + i) `S.append` S.slice b1 (dst + i) (dst + i + 1);
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.slice b1 (dst + i) (dst + i + 1);
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.cons (S.index b1 (dst + i)) S.empty;
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.cons (S.index b0 (src + i)) S.empty;
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.slice b0 (src + i) (src + i + 1);
(S.equal) { lemma_slice_ijk b0 src (src + i) (src + i + 1) }
S.slice b0 src (src + (i + 1));
};
let s1 = S.slice b1 (src + (i + 1)) (src + l) in
let s0 = S.slice b0 (src + (i + 1)) (src + l) in
let aux (j: nat { j < S.length s0 }): Lemma (S.index s0 j == S.index s1 j)
[ SMTPat (S.index s0 j); SMTPat (S.index s1 j) ]
=
calc (==) {
S.index s0 j;
(==) {}
S.index (S.slice b0 (src + i) (src + l)) (j + 1);
(==) {}
S.index (S.slice b1 (src + i) (src + l)) (j + 1);
(==) {}
S.index s1 j;
}
in
()
in
C.Loops.for 0ul l inv f
inline_for_extraction
val shrink:
#a:Type -> vec:vector a ->
new_size:uint32_t{new_size <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 -> live h0 vec /\ freeable vec))
(ensures (fun h0 r h1 ->
live h1 vec /\ live h1 r /\ size_of r = new_size /\
frameOf r = frameOf vec /\
hmap_dom_eq h0 h1 /\
freeable r /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector r /\
S.equal (S.slice (V.as_seq h0 vec) 0 (U32.v new_size))
(S.slice (V.as_seq h1 r) 0 (U32.v new_size)))) | false | false | MerkleTree.Low.VectorExtras.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val shrink:
#a:Type -> vec:vector a ->
new_size:uint32_t{new_size <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 -> live h0 vec /\ freeable vec))
(ensures (fun h0 r h1 ->
live h1 vec /\ live h1 r /\ size_of r = new_size /\
frameOf r = frameOf vec /\
hmap_dom_eq h0 h1 /\
freeable r /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector r /\
S.equal (S.slice (V.as_seq h0 vec) 0 (U32.v new_size))
(S.slice (V.as_seq h1 r) 0 (U32.v new_size)))) | [] | MerkleTree.Low.VectorExtras.shrink | {
"file_name": "src/MerkleTree.Low.VectorExtras.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
vec: LowStar.Vector.vector a ->
new_size: LowStar.Vector.uint32_t{new_size <= LowStar.Vector.size_of vec}
-> FStar.HyperStack.ST.ST (LowStar.Vector.vector a) | {
"end_col": 43,
"end_line": 127,
"start_col": 2,
"start_line": 127
} |
FStar.HyperStack.ST.ST | val flush_inplace:
#a:Type -> vec:vector a ->
i:uint32_t{i <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 ->
live h0 vec /\ freeable vec /\
HST.is_eternal_region (frameOf vec)))
(ensures (fun h0 fvec h1 ->
frameOf vec = frameOf fvec /\
hmap_dom_eq h0 h1 /\
live h1 fvec /\ freeable fvec /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector fvec /\
size_of fvec = size_of vec - i /\
S.equal (V.as_seq h1 fvec)
(S.slice (V.as_seq h0 vec) (U32.v i) (U32.v (size_of vec))))) | [
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Modifies",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let flush_inplace #a vec i =
let h0 = HST.get() in
if i >= size_of vec then
shrink vec 0ul
else if i = 0ul then
vec
else begin
let n_shifted = size_of vec - i in
move_left (Vec?.vs vec) 0ul i n_shifted;
shrink vec n_shifted
end | val flush_inplace:
#a:Type -> vec:vector a ->
i:uint32_t{i <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 ->
live h0 vec /\ freeable vec /\
HST.is_eternal_region (frameOf vec)))
(ensures (fun h0 fvec h1 ->
frameOf vec = frameOf fvec /\
hmap_dom_eq h0 h1 /\
live h1 fvec /\ freeable fvec /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector fvec /\
size_of fvec = size_of vec - i /\
S.equal (V.as_seq h1 fvec)
(S.slice (V.as_seq h0 vec) (U32.v i) (U32.v (size_of vec)))))
let flush_inplace #a vec i = | true | null | false | let h0 = HST.get () in
if i >= size_of vec
then shrink vec 0ul
else
if i = 0ul
then vec
else
let n_shifted = size_of vec - i in
move_left (Vec?.vs vec) 0ul i n_shifted;
shrink vec n_shifted | {
"checked_file": "MerkleTree.Low.VectorExtras.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Hacl.Hash.Lemmas.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.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.VectorExtras.fst"
} | [] | [
"LowStar.Vector.vector",
"LowStar.Vector.uint32_t",
"Prims.b2t",
"FStar.Integers.op_Less_Equals",
"FStar.Integers.Unsigned",
"FStar.Integers.W32",
"LowStar.Vector.size_of",
"FStar.Integers.op_Greater_Equals",
"MerkleTree.Low.VectorExtras.shrink",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.op_Equality",
"FStar.UInt32.t",
"Prims.unit",
"MerkleTree.Low.VectorExtras.move_left",
"LowStar.Vector.__proj__Vec__item__vs",
"FStar.Integers.int_t",
"FStar.Integers.op_Subtraction",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module MerkleTree.Low.VectorExtras
module B = LowStar.Buffer
module S = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
open LowStar.BufferOps
open Hacl.Hash.Lemmas
open FStar.Integers
open LowStar.Modifies
open LowStar.Regional
open LowStar.Vector
open LowStar.RVector
module V = LowStar.Vector
module RV = LowStar.RVector
(** Some extra functions on top of LowStar.Vector... used for Merkle Tree. *)
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
inline_for_extraction
let move_left #a (b: B.buffer a) (dst src: U32.t) (l: U32.t): HST.Stack unit
(requires fun h0 ->
B.live h0 b /\
U32.v src + U32.v l <= B.length b /\
U32.v dst <= U32.v src)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\ (
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
S.slice b1 dst (dst + l) `S.equal` S.slice b0 src (src + l)))
=
let h0 = HST.get () in
[@inline_let]
let inv (h: HS.mem) (i: nat) =
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
i <= l /\
B.(modifies (loc_buffer b) h0 h) /\
S.slice b1 dst (dst + i) `S.equal` S.slice b0 src (src + i) /\
S.slice b1 (src + i) (src + l) `S.equal` S.slice b0 (src + i) (src + l)
in
let f (i: U32.t { U32.(0 <= v i /\ v i < v l) }): HST.Stack unit
(requires fun h0 -> inv h0 (U32.v i))
(ensures fun h0 _ h1 -> U32.(inv h0 (v i) /\ inv h1 (v i + 1)))
=
let h00 = HST.get () in
calc (==) {
S.index (B.as_seq h0 b) U32.(v src + v i);
(==) {}
S.index (S.slice (B.as_seq h0 b) U32.(v src + v i) U32.(v src + v l)) 0;
(==) {}
S.index (S.slice (B.as_seq h00 b) U32.(v src + v i) U32.(v src + v l)) 0;
(==) {}
S.index (B.as_seq h00 b) U32.(v src + v i);
};
b.(dst `U32.add` i) <- b.(src `U32.add` i);
let h = HST.get () in
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
let i = U32.v i in
calc (S.equal) {
S.slice b1 dst (dst + (i + 1));
(S.equal) { lemma_slice_ijk b1 dst (dst + i) (dst + i + 1) }
S.slice b1 dst (dst + i) `S.append` S.slice b1 (dst + i) (dst + i + 1);
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.slice b1 (dst + i) (dst + i + 1);
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.cons (S.index b1 (dst + i)) S.empty;
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.cons (S.index b0 (src + i)) S.empty;
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.slice b0 (src + i) (src + i + 1);
(S.equal) { lemma_slice_ijk b0 src (src + i) (src + i + 1) }
S.slice b0 src (src + (i + 1));
};
let s1 = S.slice b1 (src + (i + 1)) (src + l) in
let s0 = S.slice b0 (src + (i + 1)) (src + l) in
let aux (j: nat { j < S.length s0 }): Lemma (S.index s0 j == S.index s1 j)
[ SMTPat (S.index s0 j); SMTPat (S.index s1 j) ]
=
calc (==) {
S.index s0 j;
(==) {}
S.index (S.slice b0 (src + i) (src + l)) (j + 1);
(==) {}
S.index (S.slice b1 (src + i) (src + l)) (j + 1);
(==) {}
S.index s1 j;
}
in
()
in
C.Loops.for 0ul l inv f
inline_for_extraction
val shrink:
#a:Type -> vec:vector a ->
new_size:uint32_t{new_size <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 -> live h0 vec /\ freeable vec))
(ensures (fun h0 r h1 ->
live h1 vec /\ live h1 r /\ size_of r = new_size /\
frameOf r = frameOf vec /\
hmap_dom_eq h0 h1 /\
freeable r /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector r /\
S.equal (S.slice (V.as_seq h0 vec) 0 (U32.v new_size))
(S.slice (V.as_seq h1 r) 0 (U32.v new_size))))
let shrink #a vec new_size =
Vec new_size (Vec?.cap vec) (Vec?.vs vec)
inline_for_extraction
val flush_inplace:
#a:Type -> vec:vector a ->
i:uint32_t{i <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 ->
live h0 vec /\ freeable vec /\
HST.is_eternal_region (frameOf vec)))
(ensures (fun h0 fvec h1 ->
frameOf vec = frameOf fvec /\
hmap_dom_eq h0 h1 /\
live h1 fvec /\ freeable fvec /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector fvec /\
size_of fvec = size_of vec - i /\
S.equal (V.as_seq h1 fvec) | false | false | MerkleTree.Low.VectorExtras.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val flush_inplace:
#a:Type -> vec:vector a ->
i:uint32_t{i <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 ->
live h0 vec /\ freeable vec /\
HST.is_eternal_region (frameOf vec)))
(ensures (fun h0 fvec h1 ->
frameOf vec = frameOf fvec /\
hmap_dom_eq h0 h1 /\
live h1 fvec /\ freeable fvec /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector fvec /\
size_of fvec = size_of vec - i /\
S.equal (V.as_seq h1 fvec)
(S.slice (V.as_seq h0 vec) (U32.v i) (U32.v (size_of vec))))) | [] | MerkleTree.Low.VectorExtras.flush_inplace | {
"file_name": "src/MerkleTree.Low.VectorExtras.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | vec: LowStar.Vector.vector a -> i: LowStar.Vector.uint32_t{i <= LowStar.Vector.size_of vec}
-> FStar.HyperStack.ST.ST (LowStar.Vector.vector a) | {
"end_col": 5,
"end_line": 157,
"start_col": 28,
"start_line": 147
} |
FStar.HyperStack.ST.ST | val rv_flush_inplace:
#a:Type0 -> #rst:Type -> #rg:regional rst a ->
rv:rvector rg -> i:uint32_t{i <= size_of rv} ->
HST.ST (rvector rg)
(requires (fun h0 -> rv_inv h0 rv))
(ensures (fun h0 frv h1 ->
V.size_of frv = V.size_of rv - i /\
V.frameOf rv = V.frameOf frv /\
modifies (loc_rvector rv) h0 h1 /\
rv_inv h1 frv /\
S.equal (as_seq h1 frv)
(S.slice (as_seq h0 rv) (U32.v i) (U32.v (V.size_of rv))))) | [
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Modifies",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rv_flush_inplace #a #rst #rg rv i =
let hh0 = HST.get () in
(if i = 0ul then () else free_elems rv (i - 1ul));
rv_loc_elems_included hh0 rv 0ul i;
let hh1 = HST.get () in
assert (modifies (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) hh0 hh1);
let frv = flush_inplace rv i in
let hh2 = HST.get () in
assert (modifies (loc_region_only false (V.frameOf rv)) hh1 hh2);
// Safety
rs_loc_elems_disj
rg (V.as_seq hh0 rv) (V.frameOf rv) 0 (U32.v (V.size_of rv))
0 (U32.v i) (U32.v i) (U32.v (V.size_of rv));
rs_loc_elems_parent_disj
rg (V.as_seq hh0 rv) (V.frameOf rv)
(U32.v i) (U32.v (V.size_of rv));
rs_elems_inv_preserved
rg (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))
(loc_union (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i))
(loc_region_only false (V.frameOf rv)))
hh0 hh2;
assert (rv_inv #a #rst #rg hh2 frv);
// Correctness
as_seq_seq_preserved
rg (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))
(loc_union (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i))
(loc_region_only false (V.frameOf rv)))
hh0 hh2;
as_seq_seq_slice
rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv))
(U32.v i) (U32.v (V.size_of rv));
assert (S.equal (S.slice (as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)))
(as_seq_seq rg hh2 (V.as_seq hh0 rv)
(U32.v i) (U32.v (V.size_of rv))));
as_seq_seq_eq
rg hh2 (V.as_seq hh0 rv) (V.as_seq hh2 frv)
(U32.v i) (U32.v (V.size_of rv)) 0 (U32.v (V.size_of frv));
assert (S.equal (as_seq_seq rg hh2 (V.as_seq hh2 frv)
0 (U32.v (V.size_of frv)))
(as_seq_seq rg hh2 (V.as_seq hh0 rv)
(U32.v i) (U32.v (V.size_of rv))));
assert (S.equal (S.slice (as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)))
(as_seq hh2 frv));
frv | val rv_flush_inplace:
#a:Type0 -> #rst:Type -> #rg:regional rst a ->
rv:rvector rg -> i:uint32_t{i <= size_of rv} ->
HST.ST (rvector rg)
(requires (fun h0 -> rv_inv h0 rv))
(ensures (fun h0 frv h1 ->
V.size_of frv = V.size_of rv - i /\
V.frameOf rv = V.frameOf frv /\
modifies (loc_rvector rv) h0 h1 /\
rv_inv h1 frv /\
S.equal (as_seq h1 frv)
(S.slice (as_seq h0 rv) (U32.v i) (U32.v (V.size_of rv)))))
let rv_flush_inplace #a #rst #rg rv i = | true | null | false | let hh0 = HST.get () in
(if i = 0ul then () else free_elems rv (i - 1ul));
rv_loc_elems_included hh0 rv 0ul i;
let hh1 = HST.get () in
assert (modifies (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) hh0 hh1);
let frv = flush_inplace rv i in
let hh2 = HST.get () in
assert (modifies (loc_region_only false (V.frameOf rv)) hh1 hh2);
rs_loc_elems_disj rg
(V.as_seq hh0 rv)
(V.frameOf rv)
0
(U32.v (V.size_of rv))
0
(U32.v i)
(U32.v i)
(U32.v (V.size_of rv));
rs_loc_elems_parent_disj rg (V.as_seq hh0 rv) (V.frameOf rv) (U32.v i) (U32.v (V.size_of rv));
rs_elems_inv_preserved rg
(V.as_seq hh0 rv)
(U32.v i)
(U32.v (V.size_of rv))
(loc_union (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) (loc_region_only false (V.frameOf rv)))
hh0
hh2;
assert (rv_inv #a #rst #rg hh2 frv);
as_seq_seq_preserved rg
(V.as_seq hh0 rv)
(U32.v i)
(U32.v (V.size_of rv))
(loc_union (rs_loc_elems rg (V.as_seq hh0 rv) 0 (U32.v i)) (loc_region_only false (V.frameOf rv)))
hh0
hh2;
as_seq_seq_slice rg hh0 (V.as_seq hh0 rv) 0 (U32.v (V.size_of rv)) (U32.v i) (U32.v (V.size_of rv));
assert (S.equal (S.slice (as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv)))
(as_seq_seq rg hh2 (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))));
as_seq_seq_eq rg
hh2
(V.as_seq hh0 rv)
(V.as_seq hh2 frv)
(U32.v i)
(U32.v (V.size_of rv))
0
(U32.v (V.size_of frv));
assert (S.equal (as_seq_seq rg hh2 (V.as_seq hh2 frv) 0 (U32.v (V.size_of frv)))
(as_seq_seq rg hh2 (V.as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))));
assert (S.equal (S.slice (as_seq hh0 rv) (U32.v i) (U32.v (V.size_of rv))) (as_seq hh2 frv));
frv | {
"checked_file": "MerkleTree.Low.VectorExtras.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Hacl.Hash.Lemmas.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.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.VectorExtras.fst"
} | [] | [
"LowStar.Regional.regional",
"LowStar.RVector.rvector",
"LowStar.Vector.uint32_t",
"Prims.b2t",
"FStar.Integers.op_Less_Equals",
"FStar.Integers.Unsigned",
"FStar.Integers.W32",
"LowStar.Vector.size_of",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"LowStar.Regional.__proj__Rgl__item__repr",
"FStar.Seq.Base.slice",
"LowStar.RVector.as_seq",
"FStar.UInt32.v",
"LowStar.RVector.as_seq_seq",
"LowStar.Vector.as_seq",
"LowStar.RVector.as_seq_seq_eq",
"LowStar.RVector.as_seq_seq_slice",
"LowStar.RVector.as_seq_seq_preserved",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.RVector.rs_loc_elems",
"LowStar.Monotonic.Buffer.loc_region_only",
"LowStar.Vector.frameOf",
"LowStar.RVector.rv_inv",
"LowStar.RVector.rs_elems_inv_preserved",
"LowStar.RVector.rs_loc_elems_parent_disj",
"LowStar.RVector.rs_loc_elems_disj",
"LowStar.Monotonic.Buffer.modifies",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Vector.vector",
"MerkleTree.Low.VectorExtras.flush_inplace",
"LowStar.RVector.rv_loc_elems_included",
"FStar.UInt32.__uint_to_t",
"Prims.op_Equality",
"FStar.UInt32.t",
"Prims.bool",
"LowStar.RVector.free_elems",
"FStar.Integers.op_Subtraction"
] | [] | module MerkleTree.Low.VectorExtras
module B = LowStar.Buffer
module S = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
open LowStar.BufferOps
open Hacl.Hash.Lemmas
open FStar.Integers
open LowStar.Modifies
open LowStar.Regional
open LowStar.Vector
open LowStar.RVector
module V = LowStar.Vector
module RV = LowStar.RVector
(** Some extra functions on top of LowStar.Vector... used for Merkle Tree. *)
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
inline_for_extraction
let move_left #a (b: B.buffer a) (dst src: U32.t) (l: U32.t): HST.Stack unit
(requires fun h0 ->
B.live h0 b /\
U32.v src + U32.v l <= B.length b /\
U32.v dst <= U32.v src)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\ (
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
S.slice b1 dst (dst + l) `S.equal` S.slice b0 src (src + l)))
=
let h0 = HST.get () in
[@inline_let]
let inv (h: HS.mem) (i: nat) =
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
i <= l /\
B.(modifies (loc_buffer b) h0 h) /\
S.slice b1 dst (dst + i) `S.equal` S.slice b0 src (src + i) /\
S.slice b1 (src + i) (src + l) `S.equal` S.slice b0 (src + i) (src + l)
in
let f (i: U32.t { U32.(0 <= v i /\ v i < v l) }): HST.Stack unit
(requires fun h0 -> inv h0 (U32.v i))
(ensures fun h0 _ h1 -> U32.(inv h0 (v i) /\ inv h1 (v i + 1)))
=
let h00 = HST.get () in
calc (==) {
S.index (B.as_seq h0 b) U32.(v src + v i);
(==) {}
S.index (S.slice (B.as_seq h0 b) U32.(v src + v i) U32.(v src + v l)) 0;
(==) {}
S.index (S.slice (B.as_seq h00 b) U32.(v src + v i) U32.(v src + v l)) 0;
(==) {}
S.index (B.as_seq h00 b) U32.(v src + v i);
};
b.(dst `U32.add` i) <- b.(src `U32.add` i);
let h = HST.get () in
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
let i = U32.v i in
calc (S.equal) {
S.slice b1 dst (dst + (i + 1));
(S.equal) { lemma_slice_ijk b1 dst (dst + i) (dst + i + 1) }
S.slice b1 dst (dst + i) `S.append` S.slice b1 (dst + i) (dst + i + 1);
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.slice b1 (dst + i) (dst + i + 1);
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.cons (S.index b1 (dst + i)) S.empty;
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.cons (S.index b0 (src + i)) S.empty;
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.slice b0 (src + i) (src + i + 1);
(S.equal) { lemma_slice_ijk b0 src (src + i) (src + i + 1) }
S.slice b0 src (src + (i + 1));
};
let s1 = S.slice b1 (src + (i + 1)) (src + l) in
let s0 = S.slice b0 (src + (i + 1)) (src + l) in
let aux (j: nat { j < S.length s0 }): Lemma (S.index s0 j == S.index s1 j)
[ SMTPat (S.index s0 j); SMTPat (S.index s1 j) ]
=
calc (==) {
S.index s0 j;
(==) {}
S.index (S.slice b0 (src + i) (src + l)) (j + 1);
(==) {}
S.index (S.slice b1 (src + i) (src + l)) (j + 1);
(==) {}
S.index s1 j;
}
in
()
in
C.Loops.for 0ul l inv f
inline_for_extraction
val shrink:
#a:Type -> vec:vector a ->
new_size:uint32_t{new_size <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 -> live h0 vec /\ freeable vec))
(ensures (fun h0 r h1 ->
live h1 vec /\ live h1 r /\ size_of r = new_size /\
frameOf r = frameOf vec /\
hmap_dom_eq h0 h1 /\
freeable r /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector r /\
S.equal (S.slice (V.as_seq h0 vec) 0 (U32.v new_size))
(S.slice (V.as_seq h1 r) 0 (U32.v new_size))))
let shrink #a vec new_size =
Vec new_size (Vec?.cap vec) (Vec?.vs vec)
inline_for_extraction
val flush_inplace:
#a:Type -> vec:vector a ->
i:uint32_t{i <= size_of vec} ->
HST.ST (vector a)
(requires (fun h0 ->
live h0 vec /\ freeable vec /\
HST.is_eternal_region (frameOf vec)))
(ensures (fun h0 fvec h1 ->
frameOf vec = frameOf fvec /\
hmap_dom_eq h0 h1 /\
live h1 fvec /\ freeable fvec /\
modifies (loc_vector vec) h0 h1 /\
loc_vector vec == loc_vector fvec /\
size_of fvec = size_of vec - i /\
S.equal (V.as_seq h1 fvec)
(S.slice (V.as_seq h0 vec) (U32.v i) (U32.v (size_of vec)))))
let flush_inplace #a vec i =
let h0 = HST.get() in
if i >= size_of vec then
shrink vec 0ul
else if i = 0ul then
vec
else begin
let n_shifted = size_of vec - i in
move_left (Vec?.vs vec) 0ul i n_shifted;
shrink vec n_shifted
end
inline_for_extraction
val rv_flush_inplace:
#a:Type0 -> #rst:Type -> #rg:regional rst a ->
rv:rvector rg -> i:uint32_t{i <= size_of rv} ->
HST.ST (rvector rg)
(requires (fun h0 -> rv_inv h0 rv))
(ensures (fun h0 frv h1 ->
V.size_of frv = V.size_of rv - i /\
V.frameOf rv = V.frameOf frv /\
modifies (loc_rvector rv) h0 h1 /\
rv_inv h1 frv /\
S.equal (as_seq h1 frv) | false | false | MerkleTree.Low.VectorExtras.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val rv_flush_inplace:
#a:Type0 -> #rst:Type -> #rg:regional rst a ->
rv:rvector rg -> i:uint32_t{i <= size_of rv} ->
HST.ST (rvector rg)
(requires (fun h0 -> rv_inv h0 rv))
(ensures (fun h0 frv h1 ->
V.size_of frv = V.size_of rv - i /\
V.frameOf rv = V.frameOf frv /\
modifies (loc_rvector rv) h0 h1 /\
rv_inv h1 frv /\
S.equal (as_seq h1 frv)
(S.slice (as_seq h0 rv) (U32.v i) (U32.v (V.size_of rv))))) | [] | MerkleTree.Low.VectorExtras.rv_flush_inplace | {
"file_name": "src/MerkleTree.Low.VectorExtras.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | rv: LowStar.RVector.rvector rg -> i: LowStar.Vector.uint32_t{i <= LowStar.Vector.size_of rv}
-> FStar.HyperStack.ST.ST (LowStar.RVector.rvector rg) | {
"end_col": 5,
"end_line": 220,
"start_col": 39,
"start_line": 173
} |
FStar.HyperStack.ST.Stack | val move_left (#a: _) (b: B.buffer a) (dst src l: U32.t)
: HST.Stack unit
(requires fun h0 -> B.live h0 b /\ U32.v src + U32.v l <= B.length b /\ U32.v dst <= U32.v src
)
(ensures
fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\
(let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
(S.slice b1 dst (dst + l)) `S.equal` (S.slice b0 src (src + l)))) | [
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Modifies",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let move_left #a (b: B.buffer a) (dst src: U32.t) (l: U32.t): HST.Stack unit
(requires fun h0 ->
B.live h0 b /\
U32.v src + U32.v l <= B.length b /\
U32.v dst <= U32.v src)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\ (
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
S.slice b1 dst (dst + l) `S.equal` S.slice b0 src (src + l)))
=
let h0 = HST.get () in
[@inline_let]
let inv (h: HS.mem) (i: nat) =
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
i <= l /\
B.(modifies (loc_buffer b) h0 h) /\
S.slice b1 dst (dst + i) `S.equal` S.slice b0 src (src + i) /\
S.slice b1 (src + i) (src + l) `S.equal` S.slice b0 (src + i) (src + l)
in
let f (i: U32.t { U32.(0 <= v i /\ v i < v l) }): HST.Stack unit
(requires fun h0 -> inv h0 (U32.v i))
(ensures fun h0 _ h1 -> U32.(inv h0 (v i) /\ inv h1 (v i + 1)))
=
let h00 = HST.get () in
calc (==) {
S.index (B.as_seq h0 b) U32.(v src + v i);
(==) {}
S.index (S.slice (B.as_seq h0 b) U32.(v src + v i) U32.(v src + v l)) 0;
(==) {}
S.index (S.slice (B.as_seq h00 b) U32.(v src + v i) U32.(v src + v l)) 0;
(==) {}
S.index (B.as_seq h00 b) U32.(v src + v i);
};
b.(dst `U32.add` i) <- b.(src `U32.add` i);
let h = HST.get () in
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
let i = U32.v i in
calc (S.equal) {
S.slice b1 dst (dst + (i + 1));
(S.equal) { lemma_slice_ijk b1 dst (dst + i) (dst + i + 1) }
S.slice b1 dst (dst + i) `S.append` S.slice b1 (dst + i) (dst + i + 1);
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.slice b1 (dst + i) (dst + i + 1);
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.cons (S.index b1 (dst + i)) S.empty;
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.cons (S.index b0 (src + i)) S.empty;
(S.equal) { }
S.slice b0 src (src + i) `S.append` S.slice b0 (src + i) (src + i + 1);
(S.equal) { lemma_slice_ijk b0 src (src + i) (src + i + 1) }
S.slice b0 src (src + (i + 1));
};
let s1 = S.slice b1 (src + (i + 1)) (src + l) in
let s0 = S.slice b0 (src + (i + 1)) (src + l) in
let aux (j: nat { j < S.length s0 }): Lemma (S.index s0 j == S.index s1 j)
[ SMTPat (S.index s0 j); SMTPat (S.index s1 j) ]
=
calc (==) {
S.index s0 j;
(==) {}
S.index (S.slice b0 (src + i) (src + l)) (j + 1);
(==) {}
S.index (S.slice b1 (src + i) (src + l)) (j + 1);
(==) {}
S.index s1 j;
}
in
()
in
C.Loops.for 0ul l inv f | val move_left (#a: _) (b: B.buffer a) (dst src l: U32.t)
: HST.Stack unit
(requires fun h0 -> B.live h0 b /\ U32.v src + U32.v l <= B.length b /\ U32.v dst <= U32.v src
)
(ensures
fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\
(let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
(S.slice b1 dst (dst + l)) `S.equal` (S.slice b0 src (src + l))))
let move_left #a (b: B.buffer a) (dst: U32.t) (src: U32.t) (l: U32.t)
: HST.Stack unit
(requires fun h0 -> B.live h0 b /\ U32.v src + U32.v l <= B.length b /\ U32.v dst <= U32.v src
)
(ensures
fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\
(let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
(S.slice b1 dst (dst + l)) `S.equal` (S.slice b0 src (src + l)))) = | true | null | false | let h0 = HST.get () in
[@@ inline_let ]let inv (h: HS.mem) (i: nat) =
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
i <= l /\ B.(modifies (loc_buffer b) h0 h) /\
(S.slice b1 dst (dst + i)) `S.equal` (S.slice b0 src (src + i)) /\
(S.slice b1 (src + i) (src + l)) `S.equal` (S.slice b0 (src + i) (src + l))
in
let f (i: U32.t{let open U32 in 0 <= v i /\ v i < v l})
: HST.Stack unit
(requires fun h0 -> inv h0 (U32.v i))
(ensures fun h0 _ h1 -> let open U32 in inv h0 (v i) /\ inv h1 (v i + 1)) =
let h00 = HST.get () in
calc ( == ) {
S.index (B.as_seq h0 b) U32.(v src + v i);
( == ) { () }
S.index (S.slice (B.as_seq h0 b) U32.(v src + v i) U32.(v src + v l)) 0;
( == ) { () }
S.index (S.slice (B.as_seq h00 b) U32.(v src + v i) U32.(v src + v l)) 0;
( == ) { () }
S.index (B.as_seq h00 b) U32.(v src + v i);
};
b.(dst `U32.add` i) <- b.(src `U32.add` i);
let h = HST.get () in
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
let i = U32.v i in
calc (S.equal) {
S.slice b1 dst (dst + (i + 1));
(S.equal) { lemma_slice_ijk b1 dst (dst + i) (dst + i + 1) }
(S.slice b1 dst (dst + i)) `S.append` (S.slice b1 (dst + i) (dst + i + 1));
(S.equal) { () }
(S.slice b0 src (src + i)) `S.append` (S.slice b1 (dst + i) (dst + i + 1));
(S.equal) { () }
(S.slice b0 src (src + i)) `S.append` (S.cons (S.index b1 (dst + i)) S.empty);
(S.equal) { () }
(S.slice b0 src (src + i)) `S.append` (S.cons (S.index b0 (src + i)) S.empty);
(S.equal) { () }
(S.slice b0 src (src + i)) `S.append` (S.slice b0 (src + i) (src + i + 1));
(S.equal) { lemma_slice_ijk b0 src (src + i) (src + i + 1) }
S.slice b0 src (src + (i + 1));
};
let s1 = S.slice b1 (src + (i + 1)) (src + l) in
let s0 = S.slice b0 (src + (i + 1)) (src + l) in
let aux (j: nat{j < S.length s0})
: Lemma (S.index s0 j == S.index s1 j) [SMTPat (S.index s0 j); SMTPat (S.index s1 j)] =
calc ( == ) {
S.index s0 j;
( == ) { () }
S.index (S.slice b0 (src + i) (src + l)) (j + 1);
( == ) { () }
S.index (S.slice b1 (src + i) (src + l)) (j + 1);
( == ) { () }
S.index s1 j;
}
in
()
in
C.Loops.for 0ul l inv f | {
"checked_file": "MerkleTree.Low.VectorExtras.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Hacl.Hash.Lemmas.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.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.VectorExtras.fst"
} | [] | [
"LowStar.Buffer.buffer",
"FStar.UInt32.t",
"C.Loops.for",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"FStar.Monotonic.HyperStack.mem",
"Prims.op_Addition",
"FStar.Integers.op_Less_Equals",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.op_Less",
"FStar.Integers.int_t",
"Prims.op_GreaterThanOrEqual",
"FStar.Seq.Base.length",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.index",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"FStar.Integers.nat",
"FStar.Calc.calc_finish",
"FStar.Preorder.relation",
"FStar.Calc.calc_step",
"FStar.Seq.Base.slice",
"FStar.Integers.op_Plus",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.append",
"FStar.Seq.Properties.cons",
"FStar.Seq.Base.empty",
"Hacl.Hash.Lemmas.lemma_slice_ijk",
"FStar.UInt.uint_t",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Buffer.trivial_preorder",
"FStar.HyperStack.ST.get",
"LowStar.BufferOps.op_Array_Assignment",
"FStar.UInt32.add",
"LowStar.BufferOps.op_Array_Access",
"Prims.logical",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Monotonic.Buffer.live",
"LowStar.Monotonic.Buffer.length"
] | [] | module MerkleTree.Low.VectorExtras
module B = LowStar.Buffer
module S = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
open LowStar.BufferOps
open Hacl.Hash.Lemmas
open FStar.Integers
open LowStar.Modifies
open LowStar.Regional
open LowStar.Vector
open LowStar.RVector
module V = LowStar.Vector
module RV = LowStar.RVector
(** Some extra functions on top of LowStar.Vector... used for Merkle Tree. *)
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
inline_for_extraction
let move_left #a (b: B.buffer a) (dst src: U32.t) (l: U32.t): HST.Stack unit
(requires fun h0 ->
B.live h0 b /\
U32.v src + U32.v l <= B.length b /\
U32.v dst <= U32.v src)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\ (
let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in | false | false | MerkleTree.Low.VectorExtras.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val move_left (#a: _) (b: B.buffer a) (dst src l: U32.t)
: HST.Stack unit
(requires fun h0 -> B.live h0 b /\ U32.v src + U32.v l <= B.length b /\ U32.v dst <= U32.v src
)
(ensures
fun h0 _ h1 ->
B.(modifies (loc_buffer b) h0 h1) /\
(let b0 = B.as_seq h0 b in
let b1 = B.as_seq h1 b in
let src = U32.v src in
let dst = U32.v dst in
let l = U32.v l in
(S.slice b1 dst (dst + l)) `S.equal` (S.slice b0 src (src + l)))) | [] | MerkleTree.Low.VectorExtras.move_left | {
"file_name": "src/MerkleTree.Low.VectorExtras.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | b: LowStar.Buffer.buffer a -> dst: FStar.UInt32.t -> src: FStar.UInt32.t -> l: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 25,
"end_line": 108,
"start_col": 1,
"start_line": 40
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fail (#a:Type) (m:string) = raise #a (TacticFailure m) | let fail (#a: Type) (m: string) = | true | null | false | raise #a (TacticFailure m) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"Prims.string",
"FStar.Tactics.Effect.raise",
"FStar.Tactics.Common.TacticFailure"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t)
val collect_abs : term -> Tac (list binder * term)
let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t')
(* Copied from FStar.Tactics.Derived *) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 fail : m: Prims.string -> FStar.Tactics.Effect.Tac a | [] | FStar.Tactics.V1.SyntaxHelpers.fail | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | m: Prims.string -> FStar.Tactics.Effect.Tac a | {
"end_col": 58,
"end_line": 48,
"start_col": 32,
"start_line": 48
} |
|
FStar.Tactics.Effect.Tac | val collect_arr : typ -> Tac (list typ * comp) | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c) | val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t = | true | null | false | let bs, c = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"FStar.Reflection.Types.typ",
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.comp",
"FStar.Pervasives.Native.Mktuple2",
"FStar.List.Tot.Base.rev",
"FStar.List.Tot.Base.map",
"FStar.Reflection.V1.Derived.type_of_binder",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.V1.SyntaxHelpers.collect_arr'",
"Prims.Nil",
"FStar.Reflection.V1.Builtins.pack_comp",
"FStar.Reflection.V1.Data.C_Total"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 collect_arr : typ -> Tac (list typ * comp) | [] | FStar.Tactics.V1.SyntaxHelpers.collect_arr | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac (Prims.list FStar.Reflection.Types.typ * FStar.Reflection.Types.comp) | {
"end_col": 29,
"end_line": 32,
"start_col": 19,
"start_line": 29
} |
FStar.Tactics.Effect.Tac | val collect_arr_bs : typ -> Tac (list binder * comp) | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c) | val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t = | true | null | false | let bs, c = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"FStar.Reflection.Types.typ",
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.comp",
"FStar.Pervasives.Native.Mktuple2",
"FStar.List.Tot.Base.rev",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.V1.SyntaxHelpers.collect_arr'",
"Prims.Nil",
"FStar.Reflection.V1.Builtins.pack_comp",
"FStar.Reflection.V1.Data.C_Total"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end | false | false | FStar.Tactics.V1.SyntaxHelpers.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 collect_arr_bs : typ -> Tac (list binder * comp) | [] | FStar.Tactics.V1.SyntaxHelpers.collect_arr_bs | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.typ
-> FStar.Tactics.Effect.Tac
(Prims.list FStar.Reflection.Types.binder * FStar.Reflection.Types.comp) | {
"end_col": 29,
"end_line": 26,
"start_col": 22,
"start_line": 24
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let collect_app = collect_app' [] | let collect_app = | true | null | false | collect_app' [] | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"FStar.Tactics.V1.SyntaxHelpers.collect_app'",
"Prims.Nil",
"FStar.Reflection.V1.Data.argv"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t)
val collect_abs : term -> Tac (list binder * term)
let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t')
(* Copied from FStar.Tactics.Derived *)
private
let fail (#a:Type) (m:string) = raise #a (TacticFailure m)
let rec mk_arr (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack (Tv_Arrow b cod)
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_arr bs cod))))
let rec mk_arr_curried (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack_curried (Tv_Arrow b cod)
| (b::bs) -> pack_curried (Tv_Arrow b (pack_comp (C_Total (mk_arr_curried bs cod))))
let rec mk_tot_arr (bs: list binder) (cod : term) : Tac term =
match bs with
| [] -> cod
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr bs cod))))
let lookup_lb_view (lbs:list letbinding) (nm:name) : Tac lb_view =
let o = FStar.List.Tot.Base.find
(fun lb ->
let lbv = inspect_lb lb in
(inspect_fv lbv.lb_fv) = nm)
lbs
in
match o with
| Some lb -> inspect_lb lb
| None -> fail "lookup_lb_view: Name not in let group"
let rec inspect_unascribe (t:term) : Tac (tv:term_view{notAscription tv}) =
match inspect t with
| Tv_AscribedT t _ _ _
| Tv_AscribedC t _ _ _ ->
inspect_unascribe t
| tv -> tv
(* Helpers for dealing with nested applications and arrows *)
let rec collect_app' (args : list argv) (t : term)
: Tac (term * list argv) =
match inspect_unascribe t with
| Tv_App l r ->
collect_app' (r::args) l
| _ -> (t, args) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 collect_app : t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(FStar.Reflection.Types.term * Prims.list FStar.Reflection.V1.Data.argv) | [] | FStar.Tactics.V1.SyntaxHelpers.collect_app | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(FStar.Reflection.Types.term * Prims.list FStar.Reflection.V1.Data.argv) | {
"end_col": 33,
"end_line": 95,
"start_col": 18,
"start_line": 95
} |
|
FStar.Tactics.Effect.Tac | val collect_app' (args: list argv) (t: term) : Tac (term * list argv) | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec collect_app' (args : list argv) (t : term)
: Tac (term * list argv) =
match inspect_unascribe t with
| Tv_App l r ->
collect_app' (r::args) l
| _ -> (t, args) | val collect_app' (args: list argv) (t: term) : Tac (term * list argv)
let rec collect_app' (args: list argv) (t: term) : Tac (term * list argv) = | true | null | false | match inspect_unascribe t with
| Tv_App l r -> collect_app' (r :: args) l
| _ -> (t, args) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"FStar.Reflection.Types.term",
"FStar.Tactics.V1.SyntaxHelpers.collect_app'",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V1.Data.term_view",
"FStar.Pervasives.Native.Mktuple2",
"Prims.b2t",
"FStar.Reflection.V1.Data.notAscription",
"FStar.Tactics.V1.SyntaxHelpers.inspect_unascribe"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t)
val collect_abs : term -> Tac (list binder * term)
let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t')
(* Copied from FStar.Tactics.Derived *)
private
let fail (#a:Type) (m:string) = raise #a (TacticFailure m)
let rec mk_arr (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack (Tv_Arrow b cod)
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_arr bs cod))))
let rec mk_arr_curried (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack_curried (Tv_Arrow b cod)
| (b::bs) -> pack_curried (Tv_Arrow b (pack_comp (C_Total (mk_arr_curried bs cod))))
let rec mk_tot_arr (bs: list binder) (cod : term) : Tac term =
match bs with
| [] -> cod
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr bs cod))))
let lookup_lb_view (lbs:list letbinding) (nm:name) : Tac lb_view =
let o = FStar.List.Tot.Base.find
(fun lb ->
let lbv = inspect_lb lb in
(inspect_fv lbv.lb_fv) = nm)
lbs
in
match o with
| Some lb -> inspect_lb lb
| None -> fail "lookup_lb_view: Name not in let group"
let rec inspect_unascribe (t:term) : Tac (tv:term_view{notAscription tv}) =
match inspect t with
| Tv_AscribedT t _ _ _
| Tv_AscribedC t _ _ _ ->
inspect_unascribe t
| tv -> tv
(* Helpers for dealing with nested applications and arrows *)
let rec collect_app' (args : list argv) (t : term) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 collect_app' (args: list argv) (t: term) : Tac (term * list argv) | [
"recursion"
] | FStar.Tactics.V1.SyntaxHelpers.collect_app' | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | args: Prims.list FStar.Reflection.V1.Data.argv -> t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(FStar.Reflection.Types.term * Prims.list FStar.Reflection.V1.Data.argv) | {
"end_col": 20,
"end_line": 93,
"start_col": 4,
"start_line": 90
} |
FStar.Tactics.Effect.Tac | val collect_arr' (bs: list binder) (c: comp) : Tac (list binder * comp) | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end | val collect_arr' (bs: list binder) (c: comp) : Tac (list binder * comp)
let rec collect_arr' (bs: list binder) (c: comp) : Tac (list binder * comp) = | true | null | false | match inspect_comp c with
| C_Total t ->
(match inspect t with
| Tv_Arrow b c -> collect_arr' (b :: bs) c
| _ -> (bs, c))
| _ -> (bs, c) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.comp",
"FStar.Reflection.V1.Builtins.inspect_comp",
"FStar.Reflection.Types.typ",
"FStar.Tactics.V1.SyntaxHelpers.collect_arr'",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V1.Data.term_view",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.V1.Builtins.inspect",
"FStar.Reflection.V1.Data.comp_view"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private | false | false | FStar.Tactics.V1.SyntaxHelpers.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 collect_arr' (bs: list binder) (c: comp) : Tac (list binder * comp) | [
"recursion"
] | FStar.Tactics.V1.SyntaxHelpers.collect_arr' | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Types.binder -> c: FStar.Reflection.Types.comp
-> FStar.Tactics.Effect.Tac
(Prims.list FStar.Reflection.Types.binder * FStar.Reflection.Types.comp) | {
"end_col": 18,
"end_line": 20,
"start_col": 10,
"start_line": 12
} |
FStar.Tactics.Effect.Tac | val collect_abs : term -> Tac (list binder * term) | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t') | val collect_abs : term -> Tac (list binder * term)
let collect_abs t = | true | null | false | let bs, t' = collect_abs' [] t in
(List.Tot.Base.rev bs, t') | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.Native.Mktuple2",
"FStar.List.Tot.Base.rev",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.V1.SyntaxHelpers.collect_abs'",
"Prims.Nil"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 collect_abs : term -> Tac (list binder * term) | [] | FStar.Tactics.V1.SyntaxHelpers.collect_abs | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(Prims.list FStar.Reflection.Types.binder * FStar.Reflection.Types.term) | {
"end_col": 30,
"end_line": 44,
"start_col": 19,
"start_line": 42
} |
FStar.Tactics.Effect.Tac | val collect_abs' (bs: list binder) (t: term) : Tac (list binder * term) (decreases t) | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t) | val collect_abs' (bs: list binder) (t: term) : Tac (list binder * term) (decreases t)
let rec collect_abs' (bs: list binder) (t: term) : Tac (list binder * term) (decreases t) = | true | null | false | match inspect t with
| Tv_Abs b t' -> collect_abs' (b :: bs) t'
| _ -> (bs, t) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [
""
] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.term",
"FStar.Tactics.V1.SyntaxHelpers.collect_abs'",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V1.Data.term_view",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.V1.Builtins.inspect"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private | false | false | FStar.Tactics.V1.SyntaxHelpers.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 collect_abs' (bs: list binder) (t: term) : Tac (list binder * term) (decreases t) | [
"recursion"
] | FStar.Tactics.V1.SyntaxHelpers.collect_abs' | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Types.binder -> t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(Prims.list FStar.Reflection.Types.binder * FStar.Reflection.Types.term) | {
"end_col": 18,
"end_line": 39,
"start_col": 4,
"start_line": 36
} |
FStar.Tactics.Effect.Tac | val mk_arr (bs: list binder) (cod: comp) : Tac term | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mk_arr (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack (Tv_Arrow b cod)
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_arr bs cod)))) | val mk_arr (bs: list binder) (cod: comp) : Tac term
let rec mk_arr (bs: list binder) (cod: comp) : Tac term = | true | null | false | match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack (Tv_Arrow b cod)
| b :: bs -> pack (Tv_Arrow b (pack_comp (C_Total (mk_arr bs cod)))) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.comp",
"FStar.Tactics.V1.SyntaxHelpers.fail",
"FStar.Reflection.Types.term",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_Arrow",
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.V1.Builtins.pack_comp",
"FStar.Reflection.V1.Data.comp_view",
"FStar.Reflection.V1.Data.C_Total",
"FStar.Reflection.Types.typ",
"FStar.Tactics.V1.SyntaxHelpers.mk_arr"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t)
val collect_abs : term -> Tac (list binder * term)
let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t')
(* Copied from FStar.Tactics.Derived *)
private
let fail (#a:Type) (m:string) = raise #a (TacticFailure m) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 mk_arr (bs: list binder) (cod: comp) : Tac term | [
"recursion"
] | FStar.Tactics.V1.SyntaxHelpers.mk_arr | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Types.binder -> cod: FStar.Reflection.Types.comp
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 61,
"end_line": 55,
"start_col": 4,
"start_line": 51
} |
FStar.Tactics.Effect.Tac | val lookup_lb_view (lbs: list letbinding) (nm: name) : Tac lb_view | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lookup_lb_view (lbs:list letbinding) (nm:name) : Tac lb_view =
let o = FStar.List.Tot.Base.find
(fun lb ->
let lbv = inspect_lb lb in
(inspect_fv lbv.lb_fv) = nm)
lbs
in
match o with
| Some lb -> inspect_lb lb
| None -> fail "lookup_lb_view: Name not in let group" | val lookup_lb_view (lbs: list letbinding) (nm: name) : Tac lb_view
let lookup_lb_view (lbs: list letbinding) (nm: name) : Tac lb_view = | true | null | false | let o =
FStar.List.Tot.Base.find (fun lb ->
let lbv = inspect_lb lb in
(inspect_fv lbv.lb_fv) = nm)
lbs
in
match o with
| Some lb -> inspect_lb lb
| None -> fail "lookup_lb_view: Name not in let group" | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.letbinding",
"FStar.Reflection.Types.name",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Reflection.V1.Builtins.inspect_fv",
"FStar.Reflection.V1.Data.__proj__Mklb_view__item__lb_fv",
"FStar.Reflection.V1.Builtins.inspect_lb",
"FStar.Reflection.V1.Data.lb_view",
"FStar.Tactics.V1.SyntaxHelpers.fail",
"FStar.Pervasives.Native.option",
"FStar.List.Tot.Base.find",
"Prims.precedes",
"Prims.bool"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t)
val collect_abs : term -> Tac (list binder * term)
let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t')
(* Copied from FStar.Tactics.Derived *)
private
let fail (#a:Type) (m:string) = raise #a (TacticFailure m)
let rec mk_arr (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack (Tv_Arrow b cod)
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_arr bs cod))))
let rec mk_arr_curried (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack_curried (Tv_Arrow b cod)
| (b::bs) -> pack_curried (Tv_Arrow b (pack_comp (C_Total (mk_arr_curried bs cod))))
let rec mk_tot_arr (bs: list binder) (cod : term) : Tac term =
match bs with
| [] -> cod
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr bs cod)))) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 lookup_lb_view (lbs: list letbinding) (nm: name) : Tac lb_view | [] | FStar.Tactics.V1.SyntaxHelpers.lookup_lb_view | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | lbs: Prims.list FStar.Reflection.Types.letbinding -> nm: FStar.Reflection.Types.name
-> FStar.Tactics.Effect.Tac FStar.Reflection.V1.Data.lb_view | {
"end_col": 56,
"end_line": 78,
"start_col": 66,
"start_line": 69
} |
FStar.Tactics.Effect.Tac | val mk_tot_arr (bs: list binder) (cod: term) : Tac term | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mk_tot_arr (bs: list binder) (cod : term) : Tac term =
match bs with
| [] -> cod
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr bs cod)))) | val mk_tot_arr (bs: list binder) (cod: term) : Tac term
let rec mk_tot_arr (bs: list binder) (cod: term) : Tac term = | true | null | false | match bs with
| [] -> cod
| b :: bs -> pack (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr bs cod)))) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.term",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.V1.Data.Tv_Arrow",
"FStar.Reflection.Types.comp",
"FStar.Reflection.V1.Builtins.pack_comp",
"FStar.Reflection.V1.Data.comp_view",
"FStar.Reflection.V1.Data.C_Total",
"FStar.Reflection.Types.typ",
"FStar.Tactics.V1.SyntaxHelpers.mk_tot_arr"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t)
val collect_abs : term -> Tac (list binder * term)
let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t')
(* Copied from FStar.Tactics.Derived *)
private
let fail (#a:Type) (m:string) = raise #a (TacticFailure m)
let rec mk_arr (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack (Tv_Arrow b cod)
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_arr bs cod))))
let rec mk_arr_curried (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack_curried (Tv_Arrow b cod)
| (b::bs) -> pack_curried (Tv_Arrow b (pack_comp (C_Total (mk_arr_curried bs cod)))) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 mk_tot_arr (bs: list binder) (cod: term) : Tac term | [
"recursion"
] | FStar.Tactics.V1.SyntaxHelpers.mk_tot_arr | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Types.binder -> cod: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 65,
"end_line": 67,
"start_col": 4,
"start_line": 64
} |
FStar.Tactics.Effect.Tac | val inspect_unascribe (t: term) : Tac (tv: term_view{notAscription tv}) | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec inspect_unascribe (t:term) : Tac (tv:term_view{notAscription tv}) =
match inspect t with
| Tv_AscribedT t _ _ _
| Tv_AscribedC t _ _ _ ->
inspect_unascribe t
| tv -> tv | val inspect_unascribe (t: term) : Tac (tv: term_view{notAscription tv})
let rec inspect_unascribe (t: term) : Tac (tv: term_view{notAscription tv}) = | true | null | false | match inspect t with
| Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> inspect_unascribe t
| tv -> tv | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Tactics.V1.SyntaxHelpers.inspect_unascribe",
"FStar.Reflection.V1.Data.term_view",
"Prims.b2t",
"FStar.Reflection.V1.Data.notAscription",
"FStar.Reflection.Types.comp",
"FStar.Tactics.V1.Builtins.inspect"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t)
val collect_abs : term -> Tac (list binder * term)
let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t')
(* Copied from FStar.Tactics.Derived *)
private
let fail (#a:Type) (m:string) = raise #a (TacticFailure m)
let rec mk_arr (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack (Tv_Arrow b cod)
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_arr bs cod))))
let rec mk_arr_curried (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack_curried (Tv_Arrow b cod)
| (b::bs) -> pack_curried (Tv_Arrow b (pack_comp (C_Total (mk_arr_curried bs cod))))
let rec mk_tot_arr (bs: list binder) (cod : term) : Tac term =
match bs with
| [] -> cod
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_tot_arr bs cod))))
let lookup_lb_view (lbs:list letbinding) (nm:name) : Tac lb_view =
let o = FStar.List.Tot.Base.find
(fun lb ->
let lbv = inspect_lb lb in
(inspect_fv lbv.lb_fv) = nm)
lbs
in
match o with
| Some lb -> inspect_lb lb
| None -> fail "lookup_lb_view: Name not in let group" | false | false | FStar.Tactics.V1.SyntaxHelpers.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 inspect_unascribe (t: term) : Tac (tv: term_view{notAscription tv}) | [
"recursion"
] | FStar.Tactics.V1.SyntaxHelpers.inspect_unascribe | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(tv: FStar.Reflection.V1.Data.term_view{FStar.Reflection.V1.Data.notAscription tv}) | {
"end_col": 12,
"end_line": 85,
"start_col": 2,
"start_line": 81
} |
FStar.Tactics.Effect.Tac | val mk_arr_curried (bs: list binder) (cod: comp) : Tac term | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V1",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mk_arr_curried (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack_curried (Tv_Arrow b cod)
| (b::bs) -> pack_curried (Tv_Arrow b (pack_comp (C_Total (mk_arr_curried bs cod)))) | val mk_arr_curried (bs: list binder) (cod: comp) : Tac term
let rec mk_arr_curried (bs: list binder) (cod: comp) : Tac term = | true | null | false | match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack_curried (Tv_Arrow b cod)
| b :: bs -> pack_curried (Tv_Arrow b (pack_comp (C_Total (mk_arr_curried bs cod)))) | {
"checked_file": "FStar.Tactics.V1.SyntaxHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V1.Builtins.fsti.checked",
"FStar.Tactics.Types.fsti.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V1.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.V1.SyntaxHelpers.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.comp",
"FStar.Tactics.V1.SyntaxHelpers.fail",
"FStar.Reflection.Types.term",
"FStar.Tactics.V1.Builtins.pack_curried",
"FStar.Reflection.V1.Data.Tv_Arrow",
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.V1.Builtins.pack_comp",
"FStar.Reflection.V1.Data.comp_view",
"FStar.Reflection.V1.Data.C_Total",
"FStar.Reflection.Types.typ",
"FStar.Tactics.V1.SyntaxHelpers.mk_arr_curried"
] | [] | module FStar.Tactics.V1.SyntaxHelpers
open FStar.Reflection.V1
open FStar.Tactics.Effect
open FStar.Tactics.V1.Builtins
open FStar.Tactics.Types
(* These are fully-named variants of functions found in FStar.Reflection *)
private
let rec collect_arr' (bs : list binder) (c : comp) : Tac (list binder * comp) =
begin match inspect_comp c with
| C_Total t ->
begin match inspect t with
| Tv_Arrow b c ->
collect_arr' (b::bs) c
| _ ->
(bs, c)
end
| _ -> (bs, c)
end
val collect_arr_bs : typ -> Tac (list binder * comp)
let collect_arr_bs t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
(List.Tot.Base.rev bs, c)
val collect_arr : typ -> Tac (list typ * comp)
let collect_arr t =
let (bs, c) = collect_arr' [] (pack_comp (C_Total t)) in
let ts = List.Tot.Base.map type_of_binder bs in
(List.Tot.Base.rev ts, c)
private
let rec collect_abs' (bs : list binder) (t : term) : Tac (list binder * term) (decreases t) =
match inspect t with
| Tv_Abs b t' ->
collect_abs' (b::bs) t'
| _ -> (bs, t)
val collect_abs : term -> Tac (list binder * term)
let collect_abs t =
let (bs, t') = collect_abs' [] t in
(List.Tot.Base.rev bs, t')
(* Copied from FStar.Tactics.Derived *)
private
let fail (#a:Type) (m:string) = raise #a (TacticFailure m)
let rec mk_arr (bs: list binder) (cod : comp) : Tac term =
match bs with
| [] -> fail "mk_arr, empty binders"
| [b] -> pack (Tv_Arrow b cod)
| (b::bs) ->
pack (Tv_Arrow b (pack_comp (C_Total (mk_arr bs cod)))) | false | false | FStar.Tactics.V1.SyntaxHelpers.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 mk_arr_curried (bs: list binder) (cod: comp) : Tac term | [
"recursion"
] | FStar.Tactics.V1.SyntaxHelpers.mk_arr_curried | {
"file_name": "ulib/FStar.Tactics.V1.SyntaxHelpers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Types.binder -> cod: FStar.Reflection.Types.comp
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 88,
"end_line": 61,
"start_col": 4,
"start_line": 58
} |
FStar.Pervasives.Lemma | val uint_t_uint_to_t_v (#tot #t: _) (cl: uint_t tot t) (x: t)
: Lemma (cl.uint_to_t (cl.v x) == x) [SMTPat (cl.uint_to_t (cl.v x))] | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_t_uint_to_t_v #tot #t (cl: uint_t tot t) (x: t) : Lemma
(cl.uint_to_t (cl.v x) == x)
[SMTPat (cl.uint_to_t (cl.v x))]
= cl.uint_to_t_v x | val uint_t_uint_to_t_v (#tot #t: _) (cl: uint_t tot t) (x: t)
: Lemma (cl.uint_to_t (cl.v x) == x) [SMTPat (cl.uint_to_t (cl.v x))]
let uint_t_uint_to_t_v #tot #t (cl: uint_t tot t) (x: t)
: Lemma (cl.uint_to_t (cl.v x) == x) [SMTPat (cl.uint_to_t (cl.v x))] = | false | null | true | cl.uint_to_t_v x | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"LowParse.BitFields.uint_t",
"LowParse.BitFields.__proj__Mkuint_t__item__uint_to_t_v",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"LowParse.BitFields.__proj__Mkuint_t__item__uint_to_t",
"LowParse.BitFields.__proj__Mkuint_t__item__v",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi
val get_bitfield_partition
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Lemma
(requires (get_bitfield_partition_prop x y lo hi l))
(ensures (get_bitfield x lo hi == get_bitfield y lo hi))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
))
(ensures (x == y))
= assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]); // does not need fuel, thanks to normalization
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y
val get_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
: Lemma
(x < pow2 tot2 /\ (get_bitfield #tot1 x lo hi <: nat) == (get_bitfield #tot2 x lo hi <: nat))
val set_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
(v: ubitfield tot1 (hi - lo))
: Lemma
(x < pow2 tot2 /\ v < pow2 tot2 /\ (set_bitfield #tot1 x lo hi v <: nat) == (set_bitfield #tot2 x lo hi v <: nat))
val set_bitfield_bound
(#tot: pos)
(x: U.uint_t tot)
(bound: nat { bound <= tot /\ x < pow2 bound })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= bound })
(v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v < pow2 bound)
val set_bitfield_set_bitfield_get_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= hi - lo }) (v' : ubitfield tot (hi' - lo'))
: Lemma
( let v = set_bitfield (get_bitfield x lo hi) lo' hi' v' in
v < pow2 (hi - lo) /\
set_bitfield x lo hi v == set_bitfield x (lo + lo') (lo + hi') v' )
val get_bitfield_eq
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield x lo hi == (x / pow2 lo) % pow2 (hi - lo))
val get_bitfield_eq_2
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield x lo hi == (x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo))
val set_bitfield_eq
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v == (x `U.logand` U.lognot ((U.lognot 0 `U.shift_right` (tot - (hi - lo))) `U.shift_left` lo)) `U.logor` (v `U.shift_left` lo))
module U32 = FStar.UInt32
inline_for_extraction
noextract
noeq
type uint_t (tot: pos) (t: Type) = {
v: (t -> Tot (U.uint_t tot));
uint_to_t: (U.uint_t tot -> Tot t);
v_uint_to_t: ((x: U.uint_t tot) -> Lemma (v (uint_to_t x) == x));
uint_to_t_v: ((x: t) -> Lemma (uint_to_t (v x) == x));
get_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) (U32.v lo) (U32.v hi) }));
set_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> (z: t { v z < pow2 (U32.v hi - U32.v lo) }) -> Tot (y : t { v y == set_bitfield (v x) (U32.v lo) (U32.v hi) (v z)}));
get_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) lo hi }));
set_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y : t { v y == set_bitfield (v x) lo hi (v z)}));
logor: ((x: t) -> (y: t) -> Tot (z: t { v z == v x `U.logor` v y }));
bitfield_eq_lhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot t);
bitfield_eq_rhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y: t { bitfield_eq_lhs x lo hi == y <==> (get_bitfield x lo hi <: t) == z }));
}
inline_for_extraction
let bitfield (#tot: pos) (#t: Type) (cl: uint_t tot t) (sz: nat { sz <= tot }) : Tot Type =
(x: t { cl.v x < pow2 sz })
let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot) : Lemma
(cl.v (cl.uint_to_t x) == x)
[SMTPat (cl.v (cl.uint_to_t x))]
= cl.v_uint_to_t x
let uint_t_uint_to_t_v #tot #t (cl: uint_t tot t) (x: t) : Lemma
(cl.uint_to_t (cl.v x) == x) | false | false | LowParse.BitFields.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 uint_t_uint_to_t_v (#tot #t: _) (cl: uint_t tot t) (x: t)
: Lemma (cl.uint_to_t (cl.v x) == x) [SMTPat (cl.uint_to_t (cl.v x))] | [] | LowParse.BitFields.uint_t_uint_to_t_v | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | cl: LowParse.BitFields.uint_t tot t -> x: t
-> FStar.Pervasives.Lemma (ensures Mkuint_t?.uint_to_t cl (Mkuint_t?.v cl x) == x)
[SMTPat (Mkuint_t?.uint_to_t cl (Mkuint_t?.v cl x))] | {
"end_col": 18,
"end_line": 289,
"start_col": 2,
"start_line": 289
} |
FStar.Pervasives.Lemma | val uint_t_v_uint_to_t (#tot #t: _) (cl: uint_t tot t) (x: U.uint_t tot)
: Lemma (cl.v (cl.uint_to_t x) == x) [SMTPat (cl.v (cl.uint_to_t x))] | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot) : Lemma
(cl.v (cl.uint_to_t x) == x)
[SMTPat (cl.v (cl.uint_to_t x))]
= cl.v_uint_to_t x | val uint_t_v_uint_to_t (#tot #t: _) (cl: uint_t tot t) (x: U.uint_t tot)
: Lemma (cl.v (cl.uint_to_t x) == x) [SMTPat (cl.v (cl.uint_to_t x))]
let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot)
: Lemma (cl.v (cl.uint_to_t x) == x) [SMTPat (cl.v (cl.uint_to_t x))] = | false | null | true | cl.v_uint_to_t x | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"LowParse.BitFields.uint_t",
"FStar.UInt.uint_t",
"LowParse.BitFields.__proj__Mkuint_t__item__v_uint_to_t",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"LowParse.BitFields.__proj__Mkuint_t__item__v",
"LowParse.BitFields.__proj__Mkuint_t__item__uint_to_t",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi
val get_bitfield_partition
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Lemma
(requires (get_bitfield_partition_prop x y lo hi l))
(ensures (get_bitfield x lo hi == get_bitfield y lo hi))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
))
(ensures (x == y))
= assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]); // does not need fuel, thanks to normalization
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y
val get_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
: Lemma
(x < pow2 tot2 /\ (get_bitfield #tot1 x lo hi <: nat) == (get_bitfield #tot2 x lo hi <: nat))
val set_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
(v: ubitfield tot1 (hi - lo))
: Lemma
(x < pow2 tot2 /\ v < pow2 tot2 /\ (set_bitfield #tot1 x lo hi v <: nat) == (set_bitfield #tot2 x lo hi v <: nat))
val set_bitfield_bound
(#tot: pos)
(x: U.uint_t tot)
(bound: nat { bound <= tot /\ x < pow2 bound })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= bound })
(v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v < pow2 bound)
val set_bitfield_set_bitfield_get_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= hi - lo }) (v' : ubitfield tot (hi' - lo'))
: Lemma
( let v = set_bitfield (get_bitfield x lo hi) lo' hi' v' in
v < pow2 (hi - lo) /\
set_bitfield x lo hi v == set_bitfield x (lo + lo') (lo + hi') v' )
val get_bitfield_eq
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield x lo hi == (x / pow2 lo) % pow2 (hi - lo))
val get_bitfield_eq_2
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield x lo hi == (x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo))
val set_bitfield_eq
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v == (x `U.logand` U.lognot ((U.lognot 0 `U.shift_right` (tot - (hi - lo))) `U.shift_left` lo)) `U.logor` (v `U.shift_left` lo))
module U32 = FStar.UInt32
inline_for_extraction
noextract
noeq
type uint_t (tot: pos) (t: Type) = {
v: (t -> Tot (U.uint_t tot));
uint_to_t: (U.uint_t tot -> Tot t);
v_uint_to_t: ((x: U.uint_t tot) -> Lemma (v (uint_to_t x) == x));
uint_to_t_v: ((x: t) -> Lemma (uint_to_t (v x) == x));
get_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) (U32.v lo) (U32.v hi) }));
set_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> (z: t { v z < pow2 (U32.v hi - U32.v lo) }) -> Tot (y : t { v y == set_bitfield (v x) (U32.v lo) (U32.v hi) (v z)}));
get_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) lo hi }));
set_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y : t { v y == set_bitfield (v x) lo hi (v z)}));
logor: ((x: t) -> (y: t) -> Tot (z: t { v z == v x `U.logor` v y }));
bitfield_eq_lhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot t);
bitfield_eq_rhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y: t { bitfield_eq_lhs x lo hi == y <==> (get_bitfield x lo hi <: t) == z }));
}
inline_for_extraction
let bitfield (#tot: pos) (#t: Type) (cl: uint_t tot t) (sz: nat { sz <= tot }) : Tot Type =
(x: t { cl.v x < pow2 sz })
let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot) : Lemma
(cl.v (cl.uint_to_t x) == x) | false | false | LowParse.BitFields.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 uint_t_v_uint_to_t (#tot #t: _) (cl: uint_t tot t) (x: U.uint_t tot)
: Lemma (cl.v (cl.uint_to_t x) == x) [SMTPat (cl.v (cl.uint_to_t x))] | [] | LowParse.BitFields.uint_t_v_uint_to_t | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | cl: LowParse.BitFields.uint_t tot t -> x: FStar.UInt.uint_t tot
-> FStar.Pervasives.Lemma (ensures Mkuint_t?.v cl (Mkuint_t?.uint_to_t cl x) == x)
[SMTPat (Mkuint_t?.v cl (Mkuint_t?.uint_to_t cl x))] | {
"end_col": 18,
"end_line": 284,
"start_col": 2,
"start_line": 284
} |
FStar.Pervasives.Lemma | val set_bitfield_set_bitfield_same
(#tot: pos)
(x: U.uint_t tot)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(v v': ubitfield tot (hi - lo))
: Lemma (ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v')) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v' | val set_bitfield_set_bitfield_same
(#tot: pos)
(x: U.uint_t tot)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(v v': ubitfield tot (hi - lo))
: Lemma (ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
let set_bitfield_set_bitfield_same
(#tot: pos)
(x: U.uint_t tot)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(v v': ubitfield tot (hi - lo))
: Lemma (ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v')) = | false | null | true | set_bitfield_set_bitfield_same_gen x lo hi v lo hi v' | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.BitFields.ubitfield",
"Prims.op_Subtraction",
"LowParse.BitFields.set_bitfield_set_bitfield_same_gen",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"LowParse.BitFields.set_bitfield",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma | false | false | LowParse.BitFields.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 set_bitfield_set_bitfield_same
(#tot: pos)
(x: U.uint_t tot)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(v v': ubitfield tot (hi - lo))
: Lemma (ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v')) | [] | LowParse.BitFields.set_bitfield_set_bitfield_same | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
x: FStar.UInt.uint_t tot ->
lo: Prims.nat ->
hi: Prims.nat{lo <= hi /\ hi <= tot} ->
v: LowParse.BitFields.ubitfield tot (hi - lo) ->
v': LowParse.BitFields.ubitfield tot (hi - lo)
-> FStar.Pervasives.Lemma
(ensures
LowParse.BitFields.set_bitfield (LowParse.BitFields.set_bitfield x lo hi v) lo hi v' ==
LowParse.BitFields.set_bitfield x lo hi v') | {
"end_col": 55,
"end_line": 56,
"start_col": 2,
"start_line": 56
} |
Prims.Tot | val get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(l: list nat)
: Tot bool (decreases l) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi | val get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(l: list nat)
: Tot bool (decreases l)
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(l: list nat)
: Tot bool (decreases l) = | false | null | false | match l with
| [] -> get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi && get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"total",
""
] | [
"Prims.pos",
"FStar.UInt.uint_t",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.list",
"Prims.op_Equality",
"LowParse.BitFields.ubitfield",
"Prims.op_Subtraction",
"LowParse.BitFields.get_bitfield",
"Prims.op_AmpAmp",
"LowParse.BitFields.get_bitfield_partition_prop",
"Prims.bool"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool | false | false | LowParse.BitFields.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 get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(l: list nat)
: Tot bool (decreases l) | [
"recursion"
] | LowParse.BitFields.get_bitfield_partition_prop | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
x: FStar.UInt.uint_t tot ->
y: FStar.UInt.uint_t tot ->
lo: Prims.nat ->
hi: Prims.nat{lo <= hi /\ hi <= tot} ->
l: Prims.list Prims.nat
-> Prims.Tot Prims.bool | {
"end_col": 47,
"end_line": 176,
"start_col": 2,
"start_line": 170
} |
FStar.Pervasives.Lemma | val get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(x y: U.uint_t tot)
: Lemma
(requires
(get_bitfield x 0 lo == get_bitfield y 0 lo /\ get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot)) (ensures (x == y)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
))
(ensures (x == y))
= assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]); // does not need fuel, thanks to normalization
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y | val get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(x y: U.uint_t tot)
: Lemma
(requires
(get_bitfield x 0 lo == get_bitfield y 0 lo /\ get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot)) (ensures (x == y))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(x y: U.uint_t tot)
: Lemma
(requires
(get_bitfield x 0 lo == get_bitfield y 0 lo /\ get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot)) (ensures (x == y)) = | false | null | true | assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]);
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt.uint_t",
"LowParse.BitFields.get_bitfield_full",
"Prims.unit",
"LowParse.BitFields.get_bitfield_partition",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"LowParse.BitFields.get_bitfield_partition_prop",
"Prims.eq2",
"LowParse.BitFields.ubitfield",
"Prims.op_Subtraction",
"LowParse.BitFields.get_bitfield",
"Prims.squash",
"FStar.Pervasives.pattern"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi
val get_bitfield_partition
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Lemma
(requires (get_bitfield_partition_prop x y lo hi l))
(ensures (get_bitfield x lo hi == get_bitfield y lo hi))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
)) | false | false | LowParse.BitFields.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 get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(x y: U.uint_t tot)
: Lemma
(requires
(get_bitfield x 0 lo == get_bitfield y 0 lo /\ get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot)) (ensures (x == y)) | [] | LowParse.BitFields.get_bitfield_partition_3 | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
lo: Prims.nat ->
hi: Prims.nat{lo <= hi /\ hi <= tot} ->
x: FStar.UInt.uint_t tot ->
y: FStar.UInt.uint_t tot
-> FStar.Pervasives.Lemma
(requires
LowParse.BitFields.get_bitfield x 0 lo == LowParse.BitFields.get_bitfield y 0 lo /\
LowParse.BitFields.get_bitfield x lo hi == LowParse.BitFields.get_bitfield y lo hi /\
LowParse.BitFields.get_bitfield x hi tot == LowParse.BitFields.get_bitfield y hi tot)
(ensures x == y) | {
"end_col": 21,
"end_line": 203,
"start_col": 2,
"start_line": 200
} |
FStar.Pervasives.Lemma | val uint_get_bitfield_set_bitfield_same
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
: Lemma (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)] | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_get_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)]
= get_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z);
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)) == cl.uint_to_t (cl.v z)) | val uint_get_bitfield_set_bitfield_same
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
: Lemma (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)]
let uint_get_bitfield_set_bitfield_same
#tot
#t
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
: Lemma (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)] = | false | null | true | get_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z);
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)) ==
cl.uint_to_t (cl.v z)) | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"LowParse.BitFields.uint_t",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.BitFields.bitfield",
"Prims.op_Subtraction",
"Prims._assert",
"Prims.eq2",
"LowParse.BitFields.__proj__Mkuint_t__item__uint_to_t",
"LowParse.BitFields.__proj__Mkuint_t__item__v",
"LowParse.BitFields.__proj__Mkuint_t__item__get_bitfield",
"LowParse.BitFields.__proj__Mkuint_t__item__set_bitfield",
"Prims.unit",
"LowParse.BitFields.get_bitfield_set_bitfield_same",
"Prims.l_True",
"Prims.squash",
"Prims.l_or",
"FStar.UInt.uint_t",
"LowParse.BitFields.get_bitfield",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi
val get_bitfield_partition
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Lemma
(requires (get_bitfield_partition_prop x y lo hi l))
(ensures (get_bitfield x lo hi == get_bitfield y lo hi))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
))
(ensures (x == y))
= assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]); // does not need fuel, thanks to normalization
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y
val get_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
: Lemma
(x < pow2 tot2 /\ (get_bitfield #tot1 x lo hi <: nat) == (get_bitfield #tot2 x lo hi <: nat))
val set_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
(v: ubitfield tot1 (hi - lo))
: Lemma
(x < pow2 tot2 /\ v < pow2 tot2 /\ (set_bitfield #tot1 x lo hi v <: nat) == (set_bitfield #tot2 x lo hi v <: nat))
val set_bitfield_bound
(#tot: pos)
(x: U.uint_t tot)
(bound: nat { bound <= tot /\ x < pow2 bound })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= bound })
(v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v < pow2 bound)
val set_bitfield_set_bitfield_get_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= hi - lo }) (v' : ubitfield tot (hi' - lo'))
: Lemma
( let v = set_bitfield (get_bitfield x lo hi) lo' hi' v' in
v < pow2 (hi - lo) /\
set_bitfield x lo hi v == set_bitfield x (lo + lo') (lo + hi') v' )
val get_bitfield_eq
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield x lo hi == (x / pow2 lo) % pow2 (hi - lo))
val get_bitfield_eq_2
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield x lo hi == (x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo))
val set_bitfield_eq
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v == (x `U.logand` U.lognot ((U.lognot 0 `U.shift_right` (tot - (hi - lo))) `U.shift_left` lo)) `U.logor` (v `U.shift_left` lo))
module U32 = FStar.UInt32
inline_for_extraction
noextract
noeq
type uint_t (tot: pos) (t: Type) = {
v: (t -> Tot (U.uint_t tot));
uint_to_t: (U.uint_t tot -> Tot t);
v_uint_to_t: ((x: U.uint_t tot) -> Lemma (v (uint_to_t x) == x));
uint_to_t_v: ((x: t) -> Lemma (uint_to_t (v x) == x));
get_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) (U32.v lo) (U32.v hi) }));
set_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> (z: t { v z < pow2 (U32.v hi - U32.v lo) }) -> Tot (y : t { v y == set_bitfield (v x) (U32.v lo) (U32.v hi) (v z)}));
get_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) lo hi }));
set_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y : t { v y == set_bitfield (v x) lo hi (v z)}));
logor: ((x: t) -> (y: t) -> Tot (z: t { v z == v x `U.logor` v y }));
bitfield_eq_lhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot t);
bitfield_eq_rhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y: t { bitfield_eq_lhs x lo hi == y <==> (get_bitfield x lo hi <: t) == z }));
}
inline_for_extraction
let bitfield (#tot: pos) (#t: Type) (cl: uint_t tot t) (sz: nat { sz <= tot }) : Tot Type =
(x: t { cl.v x < pow2 sz })
let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot) : Lemma
(cl.v (cl.uint_to_t x) == x)
[SMTPat (cl.v (cl.uint_to_t x))]
= cl.v_uint_to_t x
let uint_t_uint_to_t_v #tot #t (cl: uint_t tot t) (x: t) : Lemma
(cl.uint_to_t (cl.v x) == x)
[SMTPat (cl.uint_to_t (cl.v x))]
= cl.uint_to_t_v x
let uint_get_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z) | false | false | LowParse.BitFields.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 uint_get_bitfield_set_bitfield_same
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
: Lemma (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)] | [] | LowParse.BitFields.uint_get_bitfield_set_bitfield_same | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cl: LowParse.BitFields.uint_t tot t ->
x: t ->
lo: Prims.nat ->
hi: Prims.nat{lo <= hi /\ hi <= tot} ->
z: LowParse.BitFields.bitfield cl (hi - lo)
-> FStar.Pervasives.Lemma
(ensures Mkuint_t?.get_bitfield cl (Mkuint_t?.set_bitfield cl x lo hi z) lo hi == z)
[SMTPat (Mkuint_t?.get_bitfield cl (Mkuint_t?.set_bitfield cl x lo hi z) lo hi)] | {
"end_col": 107,
"end_line": 298,
"start_col": 2,
"start_line": 297
} |
FStar.Pervasives.Lemma | val uint_set_bitfield_set_bitfield_same
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z z': bitfield cl (hi - lo))
: Lemma (cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z' == cl.set_bitfield x lo hi z') | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_set_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(z' : bitfield cl (hi - lo))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z' == cl.set_bitfield x lo hi z')
= set_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z) (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z')) == cl.uint_to_t (cl.v (cl.set_bitfield x lo hi z'))) | val uint_set_bitfield_set_bitfield_same
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z z': bitfield cl (hi - lo))
: Lemma (cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z' == cl.set_bitfield x lo hi z')
let uint_set_bitfield_set_bitfield_same
#tot
#t
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(z': bitfield cl (hi - lo))
: Lemma (cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z' == cl.set_bitfield x lo hi z') = | false | null | true | set_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z) (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z')) ==
cl.uint_to_t (cl.v (cl.set_bitfield x lo hi z'))) | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"LowParse.BitFields.uint_t",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.BitFields.bitfield",
"Prims.op_Subtraction",
"Prims._assert",
"Prims.eq2",
"LowParse.BitFields.__proj__Mkuint_t__item__uint_to_t",
"LowParse.BitFields.__proj__Mkuint_t__item__v",
"LowParse.BitFields.__proj__Mkuint_t__item__set_bitfield",
"Prims.unit",
"LowParse.BitFields.set_bitfield_set_bitfield_same",
"Prims.l_True",
"Prims.squash",
"Prims.l_or",
"FStar.UInt.uint_t",
"LowParse.BitFields.set_bitfield",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi
val get_bitfield_partition
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Lemma
(requires (get_bitfield_partition_prop x y lo hi l))
(ensures (get_bitfield x lo hi == get_bitfield y lo hi))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
))
(ensures (x == y))
= assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]); // does not need fuel, thanks to normalization
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y
val get_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
: Lemma
(x < pow2 tot2 /\ (get_bitfield #tot1 x lo hi <: nat) == (get_bitfield #tot2 x lo hi <: nat))
val set_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
(v: ubitfield tot1 (hi - lo))
: Lemma
(x < pow2 tot2 /\ v < pow2 tot2 /\ (set_bitfield #tot1 x lo hi v <: nat) == (set_bitfield #tot2 x lo hi v <: nat))
val set_bitfield_bound
(#tot: pos)
(x: U.uint_t tot)
(bound: nat { bound <= tot /\ x < pow2 bound })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= bound })
(v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v < pow2 bound)
val set_bitfield_set_bitfield_get_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= hi - lo }) (v' : ubitfield tot (hi' - lo'))
: Lemma
( let v = set_bitfield (get_bitfield x lo hi) lo' hi' v' in
v < pow2 (hi - lo) /\
set_bitfield x lo hi v == set_bitfield x (lo + lo') (lo + hi') v' )
val get_bitfield_eq
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield x lo hi == (x / pow2 lo) % pow2 (hi - lo))
val get_bitfield_eq_2
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield x lo hi == (x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo))
val set_bitfield_eq
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v == (x `U.logand` U.lognot ((U.lognot 0 `U.shift_right` (tot - (hi - lo))) `U.shift_left` lo)) `U.logor` (v `U.shift_left` lo))
module U32 = FStar.UInt32
inline_for_extraction
noextract
noeq
type uint_t (tot: pos) (t: Type) = {
v: (t -> Tot (U.uint_t tot));
uint_to_t: (U.uint_t tot -> Tot t);
v_uint_to_t: ((x: U.uint_t tot) -> Lemma (v (uint_to_t x) == x));
uint_to_t_v: ((x: t) -> Lemma (uint_to_t (v x) == x));
get_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) (U32.v lo) (U32.v hi) }));
set_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> (z: t { v z < pow2 (U32.v hi - U32.v lo) }) -> Tot (y : t { v y == set_bitfield (v x) (U32.v lo) (U32.v hi) (v z)}));
get_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) lo hi }));
set_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y : t { v y == set_bitfield (v x) lo hi (v z)}));
logor: ((x: t) -> (y: t) -> Tot (z: t { v z == v x `U.logor` v y }));
bitfield_eq_lhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot t);
bitfield_eq_rhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y: t { bitfield_eq_lhs x lo hi == y <==> (get_bitfield x lo hi <: t) == z }));
}
inline_for_extraction
let bitfield (#tot: pos) (#t: Type) (cl: uint_t tot t) (sz: nat { sz <= tot }) : Tot Type =
(x: t { cl.v x < pow2 sz })
let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot) : Lemma
(cl.v (cl.uint_to_t x) == x)
[SMTPat (cl.v (cl.uint_to_t x))]
= cl.v_uint_to_t x
let uint_t_uint_to_t_v #tot #t (cl: uint_t tot t) (x: t) : Lemma
(cl.uint_to_t (cl.v x) == x)
[SMTPat (cl.uint_to_t (cl.v x))]
= cl.uint_to_t_v x
let uint_get_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)]
= get_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z);
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)) == cl.uint_to_t (cl.v z))
let uint_get_bitfield_set_bitfield_other
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo') })
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi')
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')]
= get_bitfield_set_bitfield_other (cl.v x) lo hi (cl.v z) lo' hi';
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')) == cl.uint_to_t (cl.v (cl.get_bitfield x lo' hi')))
let uint_set_bitfield_set_bitfield_same_gen
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo': nat) (hi': nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot }) (z' : bitfield cl (hi' - lo'))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' == cl.set_bitfield x lo' hi' z')
= set_bitfield_set_bitfield_same_gen (cl.v x) lo hi (cl.v z) lo' hi' (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z')) == cl.uint_to_t (cl.v (cl.set_bitfield x lo' hi' z')))
let uint_set_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(z' : bitfield cl (hi - lo))
: Lemma | false | false | LowParse.BitFields.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 uint_set_bitfield_set_bitfield_same
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z z': bitfield cl (hi - lo))
: Lemma (cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z' == cl.set_bitfield x lo hi z') | [] | LowParse.BitFields.uint_set_bitfield_set_bitfield_same | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cl: LowParse.BitFields.uint_t tot t ->
x: t ->
lo: Prims.nat ->
hi: Prims.nat{lo <= hi /\ hi <= tot} ->
z: LowParse.BitFields.bitfield cl (hi - lo) ->
z': LowParse.BitFields.bitfield cl (hi - lo)
-> FStar.Pervasives.Lemma
(ensures
Mkuint_t?.set_bitfield cl (Mkuint_t?.set_bitfield cl x lo hi z) lo hi z' ==
Mkuint_t?.set_bitfield cl x lo hi z') | {
"end_col": 137,
"end_line": 326,
"start_col": 2,
"start_line": 325
} |
FStar.Pervasives.Lemma | val uint_get_bitfield_set_bitfield_other
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')})
: Lemma (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi')
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')] | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_get_bitfield_set_bitfield_other
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo') })
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi')
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')]
= get_bitfield_set_bitfield_other (cl.v x) lo hi (cl.v z) lo' hi';
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')) == cl.uint_to_t (cl.v (cl.get_bitfield x lo' hi'))) | val uint_get_bitfield_set_bitfield_other
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')})
: Lemma (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi')
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')]
let uint_get_bitfield_set_bitfield_other
#tot
#t
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')})
: Lemma (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi')
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')] = | false | null | true | get_bitfield_set_bitfield_other (cl.v x) lo hi (cl.v z) lo' hi';
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')) ==
cl.uint_to_t (cl.v (cl.get_bitfield x lo' hi'))) | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"LowParse.BitFields.uint_t",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.BitFields.bitfield",
"Prims.op_Subtraction",
"Prims.l_or",
"Prims._assert",
"Prims.eq2",
"LowParse.BitFields.__proj__Mkuint_t__item__uint_to_t",
"LowParse.BitFields.__proj__Mkuint_t__item__v",
"LowParse.BitFields.__proj__Mkuint_t__item__get_bitfield",
"LowParse.BitFields.__proj__Mkuint_t__item__set_bitfield",
"Prims.unit",
"LowParse.BitFields.get_bitfield_set_bitfield_other",
"Prims.l_True",
"Prims.squash",
"FStar.UInt.uint_t",
"LowParse.BitFields.get_bitfield",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi
val get_bitfield_partition
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Lemma
(requires (get_bitfield_partition_prop x y lo hi l))
(ensures (get_bitfield x lo hi == get_bitfield y lo hi))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
))
(ensures (x == y))
= assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]); // does not need fuel, thanks to normalization
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y
val get_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
: Lemma
(x < pow2 tot2 /\ (get_bitfield #tot1 x lo hi <: nat) == (get_bitfield #tot2 x lo hi <: nat))
val set_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
(v: ubitfield tot1 (hi - lo))
: Lemma
(x < pow2 tot2 /\ v < pow2 tot2 /\ (set_bitfield #tot1 x lo hi v <: nat) == (set_bitfield #tot2 x lo hi v <: nat))
val set_bitfield_bound
(#tot: pos)
(x: U.uint_t tot)
(bound: nat { bound <= tot /\ x < pow2 bound })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= bound })
(v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v < pow2 bound)
val set_bitfield_set_bitfield_get_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= hi - lo }) (v' : ubitfield tot (hi' - lo'))
: Lemma
( let v = set_bitfield (get_bitfield x lo hi) lo' hi' v' in
v < pow2 (hi - lo) /\
set_bitfield x lo hi v == set_bitfield x (lo + lo') (lo + hi') v' )
val get_bitfield_eq
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield x lo hi == (x / pow2 lo) % pow2 (hi - lo))
val get_bitfield_eq_2
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield x lo hi == (x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo))
val set_bitfield_eq
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v == (x `U.logand` U.lognot ((U.lognot 0 `U.shift_right` (tot - (hi - lo))) `U.shift_left` lo)) `U.logor` (v `U.shift_left` lo))
module U32 = FStar.UInt32
inline_for_extraction
noextract
noeq
type uint_t (tot: pos) (t: Type) = {
v: (t -> Tot (U.uint_t tot));
uint_to_t: (U.uint_t tot -> Tot t);
v_uint_to_t: ((x: U.uint_t tot) -> Lemma (v (uint_to_t x) == x));
uint_to_t_v: ((x: t) -> Lemma (uint_to_t (v x) == x));
get_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) (U32.v lo) (U32.v hi) }));
set_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> (z: t { v z < pow2 (U32.v hi - U32.v lo) }) -> Tot (y : t { v y == set_bitfield (v x) (U32.v lo) (U32.v hi) (v z)}));
get_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) lo hi }));
set_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y : t { v y == set_bitfield (v x) lo hi (v z)}));
logor: ((x: t) -> (y: t) -> Tot (z: t { v z == v x `U.logor` v y }));
bitfield_eq_lhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot t);
bitfield_eq_rhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y: t { bitfield_eq_lhs x lo hi == y <==> (get_bitfield x lo hi <: t) == z }));
}
inline_for_extraction
let bitfield (#tot: pos) (#t: Type) (cl: uint_t tot t) (sz: nat { sz <= tot }) : Tot Type =
(x: t { cl.v x < pow2 sz })
let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot) : Lemma
(cl.v (cl.uint_to_t x) == x)
[SMTPat (cl.v (cl.uint_to_t x))]
= cl.v_uint_to_t x
let uint_t_uint_to_t_v #tot #t (cl: uint_t tot t) (x: t) : Lemma
(cl.uint_to_t (cl.v x) == x)
[SMTPat (cl.uint_to_t (cl.v x))]
= cl.uint_to_t_v x
let uint_get_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)]
= get_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z);
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)) == cl.uint_to_t (cl.v z))
let uint_get_bitfield_set_bitfield_other
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo') })
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi') | false | false | LowParse.BitFields.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 uint_get_bitfield_set_bitfield_other
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')})
: Lemma (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi')
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')] | [] | LowParse.BitFields.uint_get_bitfield_set_bitfield_other | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cl: LowParse.BitFields.uint_t tot t ->
x: t ->
lo: Prims.nat ->
hi: Prims.nat{lo <= hi /\ hi <= tot} ->
z: LowParse.BitFields.bitfield cl (hi - lo) ->
lo': Prims.nat ->
hi': Prims.nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')}
-> FStar.Pervasives.Lemma
(ensures
Mkuint_t?.get_bitfield cl (Mkuint_t?.set_bitfield cl x lo hi z) lo' hi' ==
Mkuint_t?.get_bitfield cl x lo' hi')
[SMTPat (Mkuint_t?.get_bitfield cl (Mkuint_t?.set_bitfield cl x lo hi z) lo' hi')] | {
"end_col": 135,
"end_line": 308,
"start_col": 2,
"start_line": 307
} |
FStar.Pervasives.Lemma | val uint_set_bitfield_set_bitfield_same_gen
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= lo /\ hi <= hi' /\ hi' <= tot})
(z': bitfield cl (hi' - lo'))
: Lemma (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' == cl.set_bitfield x lo' hi' z') | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_set_bitfield_set_bitfield_same_gen
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo': nat) (hi': nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot }) (z' : bitfield cl (hi' - lo'))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' == cl.set_bitfield x lo' hi' z')
= set_bitfield_set_bitfield_same_gen (cl.v x) lo hi (cl.v z) lo' hi' (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z')) == cl.uint_to_t (cl.v (cl.set_bitfield x lo' hi' z'))) | val uint_set_bitfield_set_bitfield_same_gen
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= lo /\ hi <= hi' /\ hi' <= tot})
(z': bitfield cl (hi' - lo'))
: Lemma (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' == cl.set_bitfield x lo' hi' z')
let uint_set_bitfield_set_bitfield_same_gen
#tot
#t
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= lo /\ hi <= hi' /\ hi' <= tot})
(z': bitfield cl (hi' - lo'))
: Lemma (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' == cl.set_bitfield x lo' hi' z') = | false | null | true | set_bitfield_set_bitfield_same_gen (cl.v x) lo hi (cl.v z) lo' hi' (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z')) ==
cl.uint_to_t (cl.v (cl.set_bitfield x lo' hi' z'))) | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"LowParse.BitFields.uint_t",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.BitFields.bitfield",
"Prims.op_Subtraction",
"Prims._assert",
"Prims.eq2",
"LowParse.BitFields.__proj__Mkuint_t__item__uint_to_t",
"LowParse.BitFields.__proj__Mkuint_t__item__v",
"LowParse.BitFields.__proj__Mkuint_t__item__set_bitfield",
"Prims.unit",
"LowParse.BitFields.set_bitfield_set_bitfield_same_gen",
"Prims.l_True",
"Prims.squash",
"Prims.l_or",
"FStar.UInt.uint_t",
"LowParse.BitFields.set_bitfield",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi
val get_bitfield_partition
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Lemma
(requires (get_bitfield_partition_prop x y lo hi l))
(ensures (get_bitfield x lo hi == get_bitfield y lo hi))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
))
(ensures (x == y))
= assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]); // does not need fuel, thanks to normalization
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y
val get_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
: Lemma
(x < pow2 tot2 /\ (get_bitfield #tot1 x lo hi <: nat) == (get_bitfield #tot2 x lo hi <: nat))
val set_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
(v: ubitfield tot1 (hi - lo))
: Lemma
(x < pow2 tot2 /\ v < pow2 tot2 /\ (set_bitfield #tot1 x lo hi v <: nat) == (set_bitfield #tot2 x lo hi v <: nat))
val set_bitfield_bound
(#tot: pos)
(x: U.uint_t tot)
(bound: nat { bound <= tot /\ x < pow2 bound })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= bound })
(v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v < pow2 bound)
val set_bitfield_set_bitfield_get_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= hi - lo }) (v' : ubitfield tot (hi' - lo'))
: Lemma
( let v = set_bitfield (get_bitfield x lo hi) lo' hi' v' in
v < pow2 (hi - lo) /\
set_bitfield x lo hi v == set_bitfield x (lo + lo') (lo + hi') v' )
val get_bitfield_eq
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield x lo hi == (x / pow2 lo) % pow2 (hi - lo))
val get_bitfield_eq_2
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield x lo hi == (x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo))
val set_bitfield_eq
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v == (x `U.logand` U.lognot ((U.lognot 0 `U.shift_right` (tot - (hi - lo))) `U.shift_left` lo)) `U.logor` (v `U.shift_left` lo))
module U32 = FStar.UInt32
inline_for_extraction
noextract
noeq
type uint_t (tot: pos) (t: Type) = {
v: (t -> Tot (U.uint_t tot));
uint_to_t: (U.uint_t tot -> Tot t);
v_uint_to_t: ((x: U.uint_t tot) -> Lemma (v (uint_to_t x) == x));
uint_to_t_v: ((x: t) -> Lemma (uint_to_t (v x) == x));
get_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) (U32.v lo) (U32.v hi) }));
set_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> (z: t { v z < pow2 (U32.v hi - U32.v lo) }) -> Tot (y : t { v y == set_bitfield (v x) (U32.v lo) (U32.v hi) (v z)}));
get_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) lo hi }));
set_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y : t { v y == set_bitfield (v x) lo hi (v z)}));
logor: ((x: t) -> (y: t) -> Tot (z: t { v z == v x `U.logor` v y }));
bitfield_eq_lhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot t);
bitfield_eq_rhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y: t { bitfield_eq_lhs x lo hi == y <==> (get_bitfield x lo hi <: t) == z }));
}
inline_for_extraction
let bitfield (#tot: pos) (#t: Type) (cl: uint_t tot t) (sz: nat { sz <= tot }) : Tot Type =
(x: t { cl.v x < pow2 sz })
let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot) : Lemma
(cl.v (cl.uint_to_t x) == x)
[SMTPat (cl.v (cl.uint_to_t x))]
= cl.v_uint_to_t x
let uint_t_uint_to_t_v #tot #t (cl: uint_t tot t) (x: t) : Lemma
(cl.uint_to_t (cl.v x) == x)
[SMTPat (cl.uint_to_t (cl.v x))]
= cl.uint_to_t_v x
let uint_get_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)]
= get_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z);
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)) == cl.uint_to_t (cl.v z))
let uint_get_bitfield_set_bitfield_other
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo') })
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi')
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')]
= get_bitfield_set_bitfield_other (cl.v x) lo hi (cl.v z) lo' hi';
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')) == cl.uint_to_t (cl.v (cl.get_bitfield x lo' hi')))
let uint_set_bitfield_set_bitfield_same_gen
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo': nat) (hi': nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot }) (z' : bitfield cl (hi' - lo'))
: Lemma | false | false | LowParse.BitFields.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 uint_set_bitfield_set_bitfield_same_gen
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= lo /\ hi <= hi' /\ hi' <= tot})
(z': bitfield cl (hi' - lo'))
: Lemma (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' == cl.set_bitfield x lo' hi' z') | [] | LowParse.BitFields.uint_set_bitfield_set_bitfield_same_gen | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cl: LowParse.BitFields.uint_t tot t ->
x: t ->
lo: Prims.nat ->
hi: Prims.nat{lo <= hi /\ hi <= tot} ->
z: LowParse.BitFields.bitfield cl (hi - lo) ->
lo': Prims.nat ->
hi': Prims.nat{lo' <= lo /\ hi <= hi' /\ hi' <= tot} ->
z': LowParse.BitFields.bitfield cl (hi' - lo')
-> FStar.Pervasives.Lemma
(ensures
Mkuint_t?.set_bitfield cl (Mkuint_t?.set_bitfield cl x lo hi z) lo' hi' z' ==
Mkuint_t?.set_bitfield cl x lo' hi' z') | {
"end_col": 141,
"end_line": 317,
"start_col": 2,
"start_line": 316
} |
FStar.Pervasives.Lemma | val uint_set_bitfield_set_bitfield_other
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')})
(z': bitfield cl (hi' - lo'))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' ==
cl.set_bitfield (cl.set_bitfield x lo' hi' z') lo hi z) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_set_bitfield_set_bitfield_other
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo') })
(z' : bitfield cl (hi' - lo'))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' == cl.set_bitfield (cl.set_bitfield x lo' hi' z') lo hi z)
= set_bitfield_set_bitfield_other (cl.v x) lo hi (cl.v z) lo' hi' (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z')) == cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo' hi' z') lo hi z))) | val uint_set_bitfield_set_bitfield_other
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')})
(z': bitfield cl (hi' - lo'))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' ==
cl.set_bitfield (cl.set_bitfield x lo' hi' z') lo hi z)
let uint_set_bitfield_set_bitfield_other
#tot
#t
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')})
(z': bitfield cl (hi' - lo'))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' ==
cl.set_bitfield (cl.set_bitfield x lo' hi' z') lo hi z) = | false | null | true | set_bitfield_set_bitfield_other (cl.v x) lo hi (cl.v z) lo' hi' (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z')) ==
cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo' hi' z') lo hi z))) | {
"checked_file": "LowParse.BitFields.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.BitFields.fsti"
} | [
"lemma"
] | [
"Prims.pos",
"LowParse.BitFields.uint_t",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.BitFields.bitfield",
"Prims.op_Subtraction",
"Prims.l_or",
"Prims._assert",
"Prims.eq2",
"LowParse.BitFields.__proj__Mkuint_t__item__uint_to_t",
"LowParse.BitFields.__proj__Mkuint_t__item__v",
"LowParse.BitFields.__proj__Mkuint_t__item__set_bitfield",
"Prims.unit",
"LowParse.BitFields.set_bitfield_set_bitfield_other",
"Prims.l_True",
"Prims.squash",
"FStar.UInt.uint_t",
"LowParse.BitFields.set_bitfield",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.BitFields
module U = FStar.UInt
type ubitfield (tot: nat) (sz: nat) = (x: U.uint_t tot { x < pow2 sz })
// IMPORTANT: these bitfield operators are defined in a least
// significant bit (LSB) first fashion.
val get_bitfield
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Tot (ubitfield tot (hi - lo))
val get_bitfield_logor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi)
val get_bitfield_logxor
(#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi)
val set_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Tot (U.uint_t tot)
val get_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot })
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi'))
val set_bitfield_set_bitfield_same_gen
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot })
(v' : ubitfield tot (hi' - lo'))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v'))
let set_bitfield_set_bitfield_same
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(v' : ubitfield tot (hi - lo))
: Lemma
(ensures (set_bitfield (set_bitfield x lo hi v) lo hi v' == set_bitfield x lo hi v'))
= set_bitfield_set_bitfield_same_gen x lo hi v lo hi v'
val set_bitfield_set_bitfield_other
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo'))
: Lemma
(requires (hi' <= lo \/ hi <= lo'))
(ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v))
val set_bitfield_full
(#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot)
: Lemma
(set_bitfield x 0 tot y == y)
val set_bitfield_empty
(#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0)
: Lemma
(set_bitfield x i i y == x)
val get_bitfield_zero
(tot: pos)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield #tot 0 lo hi == 0)
val get_bitfield_full
(#tot: pos)
(x: U.uint_t tot)
: Lemma
(get_bitfield x 0 tot == x)
val get_bitfield_empty
(#tot: pos)
(x: U.uint_t tot)
(i: nat { i <= tot })
: Lemma
(get_bitfield x i i == 0)
val lt_pow2_get_bitfield_hi
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (x < pow2 mi))
(ensures (get_bitfield x mi tot == 0))
val get_bitfield_hi_lt_pow2
(#tot: pos)
(x: U.uint_t tot)
(mi: nat {mi <= tot})
: Lemma
(requires (get_bitfield x mi tot == 0))
(ensures (x < pow2 mi))
val get_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo })
: Lemma
(get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi'))
val get_bitfield_zero_inner
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi })
: Lemma
(ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0))
val set_bitfield_get_bitfield
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(set_bitfield x lo hi (get_bitfield x lo hi) == x)
val get_bitfield_partition_2_gen
(#tot: pos)
(lo: nat)
(mi: nat)
(hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x lo mi == get_bitfield y lo mi /\
get_bitfield x mi hi == get_bitfield y mi hi
))
(ensures (
get_bitfield x lo hi == get_bitfield y lo hi
))
val get_bitfield_partition_2
(#tot: pos)
(mid: nat { mid <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 mid == get_bitfield y 0 mid /\
get_bitfield x mid tot == get_bitfield y mid tot
))
(ensures (
x == y
))
let rec get_bitfield_partition_prop
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Tot bool
(decreases l)
= match l with
| [] ->
get_bitfield x lo hi = get_bitfield y lo hi
| mi :: q ->
lo <= mi && mi <= hi &&
get_bitfield_partition_prop x y mi hi q &&
get_bitfield x lo mi = get_bitfield y lo mi
val get_bitfield_partition
(#tot: pos)
(x y: U.uint_t tot)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(l: list nat)
: Lemma
(requires (get_bitfield_partition_prop x y lo hi l))
(ensures (get_bitfield x lo hi == get_bitfield y lo hi))
let get_bitfield_partition_3
(#tot: pos)
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot })
(x y: U.uint_t tot)
: Lemma
(requires (
get_bitfield x 0 lo == get_bitfield y 0 lo /\
get_bitfield x lo hi == get_bitfield y lo hi /\
get_bitfield x hi tot == get_bitfield y hi tot
))
(ensures (x == y))
= assert_norm (get_bitfield_partition_prop x y 0 tot [lo; hi]); // does not need fuel, thanks to normalization
get_bitfield_partition x y 0 tot [lo; hi];
get_bitfield_full x;
get_bitfield_full y
val get_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
: Lemma
(x < pow2 tot2 /\ (get_bitfield #tot1 x lo hi <: nat) == (get_bitfield #tot2 x lo hi <: nat))
val set_bitfield_size
(tot1 tot2: pos)
(x: nat { x < pow2 tot1 /\ tot1 <= tot2 })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= tot1 })
(v: ubitfield tot1 (hi - lo))
: Lemma
(x < pow2 tot2 /\ v < pow2 tot2 /\ (set_bitfield #tot1 x lo hi v <: nat) == (set_bitfield #tot2 x lo hi v <: nat))
val set_bitfield_bound
(#tot: pos)
(x: U.uint_t tot)
(bound: nat { bound <= tot /\ x < pow2 bound })
(lo: nat)
(hi: nat { lo <= hi /\ hi <= bound })
(v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v < pow2 bound)
val set_bitfield_set_bitfield_get_bitfield
(#tot: pos) (x: U.uint_t tot)
(lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= hi - lo }) (v' : ubitfield tot (hi' - lo'))
: Lemma
( let v = set_bitfield (get_bitfield x lo hi) lo' hi' v' in
v < pow2 (hi - lo) /\
set_bitfield x lo hi v == set_bitfield x (lo + lo') (lo + hi') v' )
val get_bitfield_eq
(#tot: pos)
(x: U.uint_t tot)
(lo: nat) (hi: nat {lo <= hi /\ hi <= tot})
: Lemma
(get_bitfield x lo hi == (x / pow2 lo) % pow2 (hi - lo))
val get_bitfield_eq_2
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot })
: Lemma
(get_bitfield x lo hi == (x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo))
val set_bitfield_eq
(#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo))
: Lemma
(set_bitfield x lo hi v == (x `U.logand` U.lognot ((U.lognot 0 `U.shift_right` (tot - (hi - lo))) `U.shift_left` lo)) `U.logor` (v `U.shift_left` lo))
module U32 = FStar.UInt32
inline_for_extraction
noextract
noeq
type uint_t (tot: pos) (t: Type) = {
v: (t -> Tot (U.uint_t tot));
uint_to_t: (U.uint_t tot -> Tot t);
v_uint_to_t: ((x: U.uint_t tot) -> Lemma (v (uint_to_t x) == x));
uint_to_t_v: ((x: t) -> Lemma (uint_to_t (v x) == x));
get_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) (U32.v lo) (U32.v hi) }));
set_bitfield_gen: ((x: t) -> (lo: U32.t) -> (hi: U32.t { U32.v lo < U32.v hi /\ U32.v hi <= tot }) -> (z: t { v z < pow2 (U32.v hi - U32.v lo) }) -> Tot (y : t { v y == set_bitfield (v x) (U32.v lo) (U32.v hi) (v z)}));
get_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot (y: t { v y == get_bitfield (v x) lo hi }));
set_bitfield: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y : t { v y == set_bitfield (v x) lo hi (v z)}));
logor: ((x: t) -> (y: t) -> Tot (z: t { v z == v x `U.logor` v y }));
bitfield_eq_lhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> Tot t);
bitfield_eq_rhs: ((x: t) -> (lo: nat) -> (hi: nat { lo <= hi /\ hi <= tot }) -> (z: t { v z < pow2 (hi - lo) }) -> Tot (y: t { bitfield_eq_lhs x lo hi == y <==> (get_bitfield x lo hi <: t) == z }));
}
inline_for_extraction
let bitfield (#tot: pos) (#t: Type) (cl: uint_t tot t) (sz: nat { sz <= tot }) : Tot Type =
(x: t { cl.v x < pow2 sz })
let uint_t_v_uint_to_t #tot #t (cl: uint_t tot t) (x: U.uint_t tot) : Lemma
(cl.v (cl.uint_to_t x) == x)
[SMTPat (cl.v (cl.uint_to_t x))]
= cl.v_uint_to_t x
let uint_t_uint_to_t_v #tot #t (cl: uint_t tot t) (x: t) : Lemma
(cl.uint_to_t (cl.v x) == x)
[SMTPat (cl.uint_to_t (cl.v x))]
= cl.uint_to_t_v x
let uint_get_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi == z)
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)]
= get_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z);
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo hi)) == cl.uint_to_t (cl.v z))
let uint_get_bitfield_set_bitfield_other
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo') })
: Lemma
(cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi' == cl.get_bitfield x lo' hi')
[SMTPat (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')]
= get_bitfield_set_bitfield_other (cl.v x) lo hi (cl.v z) lo' hi';
assert (cl.uint_to_t (cl.v (cl.get_bitfield (cl.set_bitfield x lo hi z) lo' hi')) == cl.uint_to_t (cl.v (cl.get_bitfield x lo' hi')))
let uint_set_bitfield_set_bitfield_same_gen
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo': nat) (hi': nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot }) (z' : bitfield cl (hi' - lo'))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' == cl.set_bitfield x lo' hi' z')
= set_bitfield_set_bitfield_same_gen (cl.v x) lo hi (cl.v z) lo' hi' (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z')) == cl.uint_to_t (cl.v (cl.set_bitfield x lo' hi' z')))
let uint_set_bitfield_set_bitfield_same
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(z' : bitfield cl (hi - lo))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z' == cl.set_bitfield x lo hi z')
= set_bitfield_set_bitfield_same (cl.v x) lo hi (cl.v z) (cl.v z');
assert (cl.uint_to_t (cl.v (cl.set_bitfield (cl.set_bitfield x lo hi z) lo hi z')) == cl.uint_to_t (cl.v (cl.set_bitfield x lo hi z')))
let uint_set_bitfield_set_bitfield_other
#tot #t (cl: uint_t tot t)
(x: t) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (z: bitfield cl (hi - lo))
(lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo') })
(z' : bitfield cl (hi' - lo'))
: Lemma | false | false | LowParse.BitFields.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 uint_set_bitfield_set_bitfield_other
(#tot #t: _)
(cl: uint_t tot t)
(x: t)
(lo: nat)
(hi: nat{lo <= hi /\ hi <= tot})
(z: bitfield cl (hi - lo))
(lo': nat)
(hi': nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')})
(z': bitfield cl (hi' - lo'))
: Lemma
(cl.set_bitfield (cl.set_bitfield x lo hi z) lo' hi' z' ==
cl.set_bitfield (cl.set_bitfield x lo' hi' z') lo hi z) | [] | LowParse.BitFields.uint_set_bitfield_set_bitfield_other | {
"file_name": "src/lowparse/LowParse.BitFields.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cl: LowParse.BitFields.uint_t tot t ->
x: t ->
lo: Prims.nat ->
hi: Prims.nat{lo <= hi /\ hi <= tot} ->
z: LowParse.BitFields.bitfield cl (hi - lo) ->
lo': Prims.nat ->
hi': Prims.nat{lo' <= hi' /\ hi' <= tot /\ (hi' <= lo \/ hi <= lo')} ->
z': LowParse.BitFields.bitfield cl (hi' - lo')
-> FStar.Pervasives.Lemma
(ensures
Mkuint_t?.set_bitfield cl (Mkuint_t?.set_bitfield cl x lo hi z) lo' hi' z' ==
Mkuint_t?.set_bitfield cl (Mkuint_t?.set_bitfield cl x lo' hi' z') lo hi z) | {
"end_col": 167,
"end_line": 336,
"start_col": 2,
"start_line": 335
} |
Prims.GTot | val writeable (p: perm) : GTot bool | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let writeable (p: perm) : GTot bool =
MkPerm?.v p = one | val writeable (p: perm) : GTot bool
let writeable (p: perm) : GTot bool = | false | null | false | MkPerm?.v p = one | {
"checked_file": "Steel.FractionalPermission.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.FractionalPermission.fst"
} | [
"sometrivial"
] | [
"Steel.FractionalPermission.perm",
"Prims.op_Equality",
"FStar.Real.real",
"Steel.FractionalPermission.__proj__MkPerm__item__v",
"FStar.Real.one",
"Prims.bool"
] | [] | (*
Copyright 2020 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 Steel.FractionalPermission
open FStar.Real
/// This module defines fractional permissions, to be used with Steel references
/// A fractional permission is a real value between 0 (excluded) and 1.
/// 1 represents full ownership, while any fraction corresponds to a shared
/// permission.
/// Note: Does not use real literals, but rather the wrappers one, zero, two, …
/// Real literals are currently not supported by Meta-F*'s reflection framework
[@@erasable]
noeq type perm : Type0 =
| MkPerm: v:real{ v >. zero } -> perm
/// A reference is only safely writeable if we have full permission | false | false | Steel.FractionalPermission.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 writeable (p: perm) : GTot bool | [] | Steel.FractionalPermission.writeable | {
"file_name": "lib/steel/Steel.FractionalPermission.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.FractionalPermission.perm -> Prims.GTot Prims.bool | {
"end_col": 19,
"end_line": 33,
"start_col": 2,
"start_line": 33
} |
Prims.GTot | val lesser_equal_perm (p1 p2: perm) : GTot bool | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lesser_equal_perm (p1 p2:perm) : GTot bool =
MkPerm?.v p1 <=. MkPerm?.v p2 | val lesser_equal_perm (p1 p2: perm) : GTot bool
let lesser_equal_perm (p1 p2: perm) : GTot bool = | false | null | false | MkPerm?.v p1 <=. MkPerm?.v p2 | {
"checked_file": "Steel.FractionalPermission.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.FractionalPermission.fst"
} | [
"sometrivial"
] | [
"Steel.FractionalPermission.perm",
"FStar.Real.op_Less_Equals_Dot",
"Steel.FractionalPermission.__proj__MkPerm__item__v",
"Prims.bool"
] | [] | (*
Copyright 2020 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 Steel.FractionalPermission
open FStar.Real
/// This module defines fractional permissions, to be used with Steel references
/// A fractional permission is a real value between 0 (excluded) and 1.
/// 1 represents full ownership, while any fraction corresponds to a shared
/// permission.
/// Note: Does not use real literals, but rather the wrappers one, zero, two, …
/// Real literals are currently not supported by Meta-F*'s reflection framework
[@@erasable]
noeq type perm : Type0 =
| MkPerm: v:real{ v >. zero } -> perm
/// A reference is only safely writeable if we have full permission
let writeable (p: perm) : GTot bool =
MkPerm?.v p = one
/// Helper around splitting a permission in half
let half_perm (p: perm) : Tot perm =
MkPerm ((MkPerm?.v p) /. two)
/// Helper to combine two permissions into one
let sum_perm (p1 p2: perm) : Tot perm =
MkPerm (MkPerm?.v p1 +. MkPerm?.v p2)
/// Helper to compare two permissions | false | false | Steel.FractionalPermission.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 lesser_equal_perm (p1 p2: perm) : GTot bool | [] | Steel.FractionalPermission.lesser_equal_perm | {
"file_name": "lib/steel/Steel.FractionalPermission.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p1: Steel.FractionalPermission.perm -> p2: Steel.FractionalPermission.perm -> Prims.GTot Prims.bool | {
"end_col": 32,
"end_line": 45,
"start_col": 2,
"start_line": 45
} |
FStar.Pervasives.Lemma | val sum_halves (p: perm)
: Lemma (sum_perm (half_perm p) (half_perm p) == p)
[SMTPat (sum_perm (half_perm p) (half_perm p))] | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sum_halves (p:perm)
: Lemma (sum_perm (half_perm p) (half_perm p) == p)
[SMTPat (sum_perm (half_perm p) (half_perm p))]
= assert (forall (r:real). r /. 2.0R +. r /. 2.0R == r) | val sum_halves (p: perm)
: Lemma (sum_perm (half_perm p) (half_perm p) == p)
[SMTPat (sum_perm (half_perm p) (half_perm p))]
let sum_halves (p: perm)
: Lemma (sum_perm (half_perm p) (half_perm p) == p)
[SMTPat (sum_perm (half_perm p) (half_perm p))] = | false | null | true | assert (forall (r: real). r /. 2.0R +. r /. 2.0R == r) | {
"checked_file": "Steel.FractionalPermission.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.FractionalPermission.fst"
} | [
"lemma"
] | [
"Steel.FractionalPermission.perm",
"Prims._assert",
"Prims.l_Forall",
"FStar.Real.real",
"Prims.eq2",
"FStar.Real.op_Plus_Dot",
"FStar.Real.op_Slash_Dot",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Steel.FractionalPermission.sum_perm",
"Steel.FractionalPermission.half_perm",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | (*
Copyright 2020 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 Steel.FractionalPermission
open FStar.Real
/// This module defines fractional permissions, to be used with Steel references
/// A fractional permission is a real value between 0 (excluded) and 1.
/// 1 represents full ownership, while any fraction corresponds to a shared
/// permission.
/// Note: Does not use real literals, but rather the wrappers one, zero, two, …
/// Real literals are currently not supported by Meta-F*'s reflection framework
[@@erasable]
noeq type perm : Type0 =
| MkPerm: v:real{ v >. zero } -> perm
/// A reference is only safely writeable if we have full permission
let writeable (p: perm) : GTot bool =
MkPerm?.v p = one
/// Helper around splitting a permission in half
let half_perm (p: perm) : Tot perm =
MkPerm ((MkPerm?.v p) /. two)
/// Helper to combine two permissions into one
let sum_perm (p1 p2: perm) : Tot perm =
MkPerm (MkPerm?.v p1 +. MkPerm?.v p2)
/// Helper to compare two permissions
let lesser_equal_perm (p1 p2:perm) : GTot bool =
MkPerm?.v p1 <=. MkPerm?.v p2
/// Wrapper around the full permission value
let full_perm : perm = MkPerm one
/// A convenience lemma
let sum_halves (p:perm)
: Lemma (sum_perm (half_perm p) (half_perm p) == p) | false | false | Steel.FractionalPermission.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 sum_halves (p: perm)
: Lemma (sum_perm (half_perm p) (half_perm p) == p)
[SMTPat (sum_perm (half_perm p) (half_perm p))] | [] | Steel.FractionalPermission.sum_halves | {
"file_name": "lib/steel/Steel.FractionalPermission.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.FractionalPermission.perm
-> FStar.Pervasives.Lemma
(ensures
Steel.FractionalPermission.sum_perm (Steel.FractionalPermission.half_perm p)
(Steel.FractionalPermission.half_perm p) ==
p)
[
SMTPat (Steel.FractionalPermission.sum_perm (Steel.FractionalPermission.half_perm p)
(Steel.FractionalPermission.half_perm p))
] | {
"end_col": 57,
"end_line": 54,
"start_col": 4,
"start_line": 54
} |
Prims.Tot | val half_perm (p: perm) : Tot perm | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let half_perm (p: perm) : Tot perm =
MkPerm ((MkPerm?.v p) /. two) | val half_perm (p: perm) : Tot perm
let half_perm (p: perm) : Tot perm = | false | null | false | MkPerm ((MkPerm?.v p) /. two) | {
"checked_file": "Steel.FractionalPermission.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.FractionalPermission.fst"
} | [
"total"
] | [
"Steel.FractionalPermission.perm",
"Steel.FractionalPermission.MkPerm",
"FStar.Real.op_Slash_Dot",
"Steel.FractionalPermission.__proj__MkPerm__item__v",
"FStar.Real.two"
] | [] | (*
Copyright 2020 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 Steel.FractionalPermission
open FStar.Real
/// This module defines fractional permissions, to be used with Steel references
/// A fractional permission is a real value between 0 (excluded) and 1.
/// 1 represents full ownership, while any fraction corresponds to a shared
/// permission.
/// Note: Does not use real literals, but rather the wrappers one, zero, two, …
/// Real literals are currently not supported by Meta-F*'s reflection framework
[@@erasable]
noeq type perm : Type0 =
| MkPerm: v:real{ v >. zero } -> perm
/// A reference is only safely writeable if we have full permission
let writeable (p: perm) : GTot bool =
MkPerm?.v p = one
/// Helper around splitting a permission in half | false | true | Steel.FractionalPermission.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 half_perm (p: perm) : Tot perm | [] | Steel.FractionalPermission.half_perm | {
"file_name": "lib/steel/Steel.FractionalPermission.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.FractionalPermission.perm -> Steel.FractionalPermission.perm | {
"end_col": 31,
"end_line": 37,
"start_col": 2,
"start_line": 37
} |
Prims.Tot | val full_perm:perm | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let full_perm : perm = MkPerm one | val full_perm:perm
let full_perm:perm = | false | null | false | MkPerm one | {
"checked_file": "Steel.FractionalPermission.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.FractionalPermission.fst"
} | [
"total"
] | [
"Steel.FractionalPermission.MkPerm",
"FStar.Real.one"
] | [] | (*
Copyright 2020 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 Steel.FractionalPermission
open FStar.Real
/// This module defines fractional permissions, to be used with Steel references
/// A fractional permission is a real value between 0 (excluded) and 1.
/// 1 represents full ownership, while any fraction corresponds to a shared
/// permission.
/// Note: Does not use real literals, but rather the wrappers one, zero, two, …
/// Real literals are currently not supported by Meta-F*'s reflection framework
[@@erasable]
noeq type perm : Type0 =
| MkPerm: v:real{ v >. zero } -> perm
/// A reference is only safely writeable if we have full permission
let writeable (p: perm) : GTot bool =
MkPerm?.v p = one
/// Helper around splitting a permission in half
let half_perm (p: perm) : Tot perm =
MkPerm ((MkPerm?.v p) /. two)
/// Helper to combine two permissions into one
let sum_perm (p1 p2: perm) : Tot perm =
MkPerm (MkPerm?.v p1 +. MkPerm?.v p2)
/// Helper to compare two permissions
let lesser_equal_perm (p1 p2:perm) : GTot bool =
MkPerm?.v p1 <=. MkPerm?.v p2 | false | true | Steel.FractionalPermission.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 full_perm:perm | [] | Steel.FractionalPermission.full_perm | {
"file_name": "lib/steel/Steel.FractionalPermission.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Steel.FractionalPermission.perm | {
"end_col": 33,
"end_line": 48,
"start_col": 23,
"start_line": 48
} |
Prims.Tot | val sum_perm (p1 p2: perm) : Tot perm | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sum_perm (p1 p2: perm) : Tot perm =
MkPerm (MkPerm?.v p1 +. MkPerm?.v p2) | val sum_perm (p1 p2: perm) : Tot perm
let sum_perm (p1 p2: perm) : Tot perm = | false | null | false | MkPerm (MkPerm?.v p1 +. MkPerm?.v p2) | {
"checked_file": "Steel.FractionalPermission.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.FractionalPermission.fst"
} | [
"total"
] | [
"Steel.FractionalPermission.perm",
"Steel.FractionalPermission.MkPerm",
"FStar.Real.op_Plus_Dot",
"Steel.FractionalPermission.__proj__MkPerm__item__v"
] | [] | (*
Copyright 2020 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 Steel.FractionalPermission
open FStar.Real
/// This module defines fractional permissions, to be used with Steel references
/// A fractional permission is a real value between 0 (excluded) and 1.
/// 1 represents full ownership, while any fraction corresponds to a shared
/// permission.
/// Note: Does not use real literals, but rather the wrappers one, zero, two, …
/// Real literals are currently not supported by Meta-F*'s reflection framework
[@@erasable]
noeq type perm : Type0 =
| MkPerm: v:real{ v >. zero } -> perm
/// A reference is only safely writeable if we have full permission
let writeable (p: perm) : GTot bool =
MkPerm?.v p = one
/// Helper around splitting a permission in half
let half_perm (p: perm) : Tot perm =
MkPerm ((MkPerm?.v p) /. two)
/// Helper to combine two permissions into one | false | true | Steel.FractionalPermission.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 sum_perm (p1 p2: perm) : Tot perm | [] | Steel.FractionalPermission.sum_perm | {
"file_name": "lib/steel/Steel.FractionalPermission.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p1: Steel.FractionalPermission.perm -> p2: Steel.FractionalPermission.perm
-> Steel.FractionalPermission.perm | {
"end_col": 40,
"end_line": 41,
"start_col": 2,
"start_line": 41
} |
Prims.Tot | val cs:S.ciphersuite | [
{
"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 cs:S.ciphersuite = (DH.DH_P256, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256) | val cs:S.ciphersuite
let cs:S.ciphersuite = | false | null | false | (DH.DH_P256, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256) | {
"checked_file": "Hacl.HPKE.P256_CP256_SHA256.fsti.checked",
"dependencies": [
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Hacl.Impl.HPKE.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.P256_CP256_SHA256.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.Mktuple4",
"Spec.Agile.DH.algorithm",
"Spec.Agile.HPKE.hash_algorithm",
"Spec.Agile.HPKE.aead",
"Spec.Hash.Definitions.hash_alg",
"Spec.Agile.DH.DH_P256",
"Spec.Hash.Definitions.SHA2_256",
"Spec.Agile.HPKE.Seal",
"Spec.Agile.AEAD.CHACHA20_POLY1305"
] | [] | module Hacl.HPKE.P256_CP256_SHA256
open Hacl.Impl.HPKE
module S = Spec.Agile.HPKE
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash | false | true | Hacl.HPKE.P256_CP256_SHA256.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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cs:S.ciphersuite | [] | Hacl.HPKE.P256_CP256_SHA256.cs | {
"file_name": "code/hpke/Hacl.HPKE.P256_CP256_SHA256.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.Agile.HPKE.ciphersuite | {
"end_col": 96,
"end_line": 10,
"start_col": 23,
"start_line": 10
} |
Prims.Tot | val get_len0 (len: size_t) : Tot (r: size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.SecretBox",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305_32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Salsa20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_len0 (len:size_t) : Tot (r:size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) =
if len <=. 32ul then len else 32ul | val get_len0 (len: size_t) : Tot (r: size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)})
let get_len0 (len: size_t) : Tot (r: size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) = | false | null | false | if len <=. 32ul then len else 32ul | {
"checked_file": "Hacl.Impl.SecretBox.fst.checked",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Salsa20.fst.checked",
"Hacl.Poly1305_32.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SecretBox.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.IntTypes.op_Less_Equals_Dot",
"Lib.IntTypes.U32",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.get_len0"
] | [] | module Hacl.Impl.SecretBox
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Salsa20
open Hacl.Poly1305_32
module ST = FStar.HyperStack.ST
module Spec = Spec.SecretBox
module LSeq = Lib.Sequence
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n)))
let secretbox_init xkeys k n =
let h0 = ST.get() in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1
inline_for_extraction noextract | false | false | Hacl.Impl.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_len0 (len: size_t) : Tot (r: size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) | [] | Hacl.Impl.SecretBox.get_len0 | {
"file_name": "code/nacl-box/Hacl.Impl.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_t
-> r:
Lib.IntTypes.size_t
{Lib.IntTypes.v r <= 32 /\ Lib.IntTypes.v r == Spec.SecretBox.get_len0 (Lib.IntTypes.v len)} | {
"end_col": 36,
"end_line": 48,
"start_col": 2,
"start_line": 48
} |
FStar.HyperStack.ST.Stack | val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n))) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.SecretBox",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305_32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Salsa20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secretbox_init xkeys k n =
let h0 = ST.get() in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1 | val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n)))
let secretbox_init xkeys k n = | true | null | false | let h0 = ST.get () in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1 | {
"checked_file": "Hacl.Impl.SecretBox.fst.checked",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Salsa20.fst.checked",
"Hacl.Poly1305_32.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SecretBox.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Salsa20.salsa20_key_block0",
"Prims.unit",
"Hacl.Salsa20.hsalsa20",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Impl.SecretBox
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Salsa20
open Hacl.Poly1305_32
module ST = FStar.HyperStack.ST
module Spec = Spec.SecretBox
module LSeq = Lib.Sequence
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n))) | false | false | Hacl.Impl.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n))) | [] | Hacl.Impl.SecretBox.secretbox_init | {
"file_name": "code/nacl-box/Hacl.Impl.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
xkeys: Lib.Buffer.lbuffer Lib.IntTypes.uint8 96ul ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 36,
"end_line": 43,
"start_col": 30,
"start_line": 36
} |
FStar.HyperStack.ST.Stack | val secretbox_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 16ul)
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.secretbox_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.SecretBox",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305_32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Salsa20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secretbox_easy mlen c k n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
secretbox_detached mlen cip tag k n m;
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16 | val secretbox_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 16ul)
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.secretbox_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
let secretbox_easy mlen c k n m = | true | null | false | let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
secretbox_detached mlen cip tag k n m;
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16 | {
"checked_file": "Hacl.Impl.SecretBox.fst.checked",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Salsa20.fst.checked",
"Hacl.Poly1305_32.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SecretBox.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Plus_Bang",
"FStar.UInt32.__uint_to_t",
"FStar.Seq.Properties.lemma_split",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.SecretBox.secretbox_detached",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | module Hacl.Impl.SecretBox
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Salsa20
open Hacl.Poly1305_32
module ST = FStar.HyperStack.ST
module Spec = Spec.SecretBox
module LSeq = Lib.Sequence
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n)))
let secretbox_init xkeys k n =
let h0 = ST.get() in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1
inline_for_extraction noextract
let get_len0 (len:size_t) : Tot (r:size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) =
if len <=. 32ul then len else 32ul
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher))
let secretbox_detached_cipher mlen c k xkeys n m =
let h0 = ST.get () in
push_frame ();
let n1 = sub n 16ul 8ul in
let subkey = sub xkeys 0ul 32ul in
let mkey = sub xkeys 32ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 m0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let h1 = ST.get () in
copy c0 (sub block0 0ul mlen0);
let h2 = ST.get () in
//assert (as_seq h2 c0 == LSeq.sub (as_seq h1 block0) 0 (v mlen0));
salsa20_encrypt mlen1 c1 m1 subkey n1 1ul;
let h3 = ST.get () in
//assert (as_seq h3 c1 == Spec.Salsa20.salsa20_encrypt_bytes (as_seq h2 subkey) (as_seq h2 n1) 1 (as_seq h2 m1));
FStar.Seq.Properties.lemma_split (as_seq h3 c) (v mlen0);
//FStar.Seq.Properties.lemma_split (Seq.append (as_seq h2 c0) (as_seq h3 c1)) (v mlen0);
assert (as_seq h3 c == Seq.append (as_seq h2 c0) (as_seq h3 c1));
assert (
let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h3 c == cipher);
pop_frame ()
val secretbox_detached:
mlen:size_t
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\
disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tag) h0 h1 /\
(as_seq h1 tag, as_seq h1 c) == Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
let secretbox_detached mlen c tag k n m =
let h0 = ST.get () in
push_frame();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
secretbox_detached_cipher mlen c k xkeys n m;
poly1305_mac tag mlen c mkey;
let h1 = ST.get () in
assert (
let (tag1, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
(as_seq h1 tag, as_seq h1 c) == (tag1, cipher));
pop_frame()
inline_for_extraction noextract
val secretbox_open_detached_plain:
mlen:size_t
-> m:lbuffer uint8 mlen
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\
disjoint m n /\ disjoint c n /\ eq_or_disjoint m c /\
disjoint xkeys m /\ disjoint xkeys c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let subkey = LSeq.sub (as_seq h0 xkeys) 0 32 in
let ekey0 = LSeq.sub (as_seq h0 xkeys) 64 32 in
let n1 = LSeq.sub (as_seq h0 n) 16 8 in
let clen0 = Spec.get_len0 (v mlen) in
let clen1 = v mlen - clen0 in
let c0 = LSeq.sub (as_seq h0 c) 0 clen0 in
let c1 = LSeq.sub (as_seq h0 c) clen0 clen1 in
let block0 = LSeq.create 32 (u8 0) in
let block0 = LSeq.update_sub block0 0 clen0 c0 in
let block0 = LSeq.map2 (^.) block0 ekey0 in
let m0 = LSeq.sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let msg = Seq.append m0 m1 in
as_seq h1 m == msg))
let secretbox_open_detached_plain mlen m xkeys n c =
push_frame ();
let subkey = sub xkeys 0ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let n1 = sub n 16ul 8ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 c0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
copy m0 (sub block0 0ul mlen0);
salsa20_decrypt mlen1 m1 c1 subkey n1 1ul;
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 m) (v mlen0);
pop_frame ()
val secretbox_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ disjoint m n /\ disjoint c n /\ eq_or_disjoint m c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg))
let secretbox_open_detached mlen m k n c tag =
push_frame();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
let tag' = create 16ul (u8 0) in
Hacl.Poly1305_32.poly1305_mac tag' mlen c mkey;
let res =
if lbytes_eq tag tag' then (
secretbox_open_detached_plain mlen m xkeys n c;
0ul)
else
0xfffffffful in
pop_frame ();
res
val secretbox_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 16ul)
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.secretbox_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | false | false | Hacl.Impl.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 16ul)
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.secretbox_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | [] | Hacl.Impl.SecretBox.secretbox_easy | {
"file_name": "code/nacl-box/Hacl.Impl.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t{Lib.IntTypes.v mlen + 16 <= Lib.IntTypes.max_size_t} ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (mlen +! 16ul) ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 51,
"end_line": 246,
"start_col": 33,
"start_line": 241
} |
FStar.HyperStack.ST.Stack | val secretbox_open_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.SecretBox",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305_32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Salsa20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secretbox_open_easy mlen m k n c =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
secretbox_open_detached mlen m k n cip tag | val secretbox_open_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg))
let secretbox_open_easy mlen m k n c = | true | null | false | let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
secretbox_open_detached mlen m k n cip tag | {
"checked_file": "Hacl.Impl.SecretBox.fst.checked",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Salsa20.fst.checked",
"Hacl.Poly1305_32.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SecretBox.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Impl.SecretBox.secretbox_open_detached",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | module Hacl.Impl.SecretBox
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Salsa20
open Hacl.Poly1305_32
module ST = FStar.HyperStack.ST
module Spec = Spec.SecretBox
module LSeq = Lib.Sequence
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n)))
let secretbox_init xkeys k n =
let h0 = ST.get() in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1
inline_for_extraction noextract
let get_len0 (len:size_t) : Tot (r:size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) =
if len <=. 32ul then len else 32ul
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher))
let secretbox_detached_cipher mlen c k xkeys n m =
let h0 = ST.get () in
push_frame ();
let n1 = sub n 16ul 8ul in
let subkey = sub xkeys 0ul 32ul in
let mkey = sub xkeys 32ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 m0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let h1 = ST.get () in
copy c0 (sub block0 0ul mlen0);
let h2 = ST.get () in
//assert (as_seq h2 c0 == LSeq.sub (as_seq h1 block0) 0 (v mlen0));
salsa20_encrypt mlen1 c1 m1 subkey n1 1ul;
let h3 = ST.get () in
//assert (as_seq h3 c1 == Spec.Salsa20.salsa20_encrypt_bytes (as_seq h2 subkey) (as_seq h2 n1) 1 (as_seq h2 m1));
FStar.Seq.Properties.lemma_split (as_seq h3 c) (v mlen0);
//FStar.Seq.Properties.lemma_split (Seq.append (as_seq h2 c0) (as_seq h3 c1)) (v mlen0);
assert (as_seq h3 c == Seq.append (as_seq h2 c0) (as_seq h3 c1));
assert (
let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h3 c == cipher);
pop_frame ()
val secretbox_detached:
mlen:size_t
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\
disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tag) h0 h1 /\
(as_seq h1 tag, as_seq h1 c) == Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
let secretbox_detached mlen c tag k n m =
let h0 = ST.get () in
push_frame();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
secretbox_detached_cipher mlen c k xkeys n m;
poly1305_mac tag mlen c mkey;
let h1 = ST.get () in
assert (
let (tag1, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
(as_seq h1 tag, as_seq h1 c) == (tag1, cipher));
pop_frame()
inline_for_extraction noextract
val secretbox_open_detached_plain:
mlen:size_t
-> m:lbuffer uint8 mlen
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\
disjoint m n /\ disjoint c n /\ eq_or_disjoint m c /\
disjoint xkeys m /\ disjoint xkeys c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let subkey = LSeq.sub (as_seq h0 xkeys) 0 32 in
let ekey0 = LSeq.sub (as_seq h0 xkeys) 64 32 in
let n1 = LSeq.sub (as_seq h0 n) 16 8 in
let clen0 = Spec.get_len0 (v mlen) in
let clen1 = v mlen - clen0 in
let c0 = LSeq.sub (as_seq h0 c) 0 clen0 in
let c1 = LSeq.sub (as_seq h0 c) clen0 clen1 in
let block0 = LSeq.create 32 (u8 0) in
let block0 = LSeq.update_sub block0 0 clen0 c0 in
let block0 = LSeq.map2 (^.) block0 ekey0 in
let m0 = LSeq.sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let msg = Seq.append m0 m1 in
as_seq h1 m == msg))
let secretbox_open_detached_plain mlen m xkeys n c =
push_frame ();
let subkey = sub xkeys 0ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let n1 = sub n 16ul 8ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 c0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
copy m0 (sub block0 0ul mlen0);
salsa20_decrypt mlen1 m1 c1 subkey n1 1ul;
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 m) (v mlen0);
pop_frame ()
val secretbox_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ disjoint m n /\ disjoint c n /\ eq_or_disjoint m c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg))
let secretbox_open_detached mlen m k n c tag =
push_frame();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
let tag' = create 16ul (u8 0) in
Hacl.Poly1305_32.poly1305_mac tag' mlen c mkey;
let res =
if lbytes_eq tag tag' then (
secretbox_open_detached_plain mlen m xkeys n c;
0ul)
else
0xfffffffful in
pop_frame ();
res
val secretbox_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> c:lbuffer uint8 (mlen +! 16ul)
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
as_seq h1 c == Spec.secretbox_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
let secretbox_easy mlen c k n m =
let tag = sub c 0ul 16ul in
let cip = sub c 16ul mlen in
secretbox_detached mlen cip tag k n m;
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 c) 16
val secretbox_open_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | false | false | Hacl.Impl.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_open_easy:
mlen:size_t{v mlen + 16 <= max_size_t}
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 (mlen +! 16ul) ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\
disjoint m c /\ disjoint n m /\ disjoint n c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_easy (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | [] | Hacl.Impl.SecretBox.secretbox_open_easy | {
"file_name": "code/nacl-box/Hacl.Impl.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t{Lib.IntTypes.v mlen + 16 <= Lib.IntTypes.max_size_t} ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (mlen +! 16ul)
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 44,
"end_line": 268,
"start_col": 38,
"start_line": 265
} |
FStar.HyperStack.ST.Stack | val secretbox_open_detached_plain:
mlen:size_t
-> m:lbuffer uint8 mlen
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\
disjoint m n /\ disjoint c n /\ eq_or_disjoint m c /\
disjoint xkeys m /\ disjoint xkeys c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let subkey = LSeq.sub (as_seq h0 xkeys) 0 32 in
let ekey0 = LSeq.sub (as_seq h0 xkeys) 64 32 in
let n1 = LSeq.sub (as_seq h0 n) 16 8 in
let clen0 = Spec.get_len0 (v mlen) in
let clen1 = v mlen - clen0 in
let c0 = LSeq.sub (as_seq h0 c) 0 clen0 in
let c1 = LSeq.sub (as_seq h0 c) clen0 clen1 in
let block0 = LSeq.create 32 (u8 0) in
let block0 = LSeq.update_sub block0 0 clen0 c0 in
let block0 = LSeq.map2 (^.) block0 ekey0 in
let m0 = LSeq.sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let msg = Seq.append m0 m1 in
as_seq h1 m == msg)) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.SecretBox",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305_32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Salsa20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secretbox_open_detached_plain mlen m xkeys n c =
push_frame ();
let subkey = sub xkeys 0ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let n1 = sub n 16ul 8ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 c0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
copy m0 (sub block0 0ul mlen0);
salsa20_decrypt mlen1 m1 c1 subkey n1 1ul;
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 m) (v mlen0);
pop_frame () | val secretbox_open_detached_plain:
mlen:size_t
-> m:lbuffer uint8 mlen
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\
disjoint m n /\ disjoint c n /\ eq_or_disjoint m c /\
disjoint xkeys m /\ disjoint xkeys c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let subkey = LSeq.sub (as_seq h0 xkeys) 0 32 in
let ekey0 = LSeq.sub (as_seq h0 xkeys) 64 32 in
let n1 = LSeq.sub (as_seq h0 n) 16 8 in
let clen0 = Spec.get_len0 (v mlen) in
let clen1 = v mlen - clen0 in
let c0 = LSeq.sub (as_seq h0 c) 0 clen0 in
let c1 = LSeq.sub (as_seq h0 c) clen0 clen1 in
let block0 = LSeq.create 32 (u8 0) in
let block0 = LSeq.update_sub block0 0 clen0 c0 in
let block0 = LSeq.map2 (^.) block0 ekey0 in
let m0 = LSeq.sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let msg = Seq.append m0 m1 in
as_seq h1 m == msg))
let secretbox_open_detached_plain mlen m xkeys n c = | true | null | false | push_frame ();
let subkey = sub xkeys 0ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let n1 = sub n 16ul 8ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 c0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
copy m0 (sub block0 0ul mlen0);
salsa20_decrypt mlen1 m1 c1 subkey n1 1ul;
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 m) (v mlen0);
pop_frame () | {
"checked_file": "Hacl.Impl.SecretBox.fst.checked",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Salsa20.fst.checked",
"Hacl.Poly1305_32.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SecretBox.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"FStar.Seq.Properties.lemma_split",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Salsa20.salsa20_decrypt",
"Lib.Buffer.copy",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"Lib.Buffer.map2T",
"Lib.IntTypes.op_Hat_Dot",
"Lib.Buffer.update_sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.IntTypes.op_Subtraction_Bang",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.SecretBox.get_len0",
"Hacl.Impl.SecretBox.get_len0",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.SecretBox
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Salsa20
open Hacl.Poly1305_32
module ST = FStar.HyperStack.ST
module Spec = Spec.SecretBox
module LSeq = Lib.Sequence
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n)))
let secretbox_init xkeys k n =
let h0 = ST.get() in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1
inline_for_extraction noextract
let get_len0 (len:size_t) : Tot (r:size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) =
if len <=. 32ul then len else 32ul
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher))
let secretbox_detached_cipher mlen c k xkeys n m =
let h0 = ST.get () in
push_frame ();
let n1 = sub n 16ul 8ul in
let subkey = sub xkeys 0ul 32ul in
let mkey = sub xkeys 32ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 m0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let h1 = ST.get () in
copy c0 (sub block0 0ul mlen0);
let h2 = ST.get () in
//assert (as_seq h2 c0 == LSeq.sub (as_seq h1 block0) 0 (v mlen0));
salsa20_encrypt mlen1 c1 m1 subkey n1 1ul;
let h3 = ST.get () in
//assert (as_seq h3 c1 == Spec.Salsa20.salsa20_encrypt_bytes (as_seq h2 subkey) (as_seq h2 n1) 1 (as_seq h2 m1));
FStar.Seq.Properties.lemma_split (as_seq h3 c) (v mlen0);
//FStar.Seq.Properties.lemma_split (Seq.append (as_seq h2 c0) (as_seq h3 c1)) (v mlen0);
assert (as_seq h3 c == Seq.append (as_seq h2 c0) (as_seq h3 c1));
assert (
let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h3 c == cipher);
pop_frame ()
val secretbox_detached:
mlen:size_t
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\
disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tag) h0 h1 /\
(as_seq h1 tag, as_seq h1 c) == Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
let secretbox_detached mlen c tag k n m =
let h0 = ST.get () in
push_frame();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
secretbox_detached_cipher mlen c k xkeys n m;
poly1305_mac tag mlen c mkey;
let h1 = ST.get () in
assert (
let (tag1, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
(as_seq h1 tag, as_seq h1 c) == (tag1, cipher));
pop_frame()
inline_for_extraction noextract
val secretbox_open_detached_plain:
mlen:size_t
-> m:lbuffer uint8 mlen
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\
disjoint m n /\ disjoint c n /\ eq_or_disjoint m c /\
disjoint xkeys m /\ disjoint xkeys c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let subkey = LSeq.sub (as_seq h0 xkeys) 0 32 in
let ekey0 = LSeq.sub (as_seq h0 xkeys) 64 32 in
let n1 = LSeq.sub (as_seq h0 n) 16 8 in
let clen0 = Spec.get_len0 (v mlen) in
let clen1 = v mlen - clen0 in
let c0 = LSeq.sub (as_seq h0 c) 0 clen0 in
let c1 = LSeq.sub (as_seq h0 c) clen0 clen1 in
let block0 = LSeq.create 32 (u8 0) in
let block0 = LSeq.update_sub block0 0 clen0 c0 in
let block0 = LSeq.map2 (^.) block0 ekey0 in
let m0 = LSeq.sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let msg = Seq.append m0 m1 in
as_seq h1 m == msg)) | false | false | Hacl.Impl.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_open_detached_plain:
mlen:size_t
-> m:lbuffer uint8 mlen
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\
disjoint m n /\ disjoint c n /\ eq_or_disjoint m c /\
disjoint xkeys m /\ disjoint xkeys c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let subkey = LSeq.sub (as_seq h0 xkeys) 0 32 in
let ekey0 = LSeq.sub (as_seq h0 xkeys) 64 32 in
let n1 = LSeq.sub (as_seq h0 n) 16 8 in
let clen0 = Spec.get_len0 (v mlen) in
let clen1 = v mlen - clen0 in
let c0 = LSeq.sub (as_seq h0 c) 0 clen0 in
let c1 = LSeq.sub (as_seq h0 c) clen0 clen1 in
let block0 = LSeq.create 32 (u8 0) in
let block0 = LSeq.update_sub block0 0 clen0 c0 in
let block0 = LSeq.map2 (^.) block0 ekey0 in
let m0 = LSeq.sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let msg = Seq.append m0 m1 in
as_seq h1 m == msg)) | [] | Hacl.Impl.SecretBox.secretbox_open_detached_plain | {
"file_name": "code/nacl-box/Hacl.Impl.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
xkeys: Lib.Buffer.lbuffer Lib.IntTypes.uint8 96ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 189,
"start_col": 2,
"start_line": 169
} |
FStar.HyperStack.ST.Stack | val secretbox_detached:
mlen:size_t
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\
disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tag) h0 h1 /\
(as_seq h1 tag, as_seq h1 c) == Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.SecretBox",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305_32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Salsa20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secretbox_detached mlen c tag k n m =
let h0 = ST.get () in
push_frame();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
secretbox_detached_cipher mlen c k xkeys n m;
poly1305_mac tag mlen c mkey;
let h1 = ST.get () in
assert (
let (tag1, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
(as_seq h1 tag, as_seq h1 c) == (tag1, cipher));
pop_frame() | val secretbox_detached:
mlen:size_t
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\
disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tag) h0 h1 /\
(as_seq h1 tag, as_seq h1 c) == Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
let secretbox_detached mlen c tag k n m = | true | null | false | let h0 = ST.get () in
push_frame ();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
secretbox_detached_cipher mlen c k xkeys n m;
poly1305_mac tag mlen c mkey;
let h1 = ST.get () in
assert (let tag1, cipher = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
(as_seq h1 tag, as_seq h1 c) == (tag1, cipher));
pop_frame () | {
"checked_file": "Hacl.Impl.SecretBox.fst.checked",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Salsa20.fst.checked",
"Hacl.Poly1305_32.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SecretBox.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Prims._assert",
"Spec.SecretBox.tag",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Sequence.seq",
"Prims.l_or",
"FStar.Seq.Base.length",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.int_t",
"Spec.SecretBox.secretbox_detached",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Poly1305_32.poly1305_mac",
"Hacl.Impl.SecretBox.secretbox_detached_cipher",
"Lib.Buffer.lbuffer_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Hacl.Impl.SecretBox.secretbox_init",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.SecretBox
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Salsa20
open Hacl.Poly1305_32
module ST = FStar.HyperStack.ST
module Spec = Spec.SecretBox
module LSeq = Lib.Sequence
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n)))
let secretbox_init xkeys k n =
let h0 = ST.get() in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1
inline_for_extraction noextract
let get_len0 (len:size_t) : Tot (r:size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) =
if len <=. 32ul then len else 32ul
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher))
let secretbox_detached_cipher mlen c k xkeys n m =
let h0 = ST.get () in
push_frame ();
let n1 = sub n 16ul 8ul in
let subkey = sub xkeys 0ul 32ul in
let mkey = sub xkeys 32ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 m0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let h1 = ST.get () in
copy c0 (sub block0 0ul mlen0);
let h2 = ST.get () in
//assert (as_seq h2 c0 == LSeq.sub (as_seq h1 block0) 0 (v mlen0));
salsa20_encrypt mlen1 c1 m1 subkey n1 1ul;
let h3 = ST.get () in
//assert (as_seq h3 c1 == Spec.Salsa20.salsa20_encrypt_bytes (as_seq h2 subkey) (as_seq h2 n1) 1 (as_seq h2 m1));
FStar.Seq.Properties.lemma_split (as_seq h3 c) (v mlen0);
//FStar.Seq.Properties.lemma_split (Seq.append (as_seq h2 c0) (as_seq h3 c1)) (v mlen0);
assert (as_seq h3 c == Seq.append (as_seq h2 c0) (as_seq h3 c1));
assert (
let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h3 c == cipher);
pop_frame ()
val secretbox_detached:
mlen:size_t
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\
disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tag) h0 h1 /\
(as_seq h1 tag, as_seq h1 c) == Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | false | false | Hacl.Impl.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_detached:
mlen:size_t
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\
disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tag) h0 h1 /\
(as_seq h1 tag, as_seq h1 c) == Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) | [] | Hacl.Impl.SecretBox.secretbox_detached | {
"file_name": "code/nacl-box/Hacl.Impl.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
tag: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 13,
"end_line": 135,
"start_col": 41,
"start_line": 123
} |
FStar.HyperStack.ST.Stack | val secretbox_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ disjoint m n /\ disjoint c n /\ eq_or_disjoint m c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.SecretBox",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305_32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Salsa20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secretbox_open_detached mlen m k n c tag =
push_frame();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
let tag' = create 16ul (u8 0) in
Hacl.Poly1305_32.poly1305_mac tag' mlen c mkey;
let res =
if lbytes_eq tag tag' then (
secretbox_open_detached_plain mlen m xkeys n c;
0ul)
else
0xfffffffful in
pop_frame ();
res | val secretbox_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ disjoint m n /\ disjoint c n /\ eq_or_disjoint m c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg))
let secretbox_open_detached mlen m k n c tag = | true | null | false | push_frame ();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
let tag' = create 16ul (u8 0) in
Hacl.Poly1305_32.poly1305_mac tag' mlen c mkey;
let res =
if lbytes_eq tag tag'
then
(secretbox_open_detached_plain mlen m xkeys n c;
0ul)
else 0xfffffffful
in
pop_frame ();
res | {
"checked_file": "Hacl.Impl.SecretBox.fst.checked",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Salsa20.fst.checked",
"Hacl.Poly1305_32.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SecretBox.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.SecretBox.secretbox_open_detached_plain",
"Prims.bool",
"Lib.ByteBuffer.lbytes_eq",
"Hacl.Poly1305_32.poly1305_mac",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.Buffer.sub",
"Hacl.Impl.SecretBox.secretbox_init",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.SecretBox
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Salsa20
open Hacl.Poly1305_32
module ST = FStar.HyperStack.ST
module Spec = Spec.SecretBox
module LSeq = Lib.Sequence
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n)))
let secretbox_init xkeys k n =
let h0 = ST.get() in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1
inline_for_extraction noextract
let get_len0 (len:size_t) : Tot (r:size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) =
if len <=. 32ul then len else 32ul
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher))
let secretbox_detached_cipher mlen c k xkeys n m =
let h0 = ST.get () in
push_frame ();
let n1 = sub n 16ul 8ul in
let subkey = sub xkeys 0ul 32ul in
let mkey = sub xkeys 32ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 m0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let h1 = ST.get () in
copy c0 (sub block0 0ul mlen0);
let h2 = ST.get () in
//assert (as_seq h2 c0 == LSeq.sub (as_seq h1 block0) 0 (v mlen0));
salsa20_encrypt mlen1 c1 m1 subkey n1 1ul;
let h3 = ST.get () in
//assert (as_seq h3 c1 == Spec.Salsa20.salsa20_encrypt_bytes (as_seq h2 subkey) (as_seq h2 n1) 1 (as_seq h2 m1));
FStar.Seq.Properties.lemma_split (as_seq h3 c) (v mlen0);
//FStar.Seq.Properties.lemma_split (Seq.append (as_seq h2 c0) (as_seq h3 c1)) (v mlen0);
assert (as_seq h3 c == Seq.append (as_seq h2 c0) (as_seq h3 c1));
assert (
let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h3 c == cipher);
pop_frame ()
val secretbox_detached:
mlen:size_t
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\
disjoint n m /\ disjoint n c)
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tag) h0 h1 /\
(as_seq h1 tag, as_seq h1 c) == Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m))
let secretbox_detached mlen c tag k n m =
let h0 = ST.get () in
push_frame();
let xkeys = create 96ul (u8 0) in
secretbox_init xkeys k n;
let mkey = sub xkeys 32ul 32ul in
secretbox_detached_cipher mlen c k xkeys n m;
poly1305_mac tag mlen c mkey;
let h1 = ST.get () in
assert (
let (tag1, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
(as_seq h1 tag, as_seq h1 c) == (tag1, cipher));
pop_frame()
inline_for_extraction noextract
val secretbox_open_detached_plain:
mlen:size_t
-> m:lbuffer uint8 mlen
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\
disjoint m n /\ disjoint c n /\ eq_or_disjoint m c /\
disjoint xkeys m /\ disjoint xkeys c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let subkey = LSeq.sub (as_seq h0 xkeys) 0 32 in
let ekey0 = LSeq.sub (as_seq h0 xkeys) 64 32 in
let n1 = LSeq.sub (as_seq h0 n) 16 8 in
let clen0 = Spec.get_len0 (v mlen) in
let clen1 = v mlen - clen0 in
let c0 = LSeq.sub (as_seq h0 c) 0 clen0 in
let c1 = LSeq.sub (as_seq h0 c) clen0 clen1 in
let block0 = LSeq.create 32 (u8 0) in
let block0 = LSeq.update_sub block0 0 clen0 c0 in
let block0 = LSeq.map2 (^.) block0 ekey0 in
let m0 = LSeq.sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let msg = Seq.append m0 m1 in
as_seq h1 m == msg))
let secretbox_open_detached_plain mlen m xkeys n c =
push_frame ();
let subkey = sub xkeys 0ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let n1 = sub n 16ul 8ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 c0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
copy m0 (sub block0 0ul mlen0);
salsa20_decrypt mlen1 m1 c1 subkey n1 1ul;
let h1 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h1 m) (v mlen0);
pop_frame ()
val secretbox_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ disjoint m n /\ disjoint c n /\ eq_or_disjoint m c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | false | false | Hacl.Impl.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_open_detached:
mlen:size_t
-> m:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul
-> c:lbuffer uint8 mlen
-> tag:lbuffer uint8 16ul ->
Stack size_t
(requires fun h ->
live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\
disjoint tag c /\ disjoint tag m /\ disjoint m n /\ disjoint c n /\ eq_or_disjoint m c)
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(let msg = Spec.secretbox_open_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in
match r with
| 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg
| _ -> None? msg)) | [] | Hacl.Impl.SecretBox.secretbox_open_detached | {
"file_name": "code/nacl-box/Hacl.Impl.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
tag: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul
-> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t | {
"end_col": 5,
"end_line": 225,
"start_col": 2,
"start_line": 210
} |
FStar.HyperStack.ST.Stack | val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher)) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.SecretBox",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305_32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Salsa20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secretbox_detached_cipher mlen c k xkeys n m =
let h0 = ST.get () in
push_frame ();
let n1 = sub n 16ul 8ul in
let subkey = sub xkeys 0ul 32ul in
let mkey = sub xkeys 32ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 m0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let h1 = ST.get () in
copy c0 (sub block0 0ul mlen0);
let h2 = ST.get () in
//assert (as_seq h2 c0 == LSeq.sub (as_seq h1 block0) 0 (v mlen0));
salsa20_encrypt mlen1 c1 m1 subkey n1 1ul;
let h3 = ST.get () in
//assert (as_seq h3 c1 == Spec.Salsa20.salsa20_encrypt_bytes (as_seq h2 subkey) (as_seq h2 n1) 1 (as_seq h2 m1));
FStar.Seq.Properties.lemma_split (as_seq h3 c) (v mlen0);
//FStar.Seq.Properties.lemma_split (Seq.append (as_seq h2 c0) (as_seq h3 c1)) (v mlen0);
assert (as_seq h3 c == Seq.append (as_seq h2 c0) (as_seq h3 c1));
assert (
let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h3 c == cipher);
pop_frame () | val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher))
let secretbox_detached_cipher mlen c k xkeys n m = | true | null | false | let h0 = ST.get () in
push_frame ();
let n1 = sub n 16ul 8ul in
let subkey = sub xkeys 0ul 32ul in
let mkey = sub xkeys 32ul 32ul in
let ekey0 = sub xkeys 64ul 32ul in
let mlen0 = get_len0 mlen in
let mlen1 = mlen -! mlen0 in
let m0 = sub m 0ul mlen0 in
let m1 = sub m mlen0 mlen1 in
let block0 = create 32ul (u8 0) in
update_sub block0 0ul mlen0 m0;
map2T 32ul block0 ( ^. ) block0 ekey0;
let c0 = sub c 0ul mlen0 in
let c1 = sub c mlen0 mlen1 in
let h1 = ST.get () in
copy c0 (sub block0 0ul mlen0);
let h2 = ST.get () in
salsa20_encrypt mlen1 c1 m1 subkey n1 1ul;
let h3 = ST.get () in
FStar.Seq.Properties.lemma_split (as_seq h3 c) (v mlen0);
assert (as_seq h3 c == Seq.append (as_seq h2 c0) (as_seq h3 c1));
assert (let tag, cipher = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h3 c == cipher);
pop_frame () | {
"checked_file": "Hacl.Impl.SecretBox.fst.checked",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Salsa20.fst.checked",
"Hacl.Poly1305_32.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SecretBox.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Prims._assert",
"Spec.SecretBox.tag",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"FStar.Seq.Base.length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Spec.SecretBox.secretbox_detached",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.append",
"FStar.Seq.Properties.lemma_split",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Salsa20.salsa20_encrypt",
"Lib.Buffer.copy",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.sub",
"Lib.Buffer.map2T",
"Lib.IntTypes.op_Hat_Dot",
"Lib.Buffer.update_sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.IntTypes.op_Subtraction_Bang",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.int",
"Lib.IntTypes.range",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.SecretBox.get_len0",
"Hacl.Impl.SecretBox.get_len0",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.SecretBox
open FStar.HyperStack.All
open FStar.HyperStack
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Salsa20
open Hacl.Poly1305_32
module ST = FStar.HyperStack.ST
module Spec = Spec.SecretBox
module LSeq = Lib.Sequence
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val secretbox_init:
xkeys:lbuffer uint8 96ul
-> k:lbuffer uint8 32ul
-> n:lbuffer uint8 24ul ->
Stack unit
(requires fun h ->
live h xkeys /\ live h k /\ live h n /\
disjoint k xkeys /\ disjoint n xkeys)
(ensures fun h0 _ h1 ->
modifies (loc xkeys) h0 h1 /\
(let xkeys = as_seq h1 xkeys in
let subkey : Spec.key = LSeq.sub xkeys 0 32 in
let aekey : Spec.aekey = LSeq.sub xkeys 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h0 k) (as_seq h0 n)))
let secretbox_init xkeys k n =
let h0 = ST.get() in
let subkey = sub xkeys 0ul 32ul in
let aekey = sub xkeys 32ul 64ul in
let n0 = sub n 0ul 16ul in
let n1 = sub n 16ul 8ul in
hsalsa20 subkey k n0;
salsa20_key_block0 aekey subkey n1
inline_for_extraction noextract
let get_len0 (len:size_t) : Tot (r:size_t{v r <= 32 /\ v r == Spec.get_len0 (v len)}) =
if len <=. 32ul then len else 32ul
#set-options "--z3rlimit 100"
inline_for_extraction noextract
val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher)) | false | false | Hacl.Impl.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_detached_cipher:
mlen:size_t
-> c:lbuffer uint8 mlen
-> k:lbuffer uint8 32ul
-> xkeys:lbuffer uint8 96ul
-> n:lbuffer uint8 24ul
-> m:lbuffer uint8 mlen ->
Stack unit
(requires fun h ->
live h c /\ live h m /\ live h xkeys /\ live h n /\ live h k /\
eq_or_disjoint m c /\ disjoint xkeys c /\ disjoint xkeys m /\
disjoint n m /\ disjoint n c /\
(let subkey : Spec.key = LSeq.sub (as_seq h xkeys) 0 32 in
let aekey : Spec.aekey = LSeq.sub (as_seq h xkeys) 32 64 in
(subkey, aekey) == Spec.secretbox_init (as_seq h k) (as_seq h n)))
(ensures fun h0 _ h1 -> modifies (loc c) h0 h1 /\
(let (tag, cipher) = Spec.secretbox_detached (as_seq h0 k) (as_seq h0 n) (as_seq h0 m) in
as_seq h1 c == cipher)) | [] | Hacl.Impl.SecretBox.secretbox_detached_cipher | {
"file_name": "code/nacl-box/Hacl.Impl.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mlen: Lib.IntTypes.size_t ->
c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
xkeys: Lib.Buffer.lbuffer Lib.IntTypes.uint8 96ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul ->
m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 105,
"start_col": 50,
"start_line": 73
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"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 cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} | let cmp (a: eqtype) = | false | null | false | f: (a -> a -> Tot bool){total_order a f} | {
"checked_file": "FStar.OrdMap.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.OrdMap.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.bool",
"FStar.OrdMap.total_order"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMap
open FStar.OrdSet
(* TODO (KM) : move me this should go in a common file on relations *)
type total_order (a:eqtype) (f: (a -> a -> Tot bool)) =
(forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *)
/\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *)
/\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) | false | true | FStar.OrdMap.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 cmp : a: Prims.eqtype -> Type0 | [] | FStar.OrdMap.cmp | {
"file_name": "ulib/experimental/FStar.OrdMap.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Prims.eqtype -> Type0 | {
"end_col": 60,
"end_line": 26,
"start_col": 21,
"start_line": 26
} |
|
Prims.Tot | val print_reg64 (r: reg_64) (p: printer) : string | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let print_reg64 (r:reg_64) (p:printer) : string =
p.reg_prefix() ^ p.print_reg_name r | val print_reg64 (r: reg_64) (p: printer) : string
let print_reg64 (r: reg_64) (p: printer) : string = | false | null | false | p.reg_prefix () ^ p.print_reg_name r | {
"checked_file": "Vale.X64.Print_s.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Print_s.fst"
} | [
"total"
] | [
"Vale.X64.Machine_s.reg_64",
"Vale.X64.Print_s.printer",
"Prims.op_Hat",
"Vale.X64.Print_s.__proj__Mkprinter__item__reg_prefix",
"Vale.X64.Print_s.__proj__Mkprinter__item__print_reg_name",
"Prims.string"
] | [] | module Vale.X64.Print_s
open FStar.Mul
open FStar.List.Tot
// Trusted code for producing assembly code
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.Bytes_Code_s
open Vale.X64.Machine_Semantics_s
open FStar.IO
noeq type printer = {
print_reg_name: reg_64 -> string;
print_reg32_name: reg_64 -> string;
print_small_reg_name: reg_64 -> string;
reg_prefix : unit -> string;
mem_prefix : string -> string;
maddr : string -> option (string & string) -> string -> string;
const : int -> string;
ins_name : string -> list operand64 -> string;
op_order : string -> string -> string & string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
sha256rnds2_explicit_xmm0: unit -> bool;
}
let print_reg_name (r:reg_64) : string =
match r with
| 0 -> "rax"
| 1 -> "rbx"
| 2 -> "rcx"
| 3 -> "rdx"
| 4 -> "rsi"
| 5 -> "rdi"
| 6 -> "rbp"
| 7 -> "rsp"
| 8 -> "r8"
| 9 -> "r9"
| 10 -> "r10"
| 11 -> "r11"
| 12 -> "r12"
| 13 -> "r13"
| 14 -> "r14"
| 15 -> "r15"
let print_reg32_name (r:reg_64) : string =
match r with
| 0 -> "eax"
| 1 -> "ebx"
| 2 -> "ecx"
| 3 -> "edx"
| 4 -> "esi"
| 5 -> "edi"
| 6 -> "ebp"
| 7 -> "esp"
| _ -> print_reg_name r ^ "d"
let print_small_reg_name (r:reg_64) : string =
match r with
| 0 -> "al"
| 1 -> "bl"
| 2 -> "cl"
| 3 -> "dl"
| _ -> " !!! INVALID small operand !!! Expected al, bl, cl, or dl." | false | true | Vale.X64.Print_s.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 print_reg64 (r: reg_64) (p: printer) : string | [] | Vale.X64.Print_s.print_reg64 | {
"file_name": "vale/specs/hardware/Vale.X64.Print_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | r: Vale.X64.Machine_s.reg_64 -> p: Vale.X64.Print_s.printer -> Prims.string | {
"end_col": 37,
"end_line": 71,
"start_col": 2,
"start_line": 71
} |
Prims.Tot | val print_reg32 (r: reg_64) (p: printer) : string | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let print_reg32 (r:reg_64) (p:printer) : string =
p.reg_prefix() ^ p.print_reg32_name r | val print_reg32 (r: reg_64) (p: printer) : string
let print_reg32 (r: reg_64) (p: printer) : string = | false | null | false | p.reg_prefix () ^ p.print_reg32_name r | {
"checked_file": "Vale.X64.Print_s.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Print_s.fst"
} | [
"total"
] | [
"Vale.X64.Machine_s.reg_64",
"Vale.X64.Print_s.printer",
"Prims.op_Hat",
"Vale.X64.Print_s.__proj__Mkprinter__item__reg_prefix",
"Vale.X64.Print_s.__proj__Mkprinter__item__print_reg32_name",
"Prims.string"
] | [] | module Vale.X64.Print_s
open FStar.Mul
open FStar.List.Tot
// Trusted code for producing assembly code
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.Bytes_Code_s
open Vale.X64.Machine_Semantics_s
open FStar.IO
noeq type printer = {
print_reg_name: reg_64 -> string;
print_reg32_name: reg_64 -> string;
print_small_reg_name: reg_64 -> string;
reg_prefix : unit -> string;
mem_prefix : string -> string;
maddr : string -> option (string & string) -> string -> string;
const : int -> string;
ins_name : string -> list operand64 -> string;
op_order : string -> string -> string & string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
sha256rnds2_explicit_xmm0: unit -> bool;
}
let print_reg_name (r:reg_64) : string =
match r with
| 0 -> "rax"
| 1 -> "rbx"
| 2 -> "rcx"
| 3 -> "rdx"
| 4 -> "rsi"
| 5 -> "rdi"
| 6 -> "rbp"
| 7 -> "rsp"
| 8 -> "r8"
| 9 -> "r9"
| 10 -> "r10"
| 11 -> "r11"
| 12 -> "r12"
| 13 -> "r13"
| 14 -> "r14"
| 15 -> "r15"
let print_reg32_name (r:reg_64) : string =
match r with
| 0 -> "eax"
| 1 -> "ebx"
| 2 -> "ecx"
| 3 -> "edx"
| 4 -> "esi"
| 5 -> "edi"
| 6 -> "ebp"
| 7 -> "esp"
| _ -> print_reg_name r ^ "d"
let print_small_reg_name (r:reg_64) : string =
match r with
| 0 -> "al"
| 1 -> "bl"
| 2 -> "cl"
| 3 -> "dl"
| _ -> " !!! INVALID small operand !!! Expected al, bl, cl, or dl."
let print_reg64 (r:reg_64) (p:printer) : string =
p.reg_prefix() ^ p.print_reg_name r | false | true | Vale.X64.Print_s.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 print_reg32 (r: reg_64) (p: printer) : string | [] | Vale.X64.Print_s.print_reg32 | {
"file_name": "vale/specs/hardware/Vale.X64.Print_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | r: Vale.X64.Machine_s.reg_64 -> p: Vale.X64.Print_s.printer -> Prims.string | {
"end_col": 39,
"end_line": 74,
"start_col": 2,
"start_line": 74
} |
Prims.Tot | val print_imm8 (i: int) (p: printer) : string | [
{
"abbrev": false,
"full_module": "FStar.UInt64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let print_imm8 (i:int) (p:printer) : string =
p.const i | val print_imm8 (i: int) (p: printer) : string
let print_imm8 (i: int) (p: printer) : string = | false | null | false | p.const i | {
"checked_file": "Vale.X64.Print_s.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Print_s.fst"
} | [
"total"
] | [
"Prims.int",
"Vale.X64.Print_s.printer",
"Vale.X64.Print_s.__proj__Mkprinter__item__const",
"Prims.string"
] | [] | module Vale.X64.Print_s
open FStar.Mul
open FStar.List.Tot
// Trusted code for producing assembly code
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.Bytes_Code_s
open Vale.X64.Machine_Semantics_s
open FStar.IO
noeq type printer = {
print_reg_name: reg_64 -> string;
print_reg32_name: reg_64 -> string;
print_small_reg_name: reg_64 -> string;
reg_prefix : unit -> string;
mem_prefix : string -> string;
maddr : string -> option (string & string) -> string -> string;
const : int -> string;
ins_name : string -> list operand64 -> string;
op_order : string -> string -> string & string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
sha256rnds2_explicit_xmm0: unit -> bool;
}
let print_reg_name (r:reg_64) : string =
match r with
| 0 -> "rax"
| 1 -> "rbx"
| 2 -> "rcx"
| 3 -> "rdx"
| 4 -> "rsi"
| 5 -> "rdi"
| 6 -> "rbp"
| 7 -> "rsp"
| 8 -> "r8"
| 9 -> "r9"
| 10 -> "r10"
| 11 -> "r11"
| 12 -> "r12"
| 13 -> "r13"
| 14 -> "r14"
| 15 -> "r15"
let print_reg32_name (r:reg_64) : string =
match r with
| 0 -> "eax"
| 1 -> "ebx"
| 2 -> "ecx"
| 3 -> "edx"
| 4 -> "esi"
| 5 -> "edi"
| 6 -> "ebp"
| 7 -> "esp"
| _ -> print_reg_name r ^ "d"
let print_small_reg_name (r:reg_64) : string =
match r with
| 0 -> "al"
| 1 -> "bl"
| 2 -> "cl"
| 3 -> "dl"
| _ -> " !!! INVALID small operand !!! Expected al, bl, cl, or dl."
let print_reg64 (r:reg_64) (p:printer) : string =
p.reg_prefix() ^ p.print_reg_name r
let print_reg32 (r:reg_64) (p:printer) : string =
p.reg_prefix() ^ p.print_reg32_name r
let print_small_reg (r:reg_64) (p:printer) : string =
p.reg_prefix() ^ p.print_small_reg_name r
let print_maddr (m:maddr) (ptr_type:string) (reg_printer:reg -> printer -> string) (p:printer) : string =
p.mem_prefix ptr_type ^
( match m with
| MConst n -> p.const n
| MReg r offset -> p.maddr (reg_printer r p) None (string_of_int offset)
| MIndex base scale index offset ->
p.maddr (reg_printer base p)
(Some (string_of_int scale, reg_printer index p))
(string_of_int offset)
)
open FStar.UInt64
let print_reg_int (r:reg) (p:printer) : string =
match r with
| Reg 0 r -> print_reg64 r p
| _ -> "!!! INVALID integer register !!!"
let print_operand (o:operand64) (p:printer) : string =
match o with
| OConst n ->
if 0 <= n && n < pow2_64 then p.const n
else "!!! INVALID constant: " ^ string_of_int n ^ " !!!"
| OReg r -> print_reg64 r p
| OMem (m, _) | OStack (m, _) -> print_maddr m "qword" print_reg_int p
let print_operand32 (o:operand64) (p:printer) : string =
match o with
| OConst n ->
if 0 <= n && n < pow2_32 then p.const n
else "!!! INVALID constant: " ^ string_of_int n ^ " !!!"
| OReg r -> print_reg32 r p
| OMem (m, _) | OStack (m, _) -> print_maddr m "dword" print_reg_int p
let print_small_operand (o:operand64) (p:printer) : string =
match o with
| OConst n ->
if n < 64 then p.const n
else "!!! INVALID constant: " ^ string_of_int n ^ " !!!!"
| OReg r -> print_small_reg r p
| _ -> "!!! INVALID small operand !!! Expected al, bl, cl, or dl." | false | true | Vale.X64.Print_s.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 print_imm8 (i: int) (p: printer) : string | [] | Vale.X64.Print_s.print_imm8 | {
"file_name": "vale/specs/hardware/Vale.X64.Print_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Prims.int -> p: Vale.X64.Print_s.printer -> Prims.string | {
"end_col": 11,
"end_line": 121,
"start_col": 2,
"start_line": 121
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.