file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.g25519_t | val g25519_t : Type0 | let g25519_t = x:glbuffer byte_t 32ul{witnessed x (Lib.Sequence.of_list S.basepoint_list) /\ recallable x} | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 106,
"end_line": 468,
"start_col": 0,
"start_line": 468
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1)
let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1)
inline_for_extraction noextract
val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1)
[@ Meta.Attribute.specialize ]
let decode_point #s o i =
push_frame();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x : felem s = sub o 0ul (nlimb s) in
let z : felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame()
val encode_point:
#s:field_spec
-> o:lbuffer uint8 32ul
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 i /\ disjoint o i /\
state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
as_seq h1 o == S.encodePoint (fget_x h0 i, fget_z h0 i))
[@ Meta.Attribute.specialize ]
let encode_point #s o i =
push_frame();
let x : felem s = sub i 0ul (nlimb s) in
let z : felem s = sub i (nlimb s) (nlimb s) in
let tmp = create_felem s in
let u64s = create 4ul (u64 0) in
let tmp_w = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let h0 = ST.get () in
finv tmp z tmp_w;
fmul tmp tmp x tmp_w;
let h1 = ST.get () in
assert (feval h1 tmp == S.fmul (S.fpow (feval h0 z) (pow2 255 - 21)) (feval h0 x));
assert (feval h1 tmp == S.fmul (feval h0 x) (S.fpow (feval h0 z) (pow2 255 - 21)));
store_felem u64s tmp;
let h2 = ST.get () in
assert (as_seq h2 u64s == BSeq.nat_to_intseq_le 4 (feval h1 tmp));
uints_to_bytes_le #U64 4ul o u64s;
let h3 = ST.get () in
BSeq.uints_to_bytes_le_nat_lemma #U64 #SEC 4 (feval h1 tmp);
assert (as_seq h3 o == BSeq.nat_to_bytes_le 32 (feval h1 tmp));
pop_frame()
// TODO: why re-define the signature here?
val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2))
[@ Meta.Attribute.inline_ ]
let cswap2 #s bit p0 p1 =
C.cswap2 #s bit p0 p1
val ladder_step:
#s:field_spec
-> k:scalar
-> q:point s
-> i:size_t{v i < 251}
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) = S.ladder_step (as_seq h0 k) (fget_xz h0 q) (v i)
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\
b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
#push-options "--z3rlimit 200 --fuel 0 --ifuel 1"
[@ Meta.Attribute.inline_ ]
let ladder_step #s k q i p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let swap : lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let nq = sub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 = sub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
let h0 = ST.get () in
let bit = scalar_bit k (253ul -. i) in
assert (v bit == v (S.ith_bit (as_seq h0 k) (253 - v i)));
let sw = swap.(0ul) ^. bit in
logxor_lemma1 (LSeq.index (as_seq h0 swap) 0) bit;
cswap2 #s sw nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- bit
#pop-options
#push-options "--z3rlimit 300 --fuel 1 --ifuel 1"
val ladder_step_loop:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) =
Lib.LoopCombinators.repeati 251
(S.ladder_step (as_seq h0 k) (fget_xz h0 q))
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder_step_loop #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
[@ inline_let]
let spec_fh h0 =
S.ladder_step (as_seq h0 k) (fget_x h0 q, fget_z h0 q) in
[@ inline_let]
let acc h : GTot (tuple3 S.proj_point S.proj_point uint64) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
(fget_xz h nq, fget_xz h nq_p1, LSeq.index (as_seq h bit) 0) in
[@ inline_let]
let inv h (i:nat{i <= 251}) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h /\
v (LSeq.index (as_seq h bit) 0) <= 1 /\
state_inv_t h (get_x q) /\ state_inv_t h (get_z q) /\
state_inv_t h (get_x nq) /\ state_inv_t h (get_z nq) /\
state_inv_t h (get_x nq_p1) /\ state_inv_t h (get_z nq_p1) /\
acc h == Lib.LoopCombinators.repeati i (spec_fh h0) (acc h0) in
Lib.Loops.for 0ul 251ul inv
(fun i ->
Lib.LoopCombinators.unfold_repeati 251 (spec_fh h0) (acc h0) (v i);
ladder_step #s k q i p01_tmp1_swap tmp2)
#pop-options
#push-options "--z3refresh --fuel 0 --ifuel 1 --z3rlimit 800"
val ladder0_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq ==
M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder0_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let swap:lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
// bit 255 is 0 and bit 254 is 1
cswap2 #s (u64 1) nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- u64 1;
//Got about 1K speedup by removing 4 iterations here.
//First iteration can be skipped because top bit of scalar is 0
ladder_step_loop #s k q p01_tmp1_swap tmp2;
let sw = swap.(0ul) in
cswap2 #s sw nq nq_p1
val ladder1_:
#s:field_spec
-> p01_tmp1:lbuffer (limb s) (8ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 p01_tmp1 /\ live h0 tmp2 /\ disjoint p01_tmp1 tmp2 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1 |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == M.montgomery_ladder1_1 (fget_xz h0 nq)))
[@ Meta.Attribute.inline_ ]
let ladder1_ #s p01_tmp1 tmp2 =
let nq : point s = sub p01_tmp1 0ul (2ul *! nlimb s) in
let tmp1 = sub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) in
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) == tmp1);
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2
val ladder2_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
(let nq' = M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1) in
fget_xz h1 nq == M.montgomery_ladder1_1 nq')))
[@ Meta.Attribute.inline_ ]
let ladder2_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
ladder0_ #s k q p01_tmp1_swap tmp2;
ladder1_ #s p01_tmp1 tmp2
inline_for_extraction noextract
val ladder3_:
#s:field_spec
-> q:point s
-> p01:lbuffer (limb s) (4ul *! nlimb s)
-> Stack unit
(requires fun h0 ->
live h0 q /\ live h0 p01 /\ disjoint q p01 /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01) h0 h1 /\
(let nq = gsub p01 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\
(fget_xz h1 q, fget_xz h1 nq, fget_xz h1 nq_p1) == M.montgomery_ladder1_2 (fget_x h0 q)))
let ladder3_ #s q p01 =
let p0 : point s = sub p01 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
copy p1 q;
let x0 : felem s = sub p0 0ul (nlimb s) in
let z0 : felem s = sub p0 (nlimb s) (nlimb s) in
set_one x0;
set_zero z0;
let h0 = ST.get () in
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
assert (gsub p0 0ul (nlimb s) == x0);
assert (gsub p0 (nlimb s) (nlimb s) == z0);
assert (fget_x h0 p1 == fget_x h0 q);
assert (fget_z h0 p1 == 1);
assert (fget_x h0 p0 == 1);
assert (fget_z h0 p0 == 0);
assert (
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x p0) /\ state_inv_t h0 (get_z p0) /\
state_inv_t h0 (get_x p1) /\ state_inv_t h0 (get_z p1))
val ladder4_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == S.montgomery_ladder (fget_x h0 q) (as_seq h0 k)))
[@ Meta.Attribute.inline_ ]
let ladder4_ #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
let p01 = sub p01_tmp1_swap 0ul (4ul *! nlimb s) in
let p0 : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (4ul *! nlimb s) == p01);
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
ladder3_ #s q p01;
ladder2_ #s k q p01_tmp1_swap tmp2;
let h1 = ST.get () in
assert (fget_xz h1 p0 == M.montgomery_ladder1 (fget_x h0 q) (as_seq h0 k));
M.lemma_montgomery_ladder (fget_x h0 q) (as_seq h0 k)
val montgomery_ladder:
#s:field_spec
-> o:point s
-> k:scalar
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 k /\ live h0 i /\
(disjoint o i \/ o == i) /\ disjoint o k /\ disjoint k i /\
fget_z h0 i == 1 /\ state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 ->
modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_xz h1 o == S.montgomery_ladder (fget_x h0 i) (as_seq h0 k))
[@ Meta.Attribute.specialize ]
let montgomery_ladder #s out key init =
push_frame();
let h0 = ST.get () in
let tmp2 = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let p01_tmp1_swap = create (8ul *! nlimb s +! 1ul) (limb_zero s) in
let p0 : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == p0);
ladder4_ #s key init p01_tmp1_swap tmp2;
copy out p0;
pop_frame ()
#pop-options
#push-options "--fuel 0 --ifuel 1 --z3rlimit 400" | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.glbuffer",
"Lib.IntTypes.byte_t",
"FStar.UInt32.__uint_to_t",
"Prims.l_and",
"Lib.Buffer.witnessed",
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.PUB",
"Spec.Curve25519.basepoint_list",
"Lib.Buffer.recallable",
"Lib.Buffer.CONST"
] | [] | false | false | false | true | true | let g25519_t =
| x: glbuffer byte_t 32ul {witnessed x (Lib.Sequence.of_list S.basepoint_list) /\ recallable x} | false |
|
Vale.Stdcalls.X64.GCM_IV.fst | Vale.Stdcalls.X64.GCM_IV.dom | val dom:dom: list td {List.length dom <= 20} | val dom:dom: list td {List.length dom <= 20} | let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in
assert_norm (List.length y = 6);
y | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 48,
"start_col": 0,
"start_line": 45
} | module Vale.Stdcalls.X64.GCM_IV
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module GC = Vale.AES.X64.GCMencryptOpt
open Vale.AES.GCM_s
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCM_IV.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": "GC"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"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": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dom: Prims.list Vale.Interop.Base.td {FStar.List.Tot.Base.length dom <= 20} | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list",
"Prims.Cons",
"Vale.Stdcalls.X64.GCM_IV.t128_no_mod",
"Vale.Stdcalls.X64.GCM_IV.tuint64",
"Vale.Stdcalls.X64.GCM_IV.t128_mod",
"Prims.Nil"
] | [] | false | false | false | false | false | let dom:dom: list td {List.length dom <= 20} =
| let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in
assert_norm (List.length y = 6);
y | false |
Vale.Stdcalls.X64.GCM_IV.fst | Vale.Stdcalls.X64.GCM_IV.lowstar_compute_iv | val lowstar_compute_iv (iv: Ghost.erased supported_iv_LE) : lowstar_compute_iv_t iv | val lowstar_compute_iv (iv: Ghost.erased supported_iv_LE) : lowstar_compute_iv_t iv | let lowstar_compute_iv (iv:Ghost.erased supported_iv_LE) : lowstar_compute_iv_t iv =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_compute_iv
dom
(W.mk_prediction code_compute_iv dom [] ((compute_iv_lemma iv) code_compute_iv IA.win)) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 91,
"end_line": 149,
"start_col": 0,
"start_line": 144
} | module Vale.Stdcalls.X64.GCM_IV
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module GC = Vale.AES.X64.GCMencryptOpt
open Vale.AES.GCM_s
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in
assert_norm (List.length y = 6);
y
[@__reduce__] noextract
let compute_iv_pre : (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state) ->
GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
[@__reduce__] noextract
let compute_iv_post : (Ghost.erased supported_iv_LE) -> VSig.vale_post dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
va_s1 f
#set-options "--z3rlimit 50"
[@__reduce__] noextract
let compute_iv_lemma'
(iv:Ghost.erased supported_iv_LE)
(code:V.va_code)
(_win:bool)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer iv_b) /\
ME.buffer_writeable (as_vale_buffer hkeys_b) /\
ME.buffer_writeable (as_vale_buffer iv_extra_b) /\
ME.buffer_writeable (as_vale_buffer j0_b))
) = let va_s1, f = GC.va_lemma_Compute_iv_stdcall code va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_extra_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 j0_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b;
va_s1, f
(* Prove that compute1_iv_lemma' has the required type *)
noextract
let compute_iv_lemma (iv:Ghost.erased supported_iv_LE) = as_t
#(VSig.vale_sig_stdcall (compute_iv_pre iv) (compute_iv_post iv))
(compute_iv_lemma' iv)
noextract
let code_compute_iv = GC.va_code_Compute_iv_stdcall IA.win
(* Here's the type expected for the compute_iv wrapper *)
[@__reduce__] noextract
let lowstar_compute_iv_t (iv:Ghost.erased supported_iv_LE) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_compute_iv
dom
[]
_
_
(W.mk_prediction code_compute_iv dom [] ((compute_iv_lemma iv) code_compute_iv IA.win))
(* And here's the gcm wrapper itself *) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCM_IV.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": "GC"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"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": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE
-> Vale.Stdcalls.X64.GCM_IV.lowstar_compute_iv_t iv | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Vale.AES.GCM_s.supported_iv_LE",
"Vale.Interop.X64.wrap_weak_stdcall",
"Vale.Stdcalls.X64.GCM_IV.code_compute_iv",
"Vale.Stdcalls.X64.GCM_IV.dom",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_lemma",
"Vale.Interop.Assumptions.win",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list",
"Vale.Stdcalls.X64.GCM_IV.lowstar_compute_iv_t"
] | [] | false | false | false | false | false | let lowstar_compute_iv (iv: Ghost.erased supported_iv_LE) : lowstar_compute_iv_t iv =
| assert_norm (List.length dom + List.length ([] <: list arg) <= 20);
IX64.wrap_weak_stdcall code_compute_iv
dom
(W.mk_prediction code_compute_iv dom [] ((compute_iv_lemma iv) code_compute_iv IA.win)) | false |
Vale.Stdcalls.X64.GCM_IV.fst | Vale.Stdcalls.X64.GCM_IV.compute_iv_pre | val compute_iv_pre: (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom | val compute_iv_pre: (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom | let compute_iv_pre : (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state) ->
GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 65,
"start_col": 0,
"start_line": 52
} | module Vale.Stdcalls.X64.GCM_IV
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module GC = Vale.AES.X64.GCMencryptOpt
open Vale.AES.GCM_s
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in
assert_norm (List.length y = 6);
y | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCM_IV.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": "GC"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"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": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE
-> Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.GCM_IV.dom | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Vale.AES.GCM_s.supported_iv_LE",
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.GCM_IV.b128",
"Vale.Stdcalls.X64.GCM_IV.uint64",
"Vale.X64.Decls.va_state",
"Vale.AES.X64.GCMencryptOpt.va_req_Compute_iv_stdcall",
"Vale.Interop.Assumptions.win",
"FStar.Ghost.reveal",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.UInt64.v",
"Prims.prop"
] | [] | false | false | false | true | false | let compute_iv_pre: (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
| fun
(iv: Ghost.erased supported_iv_LE)
(c: V.va_code)
(iv_b: b128)
(num_bytes: uint64)
(len: uint64)
(j0_b: b128)
(iv_extra_b: b128)
(hkeys_b: b128)
(va_s0: V.va_state)
->
GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b)
(UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b)
(as_vale_buffer hkeys_b) | false |
Steel.ST.GenArraySwap.fst | Steel.ST.GenArraySwap.impl_jump | val impl_jump (n l idx: SZ.t)
: Pure SZ.t
(requires (SZ.v l < SZ.v n /\ SZ.v idx < SZ.v n))
(ensures (fun idx' -> SZ.v idx' == Prf.jump (SZ.v n) (SZ.v l) (SZ.v idx))) | val impl_jump (n l idx: SZ.t)
: Pure SZ.t
(requires (SZ.v l < SZ.v n /\ SZ.v idx < SZ.v n))
(ensures (fun idx' -> SZ.v idx' == Prf.jump (SZ.v n) (SZ.v l) (SZ.v idx))) | let impl_jump
(n: SZ.t)
(l: SZ.t)
(idx: SZ.t)
: Pure SZ.t
(requires (
SZ.v l < SZ.v n /\
SZ.v idx < SZ.v n
))
(ensures (fun idx' ->
SZ.v idx' == Prf.jump (SZ.v n) (SZ.v l) (SZ.v idx)
))
= Prf.jump_if (SZ.v n) (SZ.v l) () (SZ.v idx);
[@@inline_let]
let nl = n `SZ.sub` l in
if idx `SZ.gte` nl
then idx `SZ.sub` nl
else idx `SZ.add` l | {
"file_name": "lib/steel/Steel.ST.GenArraySwap.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 21,
"end_line": 394,
"start_col": 0,
"start_line": 377
} | module Steel.ST.GenArraySwap
open Steel.ST.GenElim
module Prf = Steel.ST.GenArraySwap.Proof
module R = Steel.ST.Reference
let gcd_inv_prop
(n0: nat)
(l0: nat)
(n: nat)
(l: nat)
(b: bool)
: Tot prop
= l0 < n0 /\
l < n /\
(Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\
b == (l > 0)
[@@__reduce__]
let gcd_inv0
(n0: SZ.t)
(l0: SZ.t)
(pn: R.ref SZ.t)
(pl: R.ref SZ.t)
(b: bool)
: Tot vprop
= exists_ (fun n -> exists_ (fun l ->
R.pts_to pn full_perm n `star`
R.pts_to pl full_perm l `star`
pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b)
))
let gcd_inv
(n0: SZ.t)
(l0: SZ.t)
(pn: R.ref SZ.t)
(pl: R.ref SZ.t)
(b: bool)
: Tot vprop
= gcd_inv0 n0 l0 pn pl b
let gcd_post
(n0: SZ.t)
(l0: SZ.t)
(res: SZ.t)
: Tot prop
= SZ.v l0 < SZ.v n0 /\
SZ.v res == (Prf.mk_bezout (SZ.v n0) (SZ.v l0)).d
#push-options "--z3rlimit 16"
#restart-solver
let gcd
(n0: SZ.t)
(l0: SZ.t)
: ST SZ.t
emp
(fun _ -> emp)
(SZ.v l0 < SZ.v n0)
(fun res -> gcd_post n0 l0 res)
= let res =
R.with_local n0 (fun pn ->
R.with_local l0 (fun pl ->
noop ();
rewrite (gcd_inv0 n0 l0 pn pl (l0 `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l0 `SZ.gt` 0sz));
Steel.ST.Loops.while_loop
(gcd_inv n0 l0 pn pl)
(fun _ ->
let gb = elim_exists () in
rewrite (gcd_inv n0 l0 pn pl gb) (gcd_inv0 n0 l0 pn pl gb);
let _ = gen_elim () in
let l = R.read pl in
[@@inline_let]
let b = l `SZ.gt` 0sz in
noop ();
rewrite (gcd_inv0 n0 l0 pn pl b) (gcd_inv n0 l0 pn pl b);
return b
)
(fun _ ->
rewrite (gcd_inv n0 l0 pn pl true) (gcd_inv0 n0 l0 pn pl true);
let _ = gen_elim () in
let n = R.read pn in
let l = R.read pl in
[@@inline_let]
let l' = SZ.rem n l in
R.write pn l;
R.write pl l';
rewrite (gcd_inv0 n0 l0 pn pl (l' `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l' `SZ.gt` 0sz));
noop ()
);
rewrite (gcd_inv n0 l0 pn pl false) (gcd_inv0 n0 l0 pn pl false);
let _ = gen_elim () in
let res = R.read pn in
return res
)
)
in
elim_pure (gcd_post n0 l0 res);
return res
#pop-options
let array_swap_partial_invariant
(#t: Type)
(n: nat)
(l: nat)
(bz: Prf.bezout n l)
(s0: Ghost.erased (Seq.seq t))
(s: Ghost.erased (Seq.seq t))
(i: nat)
: GTot prop
= n == Seq.length s0 /\
n == Seq.length s /\
0 < l /\
l < n /\
i <= bz.d /\
(forall (i': Prf.nat_up_to bz.d) .
(forall (j: Prf.nat_up_to bz.q_n) .
(i' < i) ==> (
let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in
Seq.index s idx == Seq.index s0 (Prf.jump n l idx)
))) /\
(forall (i': Prf.nat_up_to bz.d) .
(forall (j: Prf.nat_up_to bz.q_n) .
(i' > i) ==> (
let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in
Seq.index s idx == Seq.index s0 idx
)))
let array_swap_inner_invariant_prop
(#t: Type)
(n: nat)
(l: nat)
(bz: Prf.bezout n l)
(s0: Ghost.erased (Seq.seq t))
(s: Ghost.erased (Seq.seq t))
(i: nat)
(j: nat)
(idx: nat)
(b: bool)
: GTot prop
= Prf.array_swap_inner_invariant s0 n l bz s i j idx /\
(b == (j < bz.q_n - 1))
let array_swap_outer_invariant_prop
(#t: Type)
(n: nat)
(l: nat)
(bz: Prf.bezout n l)
(s0: Ghost.erased (Seq.seq t))
(s: Ghost.erased (Seq.seq t))
(i: nat)
(b: bool)
: GTot prop
= Prf.array_swap_outer_invariant s0 n l bz s i /\
(b == (i < bz.d))
[@@__reduce__]
let array_swap_outer_invariant_body0
(#t: Type)
(pts_to: array_pts_to_t t)
(pi: R.ref SZ.t)
(i: SZ.t)
(s: Ghost.erased (Seq.seq t))
: Tot vprop
=
R.pts_to pi full_perm i `star`
pts_to s
[@@erasable]
noeq
type array_swap_outer_invariant_t (t: Type)
= {
i: SZ.t;
s: Ghost.erased (Seq.seq t);
}
[@@__reduce__]
let array_swap_outer_invariant0
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(b: bool)
: Tot vprop
= exists_ (fun w ->
array_swap_outer_invariant_body0 pts_to pi w.i w.s `star`
pure (array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i) b)
)
let array_swap_outer_invariant
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(b: bool)
: Tot vprop
= array_swap_outer_invariant0 pts_to n l bz s0 pi b
let intro_array_swap_outer_invariant
(#opened: _)
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(b: bool)
(i: SZ.t)
(s: Ghost.erased (Seq.seq t))
: STGhost unit opened
(array_swap_outer_invariant_body0 pts_to pi i s)
(fun _ -> array_swap_outer_invariant pts_to n l bz s0 pi b)
(array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 s (SZ.v i) b)
(fun _ -> True)
= let w = {
i = i;
s = s;
}
in
rewrite (array_swap_outer_invariant_body0 pts_to pi i s) (array_swap_outer_invariant_body0 pts_to pi w.i w.s);
rewrite (array_swap_outer_invariant0 pts_to n l bz s0 pi b) (array_swap_outer_invariant pts_to n l bz s0 pi b)
let elim_array_swap_outer_invariant
(#opened: _)
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(b: bool)
: STGhost (array_swap_outer_invariant_t t) opened
(array_swap_outer_invariant pts_to n l bz s0 pi b)
(fun w -> array_swap_outer_invariant_body0 pts_to pi w.i w.s)
True
(fun w ->
array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i) b /\
True // (b == false ==> Ghost.reveal w.s `Seq.equal` (Seq.slice s0 (SZ.v l) (SZ.v n) `Seq.append` Seq.slice s0 0 (SZ.v l)))
)
= let w = elim_exists () in
let _ = gen_elim () in
// Classical.move_requires (array_swap_outer_invariant_prop_end (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i)) b;
noop ();
w
[@@erasable]
noeq
type array_swap_inner_invariant_t (t: Type)
= {
j: SZ.t;
idx: SZ.t;
s: Ghost.erased (Seq.seq t)
}
[@@__reduce__]
let array_swap_inner_invariant_body0
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(i: SZ.t)
(pj: R.ref SZ.t)
(pidx: R.ref SZ.t)
(b: bool)
(j: SZ.t)
(idx: SZ.t)
(s: Ghost.erased (Seq.seq t))
: Tot vprop
= R.pts_to pi full_perm i `star`
R.pts_to pj full_perm j `star`
R.pts_to pidx full_perm idx `star`
pts_to s
[@@__reduce__]
let array_swap_inner_invariant0
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(i: SZ.t)
(pj: R.ref SZ.t)
(pidx: R.ref SZ.t)
(b: bool)
: Tot vprop
= exists_ (fun w ->
array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b w.j w.idx w.s `star`
pure (array_swap_inner_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v i) (SZ.v w.j) (SZ.v w.idx) b)
)
let array_swap_inner_invariant
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(i: SZ.t)
(pj: R.ref SZ.t)
(pidx: R.ref SZ.t)
(b: bool)
: Tot vprop
= array_swap_inner_invariant0 pts_to n l bz s0 pi i pj pidx b
let intro_array_swap_inner_invariant
(#opened: _)
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(i: SZ.t)
(pj: R.ref SZ.t)
(pidx: R.ref SZ.t)
(b: bool)
(j: SZ.t)
(idx: SZ.t)
(s: Ghost.erased (Seq.seq t))
: STGhost unit opened
(array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b j idx s)
(fun _ -> array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx b)
(array_swap_inner_invariant_prop (SZ.v n) (SZ.v l) bz s0 s (SZ.v i) (SZ.v j) (SZ.v idx) b)
(fun _ -> True)
= let w = {
j = j;
idx = idx;
s = s;
}
in
rewrite
(array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b j idx s)
(array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b w.j w.idx w.s);
rewrite
(array_swap_inner_invariant0 pts_to n l bz s0 pi i pj pidx b)
(array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx b)
let elim_array_swap_inner_invariant
(#opened: _)
(#t: Type)
(pts_to: array_pts_to_t t)
(n: SZ.t)
(l: SZ.t)
(bz: Prf.bezout (SZ.v n) (SZ.v l))
(s0: Ghost.erased (Seq.seq t))
(pi: R.ref SZ.t)
(i: SZ.t)
(pj: R.ref SZ.t)
(pidx: R.ref SZ.t)
(b: bool)
: STGhost (array_swap_inner_invariant_t t) opened
(array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx b)
(fun w -> array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b w.j w.idx w.s)
True
(fun w -> array_swap_inner_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v i) (SZ.v w.j) (SZ.v w.idx) b)
= let w = elim_exists () in
elim_pure _;
w | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Reference.fsti.checked",
"Steel.ST.Loops.fsti.checked",
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.GenArraySwap.Proof.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenArraySwap.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.Reference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Steel.ST.GenArraySwap.Proof",
"short_module": "Prf"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "SZ"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: FStar.SizeT.t -> l: FStar.SizeT.t -> idx: FStar.SizeT.t -> Prims.Pure FStar.SizeT.t | Prims.Pure | [] | [] | [
"FStar.SizeT.t",
"FStar.SizeT.gte",
"FStar.SizeT.sub",
"Prims.bool",
"FStar.SizeT.add",
"Prims.unit",
"Steel.ST.GenArraySwap.Proof.jump_if",
"FStar.SizeT.v",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.nat",
"Steel.ST.GenArraySwap.Proof.jump"
] | [] | false | false | false | false | false | let impl_jump (n l idx: SZ.t)
: Pure SZ.t
(requires (SZ.v l < SZ.v n /\ SZ.v idx < SZ.v n))
(ensures (fun idx' -> SZ.v idx' == Prf.jump (SZ.v n) (SZ.v l) (SZ.v idx))) =
| Prf.jump_if (SZ.v n) (SZ.v l) () (SZ.v idx);
[@@ inline_let ]let nl = n `SZ.sub` l in
if idx `SZ.gte` nl then idx `SZ.sub` nl else idx `SZ.add` l | false |
Vale.Stdcalls.X64.GCM_IV.fst | Vale.Stdcalls.X64.GCM_IV.lowstar_compute_iv_t | val lowstar_compute_iv_t : iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Type0 | let lowstar_compute_iv_t (iv:Ghost.erased supported_iv_LE) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_compute_iv
dom
[]
_
_
(W.mk_prediction code_compute_iv dom [] ((compute_iv_lemma iv) code_compute_iv IA.win)) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 91,
"end_line": 140,
"start_col": 0,
"start_line": 132
} | module Vale.Stdcalls.X64.GCM_IV
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module GC = Vale.AES.X64.GCMencryptOpt
open Vale.AES.GCM_s
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in
assert_norm (List.length y = 6);
y
[@__reduce__] noextract
let compute_iv_pre : (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state) ->
GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
[@__reduce__] noextract
let compute_iv_post : (Ghost.erased supported_iv_LE) -> VSig.vale_post dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
va_s1 f
#set-options "--z3rlimit 50"
[@__reduce__] noextract
let compute_iv_lemma'
(iv:Ghost.erased supported_iv_LE)
(code:V.va_code)
(_win:bool)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer iv_b) /\
ME.buffer_writeable (as_vale_buffer hkeys_b) /\
ME.buffer_writeable (as_vale_buffer iv_extra_b) /\
ME.buffer_writeable (as_vale_buffer j0_b))
) = let va_s1, f = GC.va_lemma_Compute_iv_stdcall code va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_extra_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 j0_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b;
va_s1, f
(* Prove that compute1_iv_lemma' has the required type *)
noextract
let compute_iv_lemma (iv:Ghost.erased supported_iv_LE) = as_t
#(VSig.vale_sig_stdcall (compute_iv_pre iv) (compute_iv_post iv))
(compute_iv_lemma' iv)
noextract
let code_compute_iv = GC.va_code_Compute_iv_stdcall IA.win
(* Here's the type expected for the compute_iv wrapper *) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCM_IV.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": "GC"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"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": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Vale.AES.GCM_s.supported_iv_LE",
"Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall",
"Vale.Stdcalls.X64.GCM_IV.code_compute_iv",
"Vale.Stdcalls.X64.GCM_IV.dom",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_lemma",
"Vale.Interop.Assumptions.win",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list"
] | [] | false | false | false | true | true | let lowstar_compute_iv_t (iv: Ghost.erased supported_iv_LE) =
| assert_norm (List.length dom + List.length ([] <: list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall code_compute_iv
dom
[]
_
_
(W.mk_prediction code_compute_iv dom [] ((compute_iv_lemma iv) code_compute_iv IA.win)) | false |
|
Vale.Stdcalls.X64.GCM_IV.fst | Vale.Stdcalls.X64.GCM_IV.compute_iv_post | val compute_iv_post: (Ghost.erased supported_iv_LE) -> VSig.vale_post dom | val compute_iv_post: (Ghost.erased supported_iv_LE) -> VSig.vale_post dom | let compute_iv_post : (Ghost.erased supported_iv_LE) -> VSig.vale_post dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
va_s1 f | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 84,
"start_col": 0,
"start_line": 68
} | module Vale.Stdcalls.X64.GCM_IV
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module GC = Vale.AES.X64.GCMencryptOpt
open Vale.AES.GCM_s
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in
assert_norm (List.length y = 6);
y
[@__reduce__] noextract
let compute_iv_pre : (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state) ->
GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCM_IV.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": "GC"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"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": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE
-> Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.GCM_IV.dom | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Vale.AES.GCM_s.supported_iv_LE",
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.GCM_IV.b128",
"Vale.Stdcalls.X64.GCM_IV.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.AES.X64.GCMencryptOpt.va_ens_Compute_iv_stdcall",
"Vale.Interop.Assumptions.win",
"FStar.Ghost.reveal",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.UInt64.v",
"Prims.prop"
] | [] | false | false | false | true | false | let compute_iv_post: (Ghost.erased supported_iv_LE) -> VSig.vale_post dom =
| fun
(iv: Ghost.erased supported_iv_LE)
(c: V.va_code)
(iv_b: b128)
(num_bytes: uint64)
(len: uint64)
(j0_b: b128)
(iv_extra_b: b128)
(hkeys_b: b128)
(va_s0: V.va_state)
(va_s1: V.va_state)
(f: V.va_fuel)
->
GC.va_ens_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b)
(UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b)
(as_vale_buffer hkeys_b) va_s1 f | false |
Spec.Frodo.Test.fst | Spec.Frodo.Test.test1_sk_expected | val test1_sk_expected : Prims.list Lib.IntTypes.uint8 | let test1_sk_expected =
List.Tot.map u8_from_UInt8
[
0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy;
0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x0duy; 0xacuy; 0x6fuy; 0x83uy; 0x94uy; 0x00uy; 0x1auy; 0xcauy;
0x97uy; 0xa1uy; 0xaauy; 0x42uy; 0x80uy; 0x9duy; 0x6buy; 0xa5uy; 0xfcuy; 0x64uy; 0x43uy; 0xdbuy;
0xbeuy; 0x6fuy; 0x12uy; 0x2auy; 0x94uy; 0x58uy; 0x36uy; 0xf2uy; 0xb1uy; 0xf8uy; 0xe5uy; 0xf0uy;
0x57uy; 0x4buy; 0x35uy; 0x51uy; 0xdduy; 0x8cuy; 0x36uy; 0x28uy; 0x34uy; 0x46uy; 0xd6uy; 0xafuy;
0x5duy; 0x49uy; 0x0euy; 0x27uy; 0xd8uy; 0xd3uy; 0xaduy; 0xe1uy; 0xeduy; 0x8buy; 0x2duy; 0x13uy;
0xf5uy; 0x5auy; 0xb6uy; 0xdduy; 0xc0uy; 0x54uy; 0x76uy; 0x09uy; 0xa6uy; 0xa4uy; 0x01uy; 0xb9uy;
0xb7uy; 0xd1uy; 0x26uy; 0xd5uy; 0x1euy; 0xa8uy; 0x20uy; 0x4duy; 0xe8uy; 0xefuy; 0xaduy; 0xb9uy;
0xf0uy; 0x65uy; 0xe9uy; 0xc4uy; 0xf4uy; 0x11uy; 0x98uy; 0x99uy; 0xf0uy; 0x2cuy; 0x63uy; 0x7buy;
0x98uy; 0xd7uy; 0x60uy; 0x43uy; 0x5duy; 0x8cuy; 0x85uy; 0xe9uy; 0xc5uy; 0x83uy; 0x83uy; 0x62uy;
0xe2uy; 0x13uy; 0x33uy; 0x54uy; 0x4buy; 0x71uy; 0xaeuy; 0x63uy; 0xbauy; 0x5auy; 0x4euy; 0x32uy;
0x59uy; 0x78uy; 0x6buy; 0x4duy; 0x39uy; 0xcfuy; 0xe1uy; 0x82uy; 0x58uy; 0x0auy; 0xc3uy; 0x61uy;
0x6auy; 0x89uy; 0x2fuy; 0x1buy; 0x70uy; 0xdduy; 0x16uy; 0x3euy; 0x96uy; 0xb1uy; 0x4cuy; 0x71uy;
0xb1uy; 0x79uy; 0x0cuy; 0x3fuy; 0xe2uy; 0xeduy; 0x05uy; 0x07uy; 0x72uy; 0xf3uy; 0x89uy; 0x08uy;
0x8cuy; 0x22uy; 0xa7uy; 0x36uy; 0x40uy; 0xcauy; 0x52uy; 0x70uy; 0x1buy; 0x09uy; 0xcbuy; 0xabuy;
0x3buy; 0x64uy; 0x61uy; 0x6duy; 0x5duy; 0xf7uy; 0x15uy; 0x69uy; 0x71uy; 0x3buy; 0x3auy; 0x2euy;
0x53uy; 0x33uy; 0x26uy; 0xe6uy; 0x29uy; 0x5cuy; 0xfbuy; 0x0duy; 0xc6uy; 0xe4uy; 0xbduy; 0x9cuy;
0x43uy; 0xffuy; 0xa6uy; 0x5buy; 0x49uy; 0x47uy; 0x93uy; 0x1cuy; 0x81uy; 0x6fuy; 0xd4uy; 0xaauy;
0x3duy; 0xaduy; 0x86uy; 0xf5uy; 0x94uy; 0x16uy; 0x7fuy; 0x31uy; 0x91uy; 0x30uy; 0x97uy; 0xc4uy;
0xa3uy; 0xe4uy; 0x01uy; 0x2buy; 0x06uy; 0xcfuy; 0x69uy; 0xfbuy; 0x69uy; 0x35uy; 0xaauy; 0x81uy;
0xeduy; 0x90uy; 0x0cuy; 0x3auy; 0xc0uy; 0xa6uy; 0x06uy; 0xabuy; 0x51uy; 0x3fuy; 0x39uy; 0xb2uy;
0x1euy; 0xb0uy; 0x4buy; 0xbcuy; 0xd0uy; 0xd0uy; 0x3auy; 0xdauy; 0x89uy; 0x88uy; 0xa6uy; 0x56uy;
0xd8uy; 0x02uy; 0x98uy; 0xeeuy; 0xa2uy; 0xf5uy; 0x0euy; 0xbauy; 0x7cuy; 0x52uy; 0xafuy; 0xf4uy;
0xbbuy; 0xe7uy; 0x36uy; 0x4auy; 0xdduy; 0x90uy; 0x93uy; 0xe9uy; 0x5duy; 0xbeuy; 0x68uy; 0x99uy;
0xc2uy; 0xaduy; 0x4duy; 0x79uy; 0x25uy; 0x0buy; 0x69uy; 0x79uy; 0x7buy; 0xe2uy; 0x3duy; 0xa8uy;
0xe7uy; 0xf1uy; 0x42uy; 0x0cuy; 0x22uy; 0x85uy; 0x95uy; 0xf0uy; 0xd5uy; 0x5cuy; 0x96uy; 0x35uy;
0xb6uy; 0x19uy; 0xaeuy; 0xb3uy; 0xcfuy; 0x22uy; 0xcauy; 0xbauy; 0x28uy; 0xd6uy; 0xdduy; 0xd5uy;
0x8euy; 0xe8uy; 0xd6uy; 0x90uy; 0x23uy; 0x8euy; 0x97uy; 0x37uy; 0xe9uy; 0xcduy; 0xabuy; 0xdcuy;
0x08uy; 0x04uy; 0xe1uy; 0x32uy; 0x02uy; 0xffuy; 0x7fuy; 0x82uy; 0x41uy; 0xf3uy; 0x9buy; 0x1duy;
0x42uy; 0x8auy; 0x98uy; 0x80uy; 0x81uy; 0xaauy; 0xbeuy; 0x7duy; 0x3buy; 0x83uy; 0x30uy; 0x4duy;
0x4auy; 0x22uy; 0x2duy; 0xafuy; 0x61uy; 0xd1uy; 0xa0uy; 0x66uy; 0xd4uy; 0x48uy; 0x0fuy; 0xe1uy;
0xd9uy; 0x77uy; 0x82uy; 0xc5uy; 0xa1uy; 0x2auy; 0x03uy; 0x1fuy; 0xd0uy; 0x7auy; 0xccuy; 0x77uy;
0x09uy; 0x4auy; 0xbduy; 0xaduy; 0xf7uy; 0x76uy; 0xdcuy; 0x10uy; 0xeduy; 0x5buy; 0xdfuy; 0x89uy;
0xfbuy; 0x52uy; 0x60uy; 0x5cuy; 0x08uy; 0x42uy; 0x50uy; 0xd1uy; 0xdauy; 0x24uy; 0xbbuy; 0x59uy;
0x3euy; 0x14uy; 0xf4uy; 0xf0uy; 0xf4uy; 0xdauy; 0xb8uy; 0x00uy; 0xe2uy; 0x0buy; 0xfauy; 0xc3uy;
0xf6uy; 0x28uy; 0x8duy; 0x20uy; 0x26uy; 0xe9uy; 0x5buy; 0x25uy; 0xa8uy; 0x80uy; 0x4cuy; 0xeeuy;
0xc9uy; 0xb6uy; 0x7auy; 0x8buy; 0x87uy; 0x21uy; 0xfduy; 0xaeuy; 0xd5uy; 0xa8uy; 0x49uy; 0x33uy;
0x58uy; 0x90uy; 0x2cuy; 0x0auy; 0xcauy; 0xb0uy; 0x9duy; 0xbeuy; 0xcduy; 0xe0uy; 0xa4uy; 0x99uy;
0x76uy; 0x01uy; 0x80uy; 0xdduy; 0x66uy; 0x76uy; 0x70uy; 0x05uy; 0xf3uy; 0xd6uy; 0x31uy; 0xa1uy;
0x9euy; 0xd5uy; 0x5fuy; 0x1buy; 0xdduy; 0x7fuy; 0x81uy; 0x6duy; 0x5cuy; 0xe9uy; 0xa3uy; 0x1auy;
0x6auy; 0x87uy; 0x93uy; 0xaduy; 0x1duy; 0x73uy; 0x44uy; 0xbcuy; 0xe4uy; 0x42uy; 0x78uy; 0x6auy;
0x71uy; 0x58uy; 0x9buy; 0x73uy; 0x55uy; 0x63uy; 0xa5uy; 0x32uy; 0xf6uy; 0x55uy; 0x68uy; 0x05uy;
0xcfuy; 0xeduy; 0x5fuy; 0x86uy; 0xe2uy; 0x65uy; 0xefuy; 0xf1uy; 0xb9uy; 0x69uy; 0xbbuy; 0x79uy;
0xb1uy; 0xf4uy; 0x7fuy; 0xa5uy; 0xfauy; 0x62uy; 0xbcuy; 0x68uy; 0xe7uy; 0xf6uy; 0xf8uy; 0xf0uy;
0x55uy; 0xf4uy; 0x93uy; 0x47uy; 0x06uy; 0xf0uy; 0x3euy; 0x94uy; 0x4auy; 0x95uy; 0xc8uy; 0x0cuy;
0xb0uy; 0x04uy; 0x4euy; 0x3fuy; 0x67uy; 0x14uy; 0xeduy; 0xbbuy; 0xbeuy; 0xf0uy; 0xabuy; 0xdduy;
0x6cuy; 0x23uy; 0x4euy; 0x07uy; 0x66uy; 0x41uy; 0x55uy; 0xbeuy; 0x22uy; 0x59uy; 0xd5uy; 0xdauy;
0xd4uy; 0xd8uy; 0x3duy; 0xb0uy; 0x74uy; 0xc4uy; 0x4fuy; 0x9buy; 0x43uy; 0xe5uy; 0x75uy; 0xfbuy;
0x33uy; 0x0euy; 0xdfuy; 0xe1uy; 0xe3uy; 0x7duy; 0x2euy; 0x80uy; 0x10uy; 0x79uy; 0x17uy; 0xeauy;
0xd3uy; 0x18uy; 0x98uy; 0x08uy; 0xeduy; 0x79uy; 0x4cuy; 0xb9uy; 0x66uy; 0x03uy; 0x04uy; 0x50uy;
0xfeuy; 0x62uy; 0x0duy; 0x48uy; 0x1auy; 0x6cuy; 0xeeuy; 0xb7uy; 0x03uy; 0x15uy; 0x92uy; 0x41uy;
0x1euy; 0xa1uy; 0x88uy; 0x46uy; 0x1auy; 0x43uy; 0x49uy; 0xf5uy; 0x93uy; 0x33uy; 0x00uy; 0x65uy;
0x69uy; 0xa8uy; 0x82uy; 0xbduy; 0xbeuy; 0x5cuy; 0x56uy; 0xa3uy; 0x06uy; 0x00uy; 0x8buy; 0x2fuy;
0x7duy; 0xecuy; 0xa4uy; 0x9auy; 0x2auy; 0xaeuy; 0x66uy; 0x07uy; 0x46uy; 0xb3uy; 0xbeuy; 0xf8uy;
0x07uy; 0x08uy; 0x10uy; 0x87uy; 0xd5uy; 0x6cuy; 0x6auy; 0xa5uy; 0xa6uy; 0x07uy; 0x4buy; 0x00uy;
0xc1uy; 0x5auy; 0xeduy; 0x7fuy; 0x14uy; 0x4buy; 0x60uy; 0x02uy; 0xc2uy; 0x67uy; 0x0cuy; 0xa4uy;
0x64uy; 0x54uy; 0x3euy; 0x22uy; 0xfeuy; 0x21uy; 0xcduy; 0x0duy; 0xcbuy; 0x60uy; 0x3buy; 0x13uy;
0xb0uy; 0x8euy; 0x36uy; 0xcauy; 0xcduy; 0x78uy; 0x8duy; 0x08uy; 0x2auy; 0xf1uy; 0x9cuy; 0x17uy;
0x11uy; 0x14uy; 0x57uy; 0x57uy; 0xe8uy; 0x3buy; 0x84uy; 0xe8uy; 0x59uy; 0xdbuy; 0x5buy; 0x77uy;
0x2euy; 0x54uy; 0x3buy; 0x6euy; 0x9cuy; 0x5euy; 0x7fuy; 0x52uy; 0xe5uy; 0x06uy; 0x8auy; 0x2duy;
0xc3uy; 0xbfuy; 0x30uy; 0x34uy; 0x8cuy; 0xaauy; 0x3buy; 0x23uy; 0x59uy; 0x32uy; 0x5fuy; 0xf7uy;
0xc9uy; 0xb2uy; 0xeeuy; 0xb2uy; 0x72uy; 0x75uy; 0x33uy; 0x8euy; 0xa9uy; 0x68uy; 0x6euy; 0xf5uy;
0x61uy; 0x7auy; 0x20uy; 0x01uy; 0xecuy; 0xabuy; 0x19uy; 0x26uy; 0xbeuy; 0x38uy; 0x49uy; 0xe2uy;
0x16uy; 0xceuy; 0x17uy; 0xafuy; 0xcauy; 0xe3uy; 0x06uy; 0xeauy; 0x37uy; 0x98uy; 0xf2uy; 0x8fuy;
0x04uy; 0x9buy; 0xabuy; 0xd8uy; 0xbduy; 0x78uy; 0x68uy; 0xacuy; 0xefuy; 0xb9uy; 0x28uy; 0x6fuy;
0x0buy; 0x37uy; 0x90uy; 0xb3uy; 0x74uy; 0x0cuy; 0x38uy; 0x12uy; 0x70uy; 0xa2uy; 0xbeuy; 0xdcuy;
0xa7uy; 0x18uy; 0xdfuy; 0x5euy; 0xd2uy; 0x62uy; 0xccuy; 0x43uy; 0x24uy; 0x32uy; 0x58uy; 0x45uy;
0x18uy; 0x0auy; 0xe1uy; 0x0duy; 0x82uy; 0xbcuy; 0x08uy; 0xb1uy; 0xa9uy; 0x7euy; 0x63uy; 0x09uy;
0xc6uy; 0x83uy; 0xa1uy; 0xe6uy; 0x5cuy; 0x9cuy; 0xefuy; 0x57uy; 0xecuy; 0xc7uy; 0x73uy; 0x19uy;
0xfbuy; 0x5cuy; 0x20uy; 0xe1uy; 0xdfuy; 0x85uy; 0x76uy; 0xabuy; 0x89uy; 0xb7uy; 0x96uy; 0x8duy;
0xd9uy; 0x8euy; 0xb7uy; 0x00uy; 0xa8uy; 0xc6uy; 0x98uy; 0x47uy; 0x03uy; 0xafuy; 0x56uy; 0x1fuy;
0x35uy; 0x49uy; 0x75uy; 0x4cuy; 0xa2uy; 0xa2uy; 0xdcuy; 0x98uy; 0xbfuy; 0x87uy; 0xeduy; 0x73uy;
0x5fuy; 0x9buy; 0xabuy; 0x3euy; 0x02uy; 0xdcuy; 0xa1uy; 0x4buy; 0x6cuy; 0xacuy; 0x10uy; 0xb2uy;
0x0buy; 0x99uy; 0xeeuy; 0xc8uy; 0xc2uy; 0x82uy; 0xa9uy; 0xf9uy; 0xa9uy; 0xa5uy; 0x4duy; 0xc9uy;
0x39uy; 0x41uy; 0x89uy; 0x0cuy; 0xc6uy; 0xe3uy; 0xaauy; 0x76uy; 0xe7uy; 0x11uy; 0x16uy; 0x8auy;
0x28uy; 0x6buy; 0x22uy; 0x3auy; 0x1euy; 0x7duy; 0xe6uy; 0xf7uy; 0x55uy; 0x85uy; 0x8cuy; 0x36uy;
0x57uy; 0x0buy; 0xdbuy; 0xe6uy; 0xefuy; 0xd9uy; 0xf6uy; 0x94uy; 0x48uy; 0x31uy; 0x7euy; 0xaauy;
0x13uy; 0xd4uy; 0x58uy; 0x9buy; 0xebuy; 0x7cuy; 0x2auy; 0x39uy; 0xdduy; 0xa3uy; 0x3fuy; 0x70uy;
0xfduy; 0x7fuy; 0x30uy; 0xa3uy; 0x34uy; 0xe6uy; 0xacuy; 0x64uy; 0x9buy; 0xf8uy; 0xbbuy; 0x1euy;
0x51uy; 0xe1uy; 0xaduy; 0x61uy; 0xf6uy; 0xffuy; 0xd4uy; 0x4auy; 0x5euy; 0x12uy; 0x40uy; 0xdcuy;
0x07uy; 0x8buy; 0xb2uy; 0xe0uy; 0xb9uy; 0x29uy; 0xaauy; 0x4euy; 0x85uy; 0xf5uy; 0xbduy; 0x5buy;
0x43uy; 0x77uy; 0xc7uy; 0x0buy; 0xfeuy; 0x66uy; 0x49uy; 0xccuy; 0xb5uy; 0x92uy; 0x4auy; 0x14uy;
0x1euy; 0xe2uy; 0xe5uy; 0x20uy; 0xfauy; 0xecuy; 0x0fuy; 0xc9uy; 0x02uy; 0x00uy; 0xffuy; 0xffuy;
0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0xfduy; 0xffuy; 0x02uy; 0x00uy; 0x05uy; 0x00uy;
0x04uy; 0x00uy; 0xfauy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0xfduy; 0xffuy; 0xfduy; 0xffuy;
0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x03uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xfbuy; 0xffuy;
0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy;
0xfauy; 0xffuy; 0xfduy; 0xffuy; 0x04uy; 0x00uy; 0xffuy; 0xffuy; 0x05uy; 0x00uy; 0x05uy; 0x00uy;
0xfeuy; 0xffuy; 0x03uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0xfduy; 0xffuy; 0x02uy; 0x00uy;
0xffuy; 0xffuy; 0xfduy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy;
0x06uy; 0x00uy; 0xffuy; 0xffuy; 0x03uy; 0x00uy; 0x03uy; 0x00uy; 0xfduy; 0xffuy; 0x04uy; 0x00uy;
0x01uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x07uy; 0x00uy; 0xfcuy; 0xffuy; 0x05uy; 0x00uy;
0x04uy; 0x00uy; 0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0xfduy; 0xffuy; 0xfeuy; 0xffuy; 0xfduy; 0xffuy;
0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0x03uy; 0x00uy; 0x02uy; 0x00uy; 0x02uy; 0x00uy;
0x03uy; 0x00uy; 0x06uy; 0x00uy; 0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0x06uy; 0x00uy;
0x02uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xffuy; 0xffuy;
0x04uy; 0x00uy; 0xffuy; 0xffuy; 0x03uy; 0x00uy; 0xfduy; 0xffuy; 0xfduy; 0xffuy; 0xffuy; 0xffuy;
0x03uy; 0x00uy; 0xfduy; 0xffuy; 0xfduy; 0xffuy; 0x03uy; 0x00uy; 0x04uy; 0x00uy; 0x03uy; 0x00uy;
0xfduy; 0xffuy; 0x02uy; 0x00uy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0xffuy; 0xffuy; 0x04uy; 0x00uy;
0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xfcuy; 0xffuy; 0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy;
0xfduy; 0xffuy; 0x02uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy;
0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0xfduy; 0xffuy;
0xffuy; 0xffuy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0xfbuy; 0xffuy; 0x03uy; 0x00uy; 0xfcuy; 0xffuy;
0x04uy; 0x00uy; 0xfbuy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x02uy; 0x00uy; 0x04uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x02uy; 0x00uy;
0xffuy; 0xffuy; 0xfcuy; 0xffuy; 0x06uy; 0x00uy; 0x02uy; 0x00uy; 0x03uy; 0x00uy; 0xfeuy; 0xffuy;
0xffuy; 0xffuy; 0xfduy; 0xffuy; 0xfeuy; 0xffuy; 0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0x04uy; 0x00uy;
0x04uy; 0x00uy; 0xfcuy; 0xffuy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy; 0x05uy; 0x00uy; 0x01uy; 0x00uy;
0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xfauy; 0xffuy; 0x00uy; 0x00uy; 0x02uy; 0x00uy; 0x02uy; 0x00uy;
0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x07uy; 0x00uy;
0x04uy; 0x00uy; 0x03uy; 0x00uy; 0x01uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x01uy; 0x00uy;
0xfeuy; 0xffuy; 0xfduy; 0xffuy; 0x04uy; 0x00uy; 0x01uy; 0x00uy; 0x03uy; 0x00uy; 0xffuy; 0xffuy;
0x02uy; 0x00uy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy; 0xffuy; 0xffuy;
0x02uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xfbuy; 0xffuy; 0x04uy; 0x00uy;
0x02uy; 0x00uy; 0xfduy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x01uy; 0x00uy;
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0xffuy; 0xffuy;
0x03uy; 0x00uy; 0xfcuy; 0xffuy; 0xfduy; 0xffuy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0x03uy; 0x00uy;
0xffuy; 0xffuy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x04uy; 0x00uy; 0x01uy; 0x00uy;
0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x02uy; 0x00uy;
0x00uy; 0x00uy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x08uy; 0x00uy; 0xfduy; 0xffuy;
0x03uy; 0x00uy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy; 0x02uy; 0x00uy; 0xffuy; 0xffuy; 0xfbuy; 0xffuy;
0x00uy; 0x00uy; 0xfbuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x04uy; 0x00uy; 0x01uy; 0x00uy;
0x03uy; 0x00uy; 0x01uy; 0x00uy; 0xfduy; 0xffuy; 0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy;
0x01uy; 0x00uy; 0xfcuy; 0xffuy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0xfcuy; 0xffuy; 0xfauy; 0xffuy;
0xfauy; 0xffuy; 0xfcuy; 0xffuy; 0xfbuy; 0xffuy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xfduy; 0xffuy;
0x01uy; 0x00uy; 0x05uy; 0x00uy; 0xfbuy; 0xffuy; 0xfduy; 0xffuy; 0xfcuy; 0xffuy; 0x05uy; 0x00uy;
0xfduy; 0xffuy; 0xfbuy; 0xffuy; 0xfduy; 0xffuy; 0xfbuy; 0xffuy; 0x03uy; 0x00uy; 0x03uy; 0x00uy;
0xfcuy; 0xffuy; 0xfduy; 0xffuy; 0x02uy; 0x00uy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0x01uy; 0x00uy;
0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0xfbuy; 0xffuy; 0xfeuy; 0xffuy; 0xfeuy; 0xffuy;
0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0x02uy; 0x00uy; 0xfduy; 0xffuy; 0xfeuy; 0xffuy;
0xfeuy; 0xffuy; 0x02uy; 0x00uy; 0xfduy; 0xffuy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy;
0x01uy; 0x00uy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0x06uy; 0x00uy; 0x04uy; 0x00uy;
0xfauy; 0xffuy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0x02uy; 0x00uy; 0x05uy; 0x00uy; 0xffuy; 0xffuy;
0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x04uy; 0x00uy; 0xfcuy; 0xffuy; 0xfduy; 0xffuy;
0xfduy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xfduy; 0xffuy;
0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy;
0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x02uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0xfcuy; 0xffuy;
0x03uy; 0x00uy; 0x08uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy;
0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x06uy; 0x00uy; 0xfeuy; 0xffuy; 0x02uy; 0x00uy;
0x09uy; 0x00uy; 0xffuy; 0xffuy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0xfauy; 0xffuy; 0xfduy; 0xffuy;
0x01uy; 0x00uy; 0x06uy; 0x00uy; 0x03uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy;
0xfbuy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy;
0xfcuy; 0xffuy; 0xfbuy; 0xffuy; 0x04uy; 0x00uy; 0xfduy; 0xffuy; 0x00uy; 0x00uy; 0x05uy; 0x00uy;
0xfduy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xfcuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy;
0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xfcuy; 0xffuy; 0x00uy; 0x00uy; 0xfeuy; 0xffuy;
0x01uy; 0x00uy; 0x01uy; 0x00uy; 0xfbuy; 0xffuy; 0xfcuy; 0xffuy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy;
0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0x01uy; 0x00uy; 0xfduy; 0xffuy; 0x01uy; 0x00uy;
0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0x03uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy;
0xffuy; 0xffuy; 0x03uy; 0x00uy; 0xfeuy; 0xffuy; 0x02uy; 0x00uy; 0x03uy; 0x00uy; 0xfbuy; 0xffuy;
0x00uy; 0x00uy; 0xfduy; 0xffuy; 0xf9uy; 0xffuy; 0x04uy; 0x00uy; 0x02uy; 0x00uy; 0x02uy; 0x00uy;
0xfcuy; 0xffuy; 0x03uy; 0x00uy; 0xfduy; 0xffuy; 0x03uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy;
0xf7uy; 0xffuy; 0xfduy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0x04uy; 0x00uy; 0x04uy; 0x00uy;
0xfduy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0x03uy; 0x00uy; 0x03uy; 0x00uy;
0x04uy; 0x00uy; 0x05uy; 0x00uy; 0xfduy; 0xffuy; 0xfauy; 0xffuy; 0x01uy; 0x00uy; 0xf8uy; 0xffuy;
0x01uy; 0x00uy; 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0xfduy; 0xffuy; 0xfbuy; 0xffuy; 0x00uy; 0x00uy;
0x02uy; 0x00uy; 0xfauy; 0xffuy; 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x02uy; 0x00uy; 0x03uy; 0x00uy;
0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0x03uy; 0x00uy; 0xffuy; 0xffuy; 0x02uy; 0x00uy;
0xfbuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xfduy; 0xffuy; 0x02uy; 0x00uy; 0xfcuy; 0xffuy;
0x01uy; 0x00uy; 0x02uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x03uy; 0x00uy; 0x02uy; 0x00uy;
0x01uy; 0x00uy; 0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0xfcuy; 0xffuy; 0xfcuy; 0xffuy; 0x01uy; 0x00uy;
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x03uy; 0x00uy;
0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xfduy; 0xffuy; 0xfeuy; 0xffuy; 0xfduy; 0xffuy; 0x03uy; 0x00uy;
0xffuy; 0xffuy; 0xfeuy; 0xffuy; 0xfduy; 0xffuy; 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy;
0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0x05uy; 0x00uy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0xfduy; 0xffuy;
0xfduy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy;
0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x04uy; 0x00uy; 0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0x02uy; 0x00uy;
0xf9uy; 0xffuy; 0x02uy; 0x00uy; 0x08uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy;
0xb6uy; 0x27uy; 0xd5uy; 0x5euy; 0x52uy; 0xfduy; 0x89uy; 0x2euy; 0x92uy; 0x59uy; 0x69uy; 0xe7uy;
0x32uy; 0xb2uy; 0xacuy; 0x21uy
] | {
"file_name": "specs/tests/Spec.Frodo.Test.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 433,
"start_col": 0,
"start_line": 260
} | module Spec.Frodo.Test
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Frodo.KEM
open Spec.Frodo.KEM.KeyGen
open Spec.Frodo.KEM.Encaps
open Spec.Frodo.KEM.Decaps
open Spec.Frodo.Params
open FStar.All
module PS = Lib.PrintSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1"
let compare (#len: size_nat) (test_expected: lbytes len) (test_result: lbytes len) =
for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result
let test_frodo
(a:frodo_alg)
(gen_a:frodo_gen_a)
(keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a})
(enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a})
(ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a})
(pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a})
(ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a})
(sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a})
: ML bool =
let keypaircoins = createL keypaircoins in
let enccoins = createL enccoins in
let ss_expected = createL ss_expected in
let pk_expected = createL pk_expected in
let ct_expected = createL ct_expected in
let sk_expected = createL sk_expected in
let pk, sk = crypto_kem_keypair_ a gen_a keypaircoins in
let ct, ss1 = crypto_kem_enc_ a gen_a enccoins pk in
let ss2 = crypto_kem_dec a gen_a ct sk in
let r_pk = compare pk_expected pk in
let r_sk = compare sk_expected sk in
let r_ct = compare ct_expected ct in
let r_ss = PS.print_compare true (crypto_bytes a) ss1 ss2 in
let r_ss1 = PS.print_compare true (crypto_bytes a) ss_expected ss2 in
r_pk && r_sk && r_ct && r_ss && r_ss1
//
// Test1. FrodoKEM-64. SHAKE128
//
let test1_keypaircoins =
List.Tot.map u8_from_UInt8
[
0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy;
0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x90uy; 0x30uy; 0x33uy; 0x55uy; 0x33uy; 0x84uy; 0x2euy; 0xe4uy;
0x4cuy; 0x55uy; 0x8fuy; 0xd8uy; 0xaeuy; 0x4buy; 0x4euy; 0x91uy; 0x62uy; 0xfeuy; 0xc7uy; 0x9auy;
0xc5uy; 0xcduy; 0x1fuy; 0xe2uy; 0xd2uy; 0x00uy; 0x63uy; 0x39uy; 0xaauy; 0xb1uy; 0xf3uy; 0x17uy
]
let test1_enccoins =
List.Tot.map u8_from_UInt8
[
0x8duy; 0xf3uy; 0xfauy; 0xe3uy; 0x83uy; 0x27uy; 0xc5uy; 0x3cuy; 0xc1uy; 0xc4uy; 0x8cuy; 0x60uy;
0xb2uy; 0x52uy; 0x2buy; 0xb5uy
]
let test1_ss_expected =
List.Tot.map u8_from_UInt8
[
0xf8uy; 0x96uy; 0x15uy; 0x94uy; 0x80uy; 0x9fuy; 0xebuy; 0x77uy; 0x56uy; 0xbeuy; 0x37uy; 0x69uy;
0xa0uy; 0xeauy; 0x60uy; 0x16uy
]
let test1_pk_expected =
List.Tot.map u8_from_UInt8
[
0x0duy; 0xacuy; 0x6fuy; 0x83uy; 0x94uy; 0x00uy; 0x1auy; 0xcauy; 0x97uy; 0xa1uy; 0xaauy; 0x42uy;
0x80uy; 0x9duy; 0x6buy; 0xa5uy; 0xfcuy; 0x64uy; 0x43uy; 0xdbuy; 0xbeuy; 0x6fuy; 0x12uy; 0x2auy;
0x94uy; 0x58uy; 0x36uy; 0xf2uy; 0xb1uy; 0xf8uy; 0xe5uy; 0xf0uy; 0x57uy; 0x4buy; 0x35uy; 0x51uy;
0xdduy; 0x8cuy; 0x36uy; 0x28uy; 0x34uy; 0x46uy; 0xd6uy; 0xafuy; 0x5duy; 0x49uy; 0x0euy; 0x27uy;
0xd8uy; 0xd3uy; 0xaduy; 0xe1uy; 0xeduy; 0x8buy; 0x2duy; 0x13uy; 0xf5uy; 0x5auy; 0xb6uy; 0xdduy;
0xc0uy; 0x54uy; 0x76uy; 0x09uy; 0xa6uy; 0xa4uy; 0x01uy; 0xb9uy; 0xb7uy; 0xd1uy; 0x26uy; 0xd5uy;
0x1euy; 0xa8uy; 0x20uy; 0x4duy; 0xe8uy; 0xefuy; 0xaduy; 0xb9uy; 0xf0uy; 0x65uy; 0xe9uy; 0xc4uy;
0xf4uy; 0x11uy; 0x98uy; 0x99uy; 0xf0uy; 0x2cuy; 0x63uy; 0x7buy; 0x98uy; 0xd7uy; 0x60uy; 0x43uy;
0x5duy; 0x8cuy; 0x85uy; 0xe9uy; 0xc5uy; 0x83uy; 0x83uy; 0x62uy; 0xe2uy; 0x13uy; 0x33uy; 0x54uy;
0x4buy; 0x71uy; 0xaeuy; 0x63uy; 0xbauy; 0x5auy; 0x4euy; 0x32uy; 0x59uy; 0x78uy; 0x6buy; 0x4duy;
0x39uy; 0xcfuy; 0xe1uy; 0x82uy; 0x58uy; 0x0auy; 0xc3uy; 0x61uy; 0x6auy; 0x89uy; 0x2fuy; 0x1buy;
0x70uy; 0xdduy; 0x16uy; 0x3euy; 0x96uy; 0xb1uy; 0x4cuy; 0x71uy; 0xb1uy; 0x79uy; 0x0cuy; 0x3fuy;
0xe2uy; 0xeduy; 0x05uy; 0x07uy; 0x72uy; 0xf3uy; 0x89uy; 0x08uy; 0x8cuy; 0x22uy; 0xa7uy; 0x36uy;
0x40uy; 0xcauy; 0x52uy; 0x70uy; 0x1buy; 0x09uy; 0xcbuy; 0xabuy; 0x3buy; 0x64uy; 0x61uy; 0x6duy;
0x5duy; 0xf7uy; 0x15uy; 0x69uy; 0x71uy; 0x3buy; 0x3auy; 0x2euy; 0x53uy; 0x33uy; 0x26uy; 0xe6uy;
0x29uy; 0x5cuy; 0xfbuy; 0x0duy; 0xc6uy; 0xe4uy; 0xbduy; 0x9cuy; 0x43uy; 0xffuy; 0xa6uy; 0x5buy;
0x49uy; 0x47uy; 0x93uy; 0x1cuy; 0x81uy; 0x6fuy; 0xd4uy; 0xaauy; 0x3duy; 0xaduy; 0x86uy; 0xf5uy;
0x94uy; 0x16uy; 0x7fuy; 0x31uy; 0x91uy; 0x30uy; 0x97uy; 0xc4uy; 0xa3uy; 0xe4uy; 0x01uy; 0x2buy;
0x06uy; 0xcfuy; 0x69uy; 0xfbuy; 0x69uy; 0x35uy; 0xaauy; 0x81uy; 0xeduy; 0x90uy; 0x0cuy; 0x3auy;
0xc0uy; 0xa6uy; 0x06uy; 0xabuy; 0x51uy; 0x3fuy; 0x39uy; 0xb2uy; 0x1euy; 0xb0uy; 0x4buy; 0xbcuy;
0xd0uy; 0xd0uy; 0x3auy; 0xdauy; 0x89uy; 0x88uy; 0xa6uy; 0x56uy; 0xd8uy; 0x02uy; 0x98uy; 0xeeuy;
0xa2uy; 0xf5uy; 0x0euy; 0xbauy; 0x7cuy; 0x52uy; 0xafuy; 0xf4uy; 0xbbuy; 0xe7uy; 0x36uy; 0x4auy;
0xdduy; 0x90uy; 0x93uy; 0xe9uy; 0x5duy; 0xbeuy; 0x68uy; 0x99uy; 0xc2uy; 0xaduy; 0x4duy; 0x79uy;
0x25uy; 0x0buy; 0x69uy; 0x79uy; 0x7buy; 0xe2uy; 0x3duy; 0xa8uy; 0xe7uy; 0xf1uy; 0x42uy; 0x0cuy;
0x22uy; 0x85uy; 0x95uy; 0xf0uy; 0xd5uy; 0x5cuy; 0x96uy; 0x35uy; 0xb6uy; 0x19uy; 0xaeuy; 0xb3uy;
0xcfuy; 0x22uy; 0xcauy; 0xbauy; 0x28uy; 0xd6uy; 0xdduy; 0xd5uy; 0x8euy; 0xe8uy; 0xd6uy; 0x90uy;
0x23uy; 0x8euy; 0x97uy; 0x37uy; 0xe9uy; 0xcduy; 0xabuy; 0xdcuy; 0x08uy; 0x04uy; 0xe1uy; 0x32uy;
0x02uy; 0xffuy; 0x7fuy; 0x82uy; 0x41uy; 0xf3uy; 0x9buy; 0x1duy; 0x42uy; 0x8auy; 0x98uy; 0x80uy;
0x81uy; 0xaauy; 0xbeuy; 0x7duy; 0x3buy; 0x83uy; 0x30uy; 0x4duy; 0x4auy; 0x22uy; 0x2duy; 0xafuy;
0x61uy; 0xd1uy; 0xa0uy; 0x66uy; 0xd4uy; 0x48uy; 0x0fuy; 0xe1uy; 0xd9uy; 0x77uy; 0x82uy; 0xc5uy;
0xa1uy; 0x2auy; 0x03uy; 0x1fuy; 0xd0uy; 0x7auy; 0xccuy; 0x77uy; 0x09uy; 0x4auy; 0xbduy; 0xaduy;
0xf7uy; 0x76uy; 0xdcuy; 0x10uy; 0xeduy; 0x5buy; 0xdfuy; 0x89uy; 0xfbuy; 0x52uy; 0x60uy; 0x5cuy;
0x08uy; 0x42uy; 0x50uy; 0xd1uy; 0xdauy; 0x24uy; 0xbbuy; 0x59uy; 0x3euy; 0x14uy; 0xf4uy; 0xf0uy;
0xf4uy; 0xdauy; 0xb8uy; 0x00uy; 0xe2uy; 0x0buy; 0xfauy; 0xc3uy; 0xf6uy; 0x28uy; 0x8duy; 0x20uy;
0x26uy; 0xe9uy; 0x5buy; 0x25uy; 0xa8uy; 0x80uy; 0x4cuy; 0xeeuy; 0xc9uy; 0xb6uy; 0x7auy; 0x8buy;
0x87uy; 0x21uy; 0xfduy; 0xaeuy; 0xd5uy; 0xa8uy; 0x49uy; 0x33uy; 0x58uy; 0x90uy; 0x2cuy; 0x0auy;
0xcauy; 0xb0uy; 0x9duy; 0xbeuy; 0xcduy; 0xe0uy; 0xa4uy; 0x99uy; 0x76uy; 0x01uy; 0x80uy; 0xdduy;
0x66uy; 0x76uy; 0x70uy; 0x05uy; 0xf3uy; 0xd6uy; 0x31uy; 0xa1uy; 0x9euy; 0xd5uy; 0x5fuy; 0x1buy;
0xdduy; 0x7fuy; 0x81uy; 0x6duy; 0x5cuy; 0xe9uy; 0xa3uy; 0x1auy; 0x6auy; 0x87uy; 0x93uy; 0xaduy;
0x1duy; 0x73uy; 0x44uy; 0xbcuy; 0xe4uy; 0x42uy; 0x78uy; 0x6auy; 0x71uy; 0x58uy; 0x9buy; 0x73uy;
0x55uy; 0x63uy; 0xa5uy; 0x32uy; 0xf6uy; 0x55uy; 0x68uy; 0x05uy; 0xcfuy; 0xeduy; 0x5fuy; 0x86uy;
0xe2uy; 0x65uy; 0xefuy; 0xf1uy; 0xb9uy; 0x69uy; 0xbbuy; 0x79uy; 0xb1uy; 0xf4uy; 0x7fuy; 0xa5uy;
0xfauy; 0x62uy; 0xbcuy; 0x68uy; 0xe7uy; 0xf6uy; 0xf8uy; 0xf0uy; 0x55uy; 0xf4uy; 0x93uy; 0x47uy;
0x06uy; 0xf0uy; 0x3euy; 0x94uy; 0x4auy; 0x95uy; 0xc8uy; 0x0cuy; 0xb0uy; 0x04uy; 0x4euy; 0x3fuy;
0x67uy; 0x14uy; 0xeduy; 0xbbuy; 0xbeuy; 0xf0uy; 0xabuy; 0xdduy; 0x6cuy; 0x23uy; 0x4euy; 0x07uy;
0x66uy; 0x41uy; 0x55uy; 0xbeuy; 0x22uy; 0x59uy; 0xd5uy; 0xdauy; 0xd4uy; 0xd8uy; 0x3duy; 0xb0uy;
0x74uy; 0xc4uy; 0x4fuy; 0x9buy; 0x43uy; 0xe5uy; 0x75uy; 0xfbuy; 0x33uy; 0x0euy; 0xdfuy; 0xe1uy;
0xe3uy; 0x7duy; 0x2euy; 0x80uy; 0x10uy; 0x79uy; 0x17uy; 0xeauy; 0xd3uy; 0x18uy; 0x98uy; 0x08uy;
0xeduy; 0x79uy; 0x4cuy; 0xb9uy; 0x66uy; 0x03uy; 0x04uy; 0x50uy; 0xfeuy; 0x62uy; 0x0duy; 0x48uy;
0x1auy; 0x6cuy; 0xeeuy; 0xb7uy; 0x03uy; 0x15uy; 0x92uy; 0x41uy; 0x1euy; 0xa1uy; 0x88uy; 0x46uy;
0x1auy; 0x43uy; 0x49uy; 0xf5uy; 0x93uy; 0x33uy; 0x00uy; 0x65uy; 0x69uy; 0xa8uy; 0x82uy; 0xbduy;
0xbeuy; 0x5cuy; 0x56uy; 0xa3uy; 0x06uy; 0x00uy; 0x8buy; 0x2fuy; 0x7duy; 0xecuy; 0xa4uy; 0x9auy;
0x2auy; 0xaeuy; 0x66uy; 0x07uy; 0x46uy; 0xb3uy; 0xbeuy; 0xf8uy; 0x07uy; 0x08uy; 0x10uy; 0x87uy;
0xd5uy; 0x6cuy; 0x6auy; 0xa5uy; 0xa6uy; 0x07uy; 0x4buy; 0x00uy; 0xc1uy; 0x5auy; 0xeduy; 0x7fuy;
0x14uy; 0x4buy; 0x60uy; 0x02uy; 0xc2uy; 0x67uy; 0x0cuy; 0xa4uy; 0x64uy; 0x54uy; 0x3euy; 0x22uy;
0xfeuy; 0x21uy; 0xcduy; 0x0duy; 0xcbuy; 0x60uy; 0x3buy; 0x13uy; 0xb0uy; 0x8euy; 0x36uy; 0xcauy;
0xcduy; 0x78uy; 0x8duy; 0x08uy; 0x2auy; 0xf1uy; 0x9cuy; 0x17uy; 0x11uy; 0x14uy; 0x57uy; 0x57uy;
0xe8uy; 0x3buy; 0x84uy; 0xe8uy; 0x59uy; 0xdbuy; 0x5buy; 0x77uy; 0x2euy; 0x54uy; 0x3buy; 0x6euy;
0x9cuy; 0x5euy; 0x7fuy; 0x52uy; 0xe5uy; 0x06uy; 0x8auy; 0x2duy; 0xc3uy; 0xbfuy; 0x30uy; 0x34uy;
0x8cuy; 0xaauy; 0x3buy; 0x23uy; 0x59uy; 0x32uy; 0x5fuy; 0xf7uy; 0xc9uy; 0xb2uy; 0xeeuy; 0xb2uy;
0x72uy; 0x75uy; 0x33uy; 0x8euy; 0xa9uy; 0x68uy; 0x6euy; 0xf5uy; 0x61uy; 0x7auy; 0x20uy; 0x01uy;
0xecuy; 0xabuy; 0x19uy; 0x26uy; 0xbeuy; 0x38uy; 0x49uy; 0xe2uy; 0x16uy; 0xceuy; 0x17uy; 0xafuy;
0xcauy; 0xe3uy; 0x06uy; 0xeauy; 0x37uy; 0x98uy; 0xf2uy; 0x8fuy; 0x04uy; 0x9buy; 0xabuy; 0xd8uy;
0xbduy; 0x78uy; 0x68uy; 0xacuy; 0xefuy; 0xb9uy; 0x28uy; 0x6fuy; 0x0buy; 0x37uy; 0x90uy; 0xb3uy;
0x74uy; 0x0cuy; 0x38uy; 0x12uy; 0x70uy; 0xa2uy; 0xbeuy; 0xdcuy; 0xa7uy; 0x18uy; 0xdfuy; 0x5euy;
0xd2uy; 0x62uy; 0xccuy; 0x43uy; 0x24uy; 0x32uy; 0x58uy; 0x45uy; 0x18uy; 0x0auy; 0xe1uy; 0x0duy;
0x82uy; 0xbcuy; 0x08uy; 0xb1uy; 0xa9uy; 0x7euy; 0x63uy; 0x09uy; 0xc6uy; 0x83uy; 0xa1uy; 0xe6uy;
0x5cuy; 0x9cuy; 0xefuy; 0x57uy; 0xecuy; 0xc7uy; 0x73uy; 0x19uy; 0xfbuy; 0x5cuy; 0x20uy; 0xe1uy;
0xdfuy; 0x85uy; 0x76uy; 0xabuy; 0x89uy; 0xb7uy; 0x96uy; 0x8duy; 0xd9uy; 0x8euy; 0xb7uy; 0x00uy;
0xa8uy; 0xc6uy; 0x98uy; 0x47uy; 0x03uy; 0xafuy; 0x56uy; 0x1fuy; 0x35uy; 0x49uy; 0x75uy; 0x4cuy;
0xa2uy; 0xa2uy; 0xdcuy; 0x98uy; 0xbfuy; 0x87uy; 0xeduy; 0x73uy; 0x5fuy; 0x9buy; 0xabuy; 0x3euy;
0x02uy; 0xdcuy; 0xa1uy; 0x4buy; 0x6cuy; 0xacuy; 0x10uy; 0xb2uy; 0x0buy; 0x99uy; 0xeeuy; 0xc8uy;
0xc2uy; 0x82uy; 0xa9uy; 0xf9uy; 0xa9uy; 0xa5uy; 0x4duy; 0xc9uy; 0x39uy; 0x41uy; 0x89uy; 0x0cuy;
0xc6uy; 0xe3uy; 0xaauy; 0x76uy; 0xe7uy; 0x11uy; 0x16uy; 0x8auy; 0x28uy; 0x6buy; 0x22uy; 0x3auy;
0x1euy; 0x7duy; 0xe6uy; 0xf7uy; 0x55uy; 0x85uy; 0x8cuy; 0x36uy; 0x57uy; 0x0buy; 0xdbuy; 0xe6uy;
0xefuy; 0xd9uy; 0xf6uy; 0x94uy; 0x48uy; 0x31uy; 0x7euy; 0xaauy; 0x13uy; 0xd4uy; 0x58uy; 0x9buy;
0xebuy; 0x7cuy; 0x2auy; 0x39uy; 0xdduy; 0xa3uy; 0x3fuy; 0x70uy; 0xfduy; 0x7fuy; 0x30uy; 0xa3uy;
0x34uy; 0xe6uy; 0xacuy; 0x64uy; 0x9buy; 0xf8uy; 0xbbuy; 0x1euy; 0x51uy; 0xe1uy; 0xaduy; 0x61uy;
0xf6uy; 0xffuy; 0xd4uy; 0x4auy; 0x5euy; 0x12uy; 0x40uy; 0xdcuy; 0x07uy; 0x8buy; 0xb2uy; 0xe0uy;
0xb9uy; 0x29uy; 0xaauy; 0x4euy; 0x85uy; 0xf5uy; 0xbduy; 0x5buy; 0x43uy; 0x77uy; 0xc7uy; 0x0buy;
0xfeuy; 0x66uy; 0x49uy; 0xccuy; 0xb5uy; 0x92uy; 0x4auy; 0x14uy; 0x1euy; 0xe2uy; 0xe5uy; 0x20uy;
0xfauy; 0xecuy; 0x0fuy; 0xc9uy
]
let test1_ct_expected =
List.Tot.map u8_from_UInt8
[
0xebuy; 0x01uy; 0x36uy; 0x7duy; 0xe9uy; 0xdauy; 0x51uy; 0x3fuy; 0x8duy; 0xc7uy; 0x53uy; 0xdeuy;
0xfcuy; 0xa2uy; 0x2cuy; 0xacuy; 0x2duy; 0xbcuy; 0x9buy; 0xacuy; 0x9cuy; 0xc0uy; 0xc5uy; 0x08uy;
0x9duy; 0x0duy; 0x07uy; 0xbcuy; 0xd8uy; 0x69uy; 0x20uy; 0xccuy; 0x18uy; 0x0cuy; 0xbcuy; 0x7buy;
0x49uy; 0x23uy; 0x06uy; 0x8cuy; 0x9cuy; 0xc4uy; 0x1fuy; 0xffuy; 0x53uy; 0x91uy; 0x9cuy; 0x7fuy;
0xb4uy; 0xa7uy; 0x28uy; 0xdfuy; 0x30uy; 0x5euy; 0x9euy; 0x19uy; 0xd1uy; 0xbbuy; 0xe7uy; 0xacuy;
0x0cuy; 0xb2uy; 0xbduy; 0x58uy; 0xd6uy; 0x96uy; 0x8buy; 0x04uy; 0x66uy; 0xf6uy; 0xbeuy; 0x58uy;
0x25uy; 0xf9uy; 0xfbuy; 0xe1uy; 0x13uy; 0x7auy; 0x88uy; 0x57uy; 0xb6uy; 0xb5uy; 0x71uy; 0xe6uy;
0xe2uy; 0x63uy; 0xd2uy; 0x85uy; 0x8duy; 0x07uy; 0x37uy; 0xe9uy; 0xaduy; 0xe9uy; 0x3duy; 0x95uy;
0xccuy; 0x7euy; 0x56uy; 0x2duy; 0xaauy; 0x0buy; 0x13uy; 0xdfuy; 0xe8uy; 0x19uy; 0x7euy; 0x52uy;
0x8duy; 0x7buy; 0xaauy; 0x09uy; 0x10uy; 0xb2uy; 0x32uy; 0x9cuy; 0x91uy; 0xf3uy; 0x14uy; 0x49uy;
0x4auy; 0x9fuy; 0x38uy; 0xc0uy; 0xf5uy; 0xf4uy; 0x44uy; 0xc6uy; 0xf6uy; 0xf8uy; 0xd0uy; 0xb0uy;
0x4fuy; 0xc1uy; 0xc3uy; 0xd7uy; 0x71uy; 0x18uy; 0xe3uy; 0xc0uy; 0xf5uy; 0x7auy; 0xd0uy; 0x04uy;
0x4fuy; 0xcfuy; 0x76uy; 0xdcuy; 0xeeuy; 0x35uy; 0x21uy; 0xe0uy; 0x9euy; 0x41uy; 0x10uy; 0x06uy;
0x2duy; 0xb8uy; 0x0cuy; 0xabuy; 0x1duy; 0x3duy; 0x60uy; 0xefuy; 0xaduy; 0xc5uy; 0x80uy; 0x09uy;
0x56uy; 0xeeuy; 0xcbuy; 0x53uy; 0x1buy; 0x50uy; 0x95uy; 0x34uy; 0x47uy; 0xaeuy; 0x70uy; 0x96uy;
0xbauy; 0x19uy; 0x55uy; 0x99uy; 0xd1uy; 0xb1uy; 0xe6uy; 0x32uy; 0xf0uy; 0x19uy; 0x3buy; 0x2buy;
0xc7uy; 0x9cuy; 0xf7uy; 0xcauy; 0xa7uy; 0x3auy; 0xd3uy; 0xdcuy; 0xecuy; 0xf2uy; 0x49uy; 0x43uy;
0x64uy; 0x7cuy; 0xfduy; 0x35uy; 0xe8uy; 0xfauy; 0xa5uy; 0x98uy; 0x01uy; 0x6buy; 0x4euy; 0xe5uy;
0x84uy; 0x03uy; 0x24uy; 0xb6uy; 0xc7uy; 0x30uy; 0x13uy; 0x44uy; 0xd3uy; 0xe6uy; 0x97uy; 0xefuy;
0xf7uy; 0x13uy; 0xefuy; 0x0euy; 0x9fuy; 0x12uy; 0x75uy; 0x76uy; 0x69uy; 0x7cuy; 0x91uy; 0x15uy;
0x6cuy; 0xc0uy; 0xc2uy; 0x60uy; 0x8cuy; 0x63uy; 0xa7uy; 0xfauy; 0xc2uy; 0xf4uy; 0x17uy; 0xbauy;
0x8buy; 0xd4uy; 0xcfuy; 0x4auy; 0x8duy; 0x63uy; 0xb8uy; 0xa4uy; 0x6buy; 0x9cuy; 0x87uy; 0x94uy;
0x37uy; 0x05uy; 0x9duy; 0xc4uy; 0x76uy; 0x24uy; 0x77uy; 0x79uy; 0x4duy; 0x93uy; 0x62uy; 0x0buy;
0xbcuy; 0x72uy; 0x7euy; 0xb2uy; 0xefuy; 0x3cuy; 0x00uy; 0x1cuy; 0x18uy; 0x18uy; 0xbbuy; 0xe8uy;
0x60uy; 0x6euy; 0xc5uy; 0x9buy; 0x47uy; 0x93uy; 0x77uy; 0xd8uy; 0xf0uy; 0x45uy; 0x16uy; 0x97uy;
0x15uy; 0xc0uy; 0xd3uy; 0x4euy; 0x6duy; 0xe9uy; 0xfeuy; 0x89uy; 0xc3uy; 0x87uy; 0x3auy; 0x49uy;
0xfbuy; 0x9duy; 0x86uy; 0xffuy; 0xcauy; 0xa1uy; 0x3fuy; 0x15uy; 0x37uy; 0xd8uy; 0x98uy; 0xeeuy;
0xd9uy; 0x36uy; 0x06uy; 0x33uy; 0xd8uy; 0xdauy; 0x82uy; 0xeeuy; 0x60uy; 0x8cuy; 0xc7uy; 0xf3uy;
0x19uy; 0x47uy; 0x15uy; 0x7fuy; 0xd3uy; 0xf1uy; 0x30uy; 0xa2uy; 0xc6uy; 0xc4uy; 0x04uy; 0x5cuy;
0x50uy; 0xa3uy; 0x48uy; 0xc8uy; 0x1buy; 0x35uy; 0xfeuy; 0xa5uy; 0xeauy; 0x8auy; 0x4auy; 0x8cuy;
0x9cuy; 0x85uy; 0x8cuy; 0x1fuy; 0xbbuy; 0x3duy; 0xafuy; 0x2euy; 0x3auy; 0xaduy; 0x34uy; 0x6cuy;
0x5duy; 0x87uy; 0xc9uy; 0xc9uy; 0x7fuy; 0x30uy; 0xc1uy; 0x8duy; 0x4cuy; 0xd6uy; 0xbfuy; 0xc0uy;
0xf8uy; 0xa7uy; 0xb2uy; 0x91uy; 0x9buy; 0xe7uy; 0x85uy; 0x96uy; 0xe8uy; 0xb3uy; 0xaeuy; 0x89uy;
0x53uy; 0x41uy; 0x48uy; 0x0euy; 0xd0uy; 0x6auy; 0x4euy; 0x0cuy; 0x7duy; 0x10uy; 0xa1uy; 0xe8uy;
0x9duy; 0x7cuy; 0xdcuy; 0x76uy; 0x91uy; 0x86uy; 0x70uy; 0x67uy; 0xe1uy; 0x76uy; 0x4duy; 0x23uy;
0xeauy; 0x55uy; 0x62uy; 0xb9uy; 0x61uy; 0x7fuy; 0x24uy; 0xd3uy; 0x06uy; 0xd8uy; 0x15uy; 0x88uy;
0x52uy; 0x92uy; 0x8auy; 0xc1uy; 0x8auy; 0x1cuy; 0x7buy; 0x40uy; 0xfauy; 0x03uy; 0xe0uy; 0x93uy;
0xf7uy; 0x2duy; 0xf1uy; 0xdcuy; 0x27uy; 0x10uy; 0xd4uy; 0x28uy; 0x0auy; 0x61uy; 0x87uy; 0xbfuy;
0x09uy; 0xfbuy; 0xb1uy; 0xc7uy; 0xd8uy; 0xe9uy; 0xfauy; 0xa5uy; 0xa8uy; 0x6buy; 0x6duy; 0xa0uy;
0x64uy; 0xb7uy; 0xe4uy; 0x86uy; 0x79uy; 0x6euy; 0x85uy; 0x93uy; 0x94uy; 0xc9uy; 0xdeuy; 0xa9uy;
0x40uy; 0xb3uy; 0x6euy; 0xa0uy; 0xa6uy; 0xc8uy; 0xc9uy; 0x84uy; 0x3euy; 0xdbuy; 0x1duy; 0xa8uy;
0xbcuy; 0x04uy; 0x1cuy; 0xa4uy; 0x4fuy; 0x70uy; 0x77uy; 0xafuy; 0x98uy; 0x71uy; 0xc6uy; 0xbeuy;
0x24uy; 0x58uy; 0xc9uy; 0x53uy; 0x20uy; 0xd2uy; 0xeauy; 0x3duy; 0xe7uy; 0x3fuy; 0x8cuy; 0x44uy;
0xc8uy; 0x3fuy; 0x14uy; 0x50uy; 0xcduy; 0xc8uy; 0x45uy; 0x99uy; 0xf8uy; 0xb6uy; 0xd5uy; 0x99uy;
0x5auy; 0x77uy; 0x61uy; 0x48uy; 0x9fuy; 0x1auy; 0xb0uy; 0x6fuy; 0x1cuy; 0x27uy; 0x35uy; 0x80uy;
0xe6uy; 0x1euy; 0xe2uy; 0x75uy; 0xafuy; 0xf8uy; 0x10uy; 0x6duy; 0x0euy; 0xe6uy; 0x8auy; 0xb5uy;
0xffuy; 0x6cuy; 0x1euy; 0x41uy; 0x60uy; 0x93uy; 0xebuy; 0xffuy; 0x9fuy; 0xffuy; 0xf7uy; 0xcauy;
0x77uy; 0x2fuy; 0xc2uy; 0x44uy; 0xe8uy; 0x86uy; 0x23uy; 0x8auy; 0x2euy; 0xa7uy; 0x1buy; 0xb2uy;
0x8auy; 0x6cuy; 0x79uy; 0x0euy; 0x4duy; 0xe2uy; 0x09uy; 0xa7uy; 0xdauy; 0x60uy; 0x54uy; 0x55uy;
0x36uy; 0xb9uy; 0x06uy; 0x51uy; 0xd9uy; 0x1duy; 0x6cuy; 0xaauy; 0x0buy; 0x03uy; 0xb1uy; 0x38uy;
0x63uy; 0xd7uy; 0x29uy; 0x76uy; 0xf6uy; 0xc5uy; 0x73uy; 0x0auy; 0x0euy; 0x1duy; 0xf7uy; 0xc9uy;
0x5auy; 0xdauy; 0xdcuy; 0x64uy; 0xd5uy; 0x9fuy; 0x51uy; 0xc8uy; 0x8euy; 0x6fuy; 0xf6uy; 0xb9uy;
0x0cuy; 0xd4uy; 0x57uy; 0x5duy; 0x82uy; 0x4euy; 0xeeuy; 0xc6uy; 0x8auy; 0xf5uy; 0x7fuy; 0x59uy;
0xe1uy; 0x0cuy; 0xb8uy; 0xe7uy; 0xf6uy; 0xc6uy; 0x2auy; 0xb1uy; 0x5auy; 0xbauy; 0x77uy; 0xa0uy;
0x30uy; 0x19uy; 0x10uy; 0xe6uy; 0x5auy; 0x90uy; 0x03uy; 0x21uy; 0x3euy; 0xd8uy; 0xc1uy; 0xc5uy;
0xc5uy; 0x81uy; 0xf7uy; 0xc1uy; 0x6auy; 0xfauy; 0xecuy; 0xf6uy; 0x31uy; 0x0duy; 0xf6uy; 0x85uy;
0x9fuy; 0xb5uy; 0x34uy; 0x38uy; 0xf8uy; 0xc1uy; 0xe6uy; 0x7euy; 0x67uy; 0x8buy; 0x14uy; 0x01uy;
0x3buy; 0x32uy; 0xb6uy; 0xb1uy; 0x90uy; 0x91uy; 0xbcuy; 0x40uy; 0x90uy; 0x72uy; 0x55uy; 0x76uy;
0x2buy; 0x34uy; 0x3buy; 0x05uy; 0x65uy; 0x87uy; 0x0euy; 0x4buy; 0xb5uy; 0xcduy; 0x94uy; 0x88uy;
0x60uy; 0xf0uy; 0x7duy; 0xc9uy; 0x21uy; 0x71uy; 0xe2uy; 0x55uy; 0x43uy; 0x06uy; 0x1cuy; 0x84uy;
0x02uy; 0xd0uy; 0x4euy; 0xcbuy; 0x1buy; 0x38uy; 0x6duy; 0x58uy; 0x62uy; 0xabuy; 0x50uy; 0xcfuy;
0xb5uy; 0x47uy; 0x24uy; 0xb8uy; 0x6cuy; 0x00uy; 0xa4uy; 0xf2uy; 0x97uy; 0x9fuy; 0xf3uy; 0x98uy;
0x2euy; 0xf9uy; 0x4fuy; 0x02uy; 0xdcuy; 0x1duy; 0xc6uy; 0x08uy; 0x35uy; 0x57uy; 0xe5uy; 0x9buy;
0xd7uy; 0xf4uy; 0xd7uy; 0x28uy; 0x50uy; 0x39uy; 0xfduy; 0xd8uy; 0xe6uy; 0xbfuy; 0xcauy; 0x61uy;
0x65uy; 0xe3uy; 0xd0uy; 0x95uy; 0x65uy; 0x68uy; 0xb1uy; 0x41uy; 0x65uy; 0x1auy; 0x62uy; 0xceuy;
0x65uy; 0x8fuy; 0xeeuy; 0xe7uy; 0x7auy; 0x3cuy; 0x04uy; 0x95uy; 0x01uy; 0xd1uy; 0x31uy; 0x75uy;
0x80uy; 0x69uy; 0x1euy; 0x4buy; 0xb3uy; 0x4fuy; 0xb9uy; 0x5buy; 0x5cuy; 0x8euy; 0x16uy; 0x01uy;
0x99uy; 0x02uy; 0x55uy; 0x94uy; 0x0buy; 0xa9uy; 0x49uy; 0x7cuy; 0x10uy; 0xd4uy; 0xc9uy; 0xdduy;
0x2buy; 0xabuy; 0x8buy; 0x4cuy; 0x21uy; 0x7auy; 0x7duy; 0x53uy; 0x7buy; 0xd0uy; 0x69uy; 0x45uy;
0xcauy; 0x9auy; 0x91uy; 0x40uy; 0x54uy; 0x03uy; 0xb3uy; 0x56uy; 0x0euy; 0xc6uy; 0x68uy; 0x30uy;
0xdcuy; 0xb1uy; 0xffuy; 0xe4uy; 0x3fuy; 0x0euy; 0x1euy; 0xc0uy; 0x56uy; 0xb2uy; 0xe1uy; 0xfcuy;
0x58uy; 0xf5uy; 0xabuy; 0x39uy; 0x4euy; 0xdduy; 0x33uy; 0xbcuy; 0x12uy; 0xc5uy; 0xdcuy; 0x77uy;
0x46uy; 0x84uy; 0x82uy; 0xb2uy; 0x7fuy; 0xa2uy; 0xf6uy; 0x06uy; 0x24uy; 0xd6uy; 0x3cuy; 0xe3uy;
0xc5uy; 0xc2uy; 0x18uy; 0xc4uy; 0xc9uy; 0xf5uy; 0xa3uy; 0x2auy; 0x56uy; 0x5buy; 0x59uy; 0xe7uy;
0x00uy; 0x92uy; 0xb4uy; 0xd6uy; 0xf9uy; 0x96uy; 0x7cuy; 0x01uy; 0x26uy; 0x1euy; 0x5fuy; 0x27uy;
0x9cuy; 0x1buy; 0xb7uy; 0xf7uy; 0x36uy; 0xebuy; 0x7auy; 0xf3uy; 0xa7uy; 0x5euy; 0x38uy; 0xb2uy;
0x7buy; 0x7fuy; 0xd1uy; 0x4euy; 0x68uy; 0xb9uy; 0xa9uy; 0xf8uy; 0x7auy; 0x06uy; 0xb4uy; 0xe8uy;
0x42uy; 0xd8uy; 0xc7uy; 0x5auy; 0x08uy; 0xd5uy; 0x67uy; 0xa7uy; 0x30uy; 0xb6uy; 0x2euy; 0x80uy;
0xacuy; 0xa9uy; 0x07uy; 0xbbuy; 0x18uy; 0x54uy; 0xc3uy; 0x81uy; 0x6euy; 0x8auy; 0x24uy; 0xc0uy;
0x7fuy; 0xd0uy; 0x54uy; 0xb2uy; 0xe7uy; 0x1auy; 0x11uy; 0xf4uy; 0x9duy; 0x2cuy; 0x75uy; 0x37uy;
0x2euy; 0xc6uy; 0xfcuy; 0x85uy; 0x5duy; 0x46uy; 0x44uy; 0x7auy; 0x36uy; 0xe5uy; 0x62uy; 0xa4uy;
0x26uy; 0xdduy; 0x4cuy; 0x20uy; 0x33uy; 0x7auy; 0x8auy; 0x41uy; 0x8auy; 0x0fuy; 0xa4uy; 0xf8uy;
0x74uy; 0x45uy; 0x98uy; 0xe3uy; 0x73uy; 0xa1uy; 0x4euy; 0x40uy; 0x10uy; 0x5buy; 0x0fuy; 0xa0uy;
0xe4uy; 0x5euy; 0x97uy; 0x40uy; 0xdcuy; 0x68uy; 0x79uy; 0xd7uy; 0xfeuy; 0xfduy; 0x34uy; 0xd0uy;
0xb7uy; 0xcbuy; 0x4auy; 0xf3uy; 0xb0uy; 0xc7uy; 0xf5uy; 0xbauy; 0x6cuy; 0xa9uy; 0xf0uy; 0x82uy;
0x01uy; 0xb2uy; 0x3fuy; 0x9euy; 0x56uy; 0x9cuy; 0x86uy; 0x05uy; 0x03uy; 0x99uy; 0x2euy; 0xe7uy;
0xeduy; 0xdfuy; 0xfeuy; 0x05uy; 0x3buy; 0xdbuy; 0x3cuy; 0x30uy; 0x98uy; 0xa2uy; 0x23uy; 0x86uy;
0xefuy; 0x80uy; 0xe4uy; 0x2fuy; 0xdeuy; 0x8cuy; 0x7duy; 0x2euy; 0x78uy; 0xdbuy; 0xd6uy; 0xcauy;
0x7fuy; 0x79uy; 0x7auy; 0x3buy; 0xafuy; 0x2auy; 0xeduy; 0xf3uy; 0x03uy; 0x15uy; 0xccuy; 0x3duy;
0x52uy; 0x50uy; 0x1duy; 0x08uy; 0x93uy; 0xa2uy; 0xd8uy; 0x63uy; 0x91uy; 0xa0uy; 0x6cuy; 0xccuy
] | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.KeyGen.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"Spec.Frodo.KEM.Decaps.fst.checked",
"Spec.Frodo.KEM.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.PrintSequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Frodo.Test.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.PrintSequence",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.KEM.Decaps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.KEM.KeyGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.list Lib.IntTypes.uint8 | Prims.Tot | [
"total"
] | [] | [
"FStar.List.Tot.Base.map",
"FStar.UInt8.t",
"Lib.IntTypes.uint8",
"Lib.RawIntTypes.u8_from_UInt8",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | true | false | let test1_sk_expected =
| List.Tot.map u8_from_UInt8
[
0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy;
0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x0duy; 0xacuy; 0x6fuy; 0x83uy; 0x94uy; 0x00uy; 0x1auy; 0xcauy;
0x97uy; 0xa1uy; 0xaauy; 0x42uy; 0x80uy; 0x9duy; 0x6buy; 0xa5uy; 0xfcuy; 0x64uy; 0x43uy; 0xdbuy;
0xbeuy; 0x6fuy; 0x12uy; 0x2auy; 0x94uy; 0x58uy; 0x36uy; 0xf2uy; 0xb1uy; 0xf8uy; 0xe5uy; 0xf0uy;
0x57uy; 0x4buy; 0x35uy; 0x51uy; 0xdduy; 0x8cuy; 0x36uy; 0x28uy; 0x34uy; 0x46uy; 0xd6uy; 0xafuy;
0x5duy; 0x49uy; 0x0euy; 0x27uy; 0xd8uy; 0xd3uy; 0xaduy; 0xe1uy; 0xeduy; 0x8buy; 0x2duy; 0x13uy;
0xf5uy; 0x5auy; 0xb6uy; 0xdduy; 0xc0uy; 0x54uy; 0x76uy; 0x09uy; 0xa6uy; 0xa4uy; 0x01uy; 0xb9uy;
0xb7uy; 0xd1uy; 0x26uy; 0xd5uy; 0x1euy; 0xa8uy; 0x20uy; 0x4duy; 0xe8uy; 0xefuy; 0xaduy; 0xb9uy;
0xf0uy; 0x65uy; 0xe9uy; 0xc4uy; 0xf4uy; 0x11uy; 0x98uy; 0x99uy; 0xf0uy; 0x2cuy; 0x63uy; 0x7buy;
0x98uy; 0xd7uy; 0x60uy; 0x43uy; 0x5duy; 0x8cuy; 0x85uy; 0xe9uy; 0xc5uy; 0x83uy; 0x83uy; 0x62uy;
0xe2uy; 0x13uy; 0x33uy; 0x54uy; 0x4buy; 0x71uy; 0xaeuy; 0x63uy; 0xbauy; 0x5auy; 0x4euy; 0x32uy;
0x59uy; 0x78uy; 0x6buy; 0x4duy; 0x39uy; 0xcfuy; 0xe1uy; 0x82uy; 0x58uy; 0x0auy; 0xc3uy; 0x61uy;
0x6auy; 0x89uy; 0x2fuy; 0x1buy; 0x70uy; 0xdduy; 0x16uy; 0x3euy; 0x96uy; 0xb1uy; 0x4cuy; 0x71uy;
0xb1uy; 0x79uy; 0x0cuy; 0x3fuy; 0xe2uy; 0xeduy; 0x05uy; 0x07uy; 0x72uy; 0xf3uy; 0x89uy; 0x08uy;
0x8cuy; 0x22uy; 0xa7uy; 0x36uy; 0x40uy; 0xcauy; 0x52uy; 0x70uy; 0x1buy; 0x09uy; 0xcbuy; 0xabuy;
0x3buy; 0x64uy; 0x61uy; 0x6duy; 0x5duy; 0xf7uy; 0x15uy; 0x69uy; 0x71uy; 0x3buy; 0x3auy; 0x2euy;
0x53uy; 0x33uy; 0x26uy; 0xe6uy; 0x29uy; 0x5cuy; 0xfbuy; 0x0duy; 0xc6uy; 0xe4uy; 0xbduy; 0x9cuy;
0x43uy; 0xffuy; 0xa6uy; 0x5buy; 0x49uy; 0x47uy; 0x93uy; 0x1cuy; 0x81uy; 0x6fuy; 0xd4uy; 0xaauy;
0x3duy; 0xaduy; 0x86uy; 0xf5uy; 0x94uy; 0x16uy; 0x7fuy; 0x31uy; 0x91uy; 0x30uy; 0x97uy; 0xc4uy;
0xa3uy; 0xe4uy; 0x01uy; 0x2buy; 0x06uy; 0xcfuy; 0x69uy; 0xfbuy; 0x69uy; 0x35uy; 0xaauy; 0x81uy;
0xeduy; 0x90uy; 0x0cuy; 0x3auy; 0xc0uy; 0xa6uy; 0x06uy; 0xabuy; 0x51uy; 0x3fuy; 0x39uy; 0xb2uy;
0x1euy; 0xb0uy; 0x4buy; 0xbcuy; 0xd0uy; 0xd0uy; 0x3auy; 0xdauy; 0x89uy; 0x88uy; 0xa6uy; 0x56uy;
0xd8uy; 0x02uy; 0x98uy; 0xeeuy; 0xa2uy; 0xf5uy; 0x0euy; 0xbauy; 0x7cuy; 0x52uy; 0xafuy; 0xf4uy;
0xbbuy; 0xe7uy; 0x36uy; 0x4auy; 0xdduy; 0x90uy; 0x93uy; 0xe9uy; 0x5duy; 0xbeuy; 0x68uy; 0x99uy;
0xc2uy; 0xaduy; 0x4duy; 0x79uy; 0x25uy; 0x0buy; 0x69uy; 0x79uy; 0x7buy; 0xe2uy; 0x3duy; 0xa8uy;
0xe7uy; 0xf1uy; 0x42uy; 0x0cuy; 0x22uy; 0x85uy; 0x95uy; 0xf0uy; 0xd5uy; 0x5cuy; 0x96uy; 0x35uy;
0xb6uy; 0x19uy; 0xaeuy; 0xb3uy; 0xcfuy; 0x22uy; 0xcauy; 0xbauy; 0x28uy; 0xd6uy; 0xdduy; 0xd5uy;
0x8euy; 0xe8uy; 0xd6uy; 0x90uy; 0x23uy; 0x8euy; 0x97uy; 0x37uy; 0xe9uy; 0xcduy; 0xabuy; 0xdcuy;
0x08uy; 0x04uy; 0xe1uy; 0x32uy; 0x02uy; 0xffuy; 0x7fuy; 0x82uy; 0x41uy; 0xf3uy; 0x9buy; 0x1duy;
0x42uy; 0x8auy; 0x98uy; 0x80uy; 0x81uy; 0xaauy; 0xbeuy; 0x7duy; 0x3buy; 0x83uy; 0x30uy; 0x4duy;
0x4auy; 0x22uy; 0x2duy; 0xafuy; 0x61uy; 0xd1uy; 0xa0uy; 0x66uy; 0xd4uy; 0x48uy; 0x0fuy; 0xe1uy;
0xd9uy; 0x77uy; 0x82uy; 0xc5uy; 0xa1uy; 0x2auy; 0x03uy; 0x1fuy; 0xd0uy; 0x7auy; 0xccuy; 0x77uy;
0x09uy; 0x4auy; 0xbduy; 0xaduy; 0xf7uy; 0x76uy; 0xdcuy; 0x10uy; 0xeduy; 0x5buy; 0xdfuy; 0x89uy;
0xfbuy; 0x52uy; 0x60uy; 0x5cuy; 0x08uy; 0x42uy; 0x50uy; 0xd1uy; 0xdauy; 0x24uy; 0xbbuy; 0x59uy;
0x3euy; 0x14uy; 0xf4uy; 0xf0uy; 0xf4uy; 0xdauy; 0xb8uy; 0x00uy; 0xe2uy; 0x0buy; 0xfauy; 0xc3uy;
0xf6uy; 0x28uy; 0x8duy; 0x20uy; 0x26uy; 0xe9uy; 0x5buy; 0x25uy; 0xa8uy; 0x80uy; 0x4cuy; 0xeeuy;
0xc9uy; 0xb6uy; 0x7auy; 0x8buy; 0x87uy; 0x21uy; 0xfduy; 0xaeuy; 0xd5uy; 0xa8uy; 0x49uy; 0x33uy;
0x58uy; 0x90uy; 0x2cuy; 0x0auy; 0xcauy; 0xb0uy; 0x9duy; 0xbeuy; 0xcduy; 0xe0uy; 0xa4uy; 0x99uy;
0x76uy; 0x01uy; 0x80uy; 0xdduy; 0x66uy; 0x76uy; 0x70uy; 0x05uy; 0xf3uy; 0xd6uy; 0x31uy; 0xa1uy;
0x9euy; 0xd5uy; 0x5fuy; 0x1buy; 0xdduy; 0x7fuy; 0x81uy; 0x6duy; 0x5cuy; 0xe9uy; 0xa3uy; 0x1auy;
0x6auy; 0x87uy; 0x93uy; 0xaduy; 0x1duy; 0x73uy; 0x44uy; 0xbcuy; 0xe4uy; 0x42uy; 0x78uy; 0x6auy;
0x71uy; 0x58uy; 0x9buy; 0x73uy; 0x55uy; 0x63uy; 0xa5uy; 0x32uy; 0xf6uy; 0x55uy; 0x68uy; 0x05uy;
0xcfuy; 0xeduy; 0x5fuy; 0x86uy; 0xe2uy; 0x65uy; 0xefuy; 0xf1uy; 0xb9uy; 0x69uy; 0xbbuy; 0x79uy;
0xb1uy; 0xf4uy; 0x7fuy; 0xa5uy; 0xfauy; 0x62uy; 0xbcuy; 0x68uy; 0xe7uy; 0xf6uy; 0xf8uy; 0xf0uy;
0x55uy; 0xf4uy; 0x93uy; 0x47uy; 0x06uy; 0xf0uy; 0x3euy; 0x94uy; 0x4auy; 0x95uy; 0xc8uy; 0x0cuy;
0xb0uy; 0x04uy; 0x4euy; 0x3fuy; 0x67uy; 0x14uy; 0xeduy; 0xbbuy; 0xbeuy; 0xf0uy; 0xabuy; 0xdduy;
0x6cuy; 0x23uy; 0x4euy; 0x07uy; 0x66uy; 0x41uy; 0x55uy; 0xbeuy; 0x22uy; 0x59uy; 0xd5uy; 0xdauy;
0xd4uy; 0xd8uy; 0x3duy; 0xb0uy; 0x74uy; 0xc4uy; 0x4fuy; 0x9buy; 0x43uy; 0xe5uy; 0x75uy; 0xfbuy;
0x33uy; 0x0euy; 0xdfuy; 0xe1uy; 0xe3uy; 0x7duy; 0x2euy; 0x80uy; 0x10uy; 0x79uy; 0x17uy; 0xeauy;
0xd3uy; 0x18uy; 0x98uy; 0x08uy; 0xeduy; 0x79uy; 0x4cuy; 0xb9uy; 0x66uy; 0x03uy; 0x04uy; 0x50uy;
0xfeuy; 0x62uy; 0x0duy; 0x48uy; 0x1auy; 0x6cuy; 0xeeuy; 0xb7uy; 0x03uy; 0x15uy; 0x92uy; 0x41uy;
0x1euy; 0xa1uy; 0x88uy; 0x46uy; 0x1auy; 0x43uy; 0x49uy; 0xf5uy; 0x93uy; 0x33uy; 0x00uy; 0x65uy;
0x69uy; 0xa8uy; 0x82uy; 0xbduy; 0xbeuy; 0x5cuy; 0x56uy; 0xa3uy; 0x06uy; 0x00uy; 0x8buy; 0x2fuy;
0x7duy; 0xecuy; 0xa4uy; 0x9auy; 0x2auy; 0xaeuy; 0x66uy; 0x07uy; 0x46uy; 0xb3uy; 0xbeuy; 0xf8uy;
0x07uy; 0x08uy; 0x10uy; 0x87uy; 0xd5uy; 0x6cuy; 0x6auy; 0xa5uy; 0xa6uy; 0x07uy; 0x4buy; 0x00uy;
0xc1uy; 0x5auy; 0xeduy; 0x7fuy; 0x14uy; 0x4buy; 0x60uy; 0x02uy; 0xc2uy; 0x67uy; 0x0cuy; 0xa4uy;
0x64uy; 0x54uy; 0x3euy; 0x22uy; 0xfeuy; 0x21uy; 0xcduy; 0x0duy; 0xcbuy; 0x60uy; 0x3buy; 0x13uy;
0xb0uy; 0x8euy; 0x36uy; 0xcauy; 0xcduy; 0x78uy; 0x8duy; 0x08uy; 0x2auy; 0xf1uy; 0x9cuy; 0x17uy;
0x11uy; 0x14uy; 0x57uy; 0x57uy; 0xe8uy; 0x3buy; 0x84uy; 0xe8uy; 0x59uy; 0xdbuy; 0x5buy; 0x77uy;
0x2euy; 0x54uy; 0x3buy; 0x6euy; 0x9cuy; 0x5euy; 0x7fuy; 0x52uy; 0xe5uy; 0x06uy; 0x8auy; 0x2duy;
0xc3uy; 0xbfuy; 0x30uy; 0x34uy; 0x8cuy; 0xaauy; 0x3buy; 0x23uy; 0x59uy; 0x32uy; 0x5fuy; 0xf7uy;
0xc9uy; 0xb2uy; 0xeeuy; 0xb2uy; 0x72uy; 0x75uy; 0x33uy; 0x8euy; 0xa9uy; 0x68uy; 0x6euy; 0xf5uy;
0x61uy; 0x7auy; 0x20uy; 0x01uy; 0xecuy; 0xabuy; 0x19uy; 0x26uy; 0xbeuy; 0x38uy; 0x49uy; 0xe2uy;
0x16uy; 0xceuy; 0x17uy; 0xafuy; 0xcauy; 0xe3uy; 0x06uy; 0xeauy; 0x37uy; 0x98uy; 0xf2uy; 0x8fuy;
0x04uy; 0x9buy; 0xabuy; 0xd8uy; 0xbduy; 0x78uy; 0x68uy; 0xacuy; 0xefuy; 0xb9uy; 0x28uy; 0x6fuy;
0x0buy; 0x37uy; 0x90uy; 0xb3uy; 0x74uy; 0x0cuy; 0x38uy; 0x12uy; 0x70uy; 0xa2uy; 0xbeuy; 0xdcuy;
0xa7uy; 0x18uy; 0xdfuy; 0x5euy; 0xd2uy; 0x62uy; 0xccuy; 0x43uy; 0x24uy; 0x32uy; 0x58uy; 0x45uy;
0x18uy; 0x0auy; 0xe1uy; 0x0duy; 0x82uy; 0xbcuy; 0x08uy; 0xb1uy; 0xa9uy; 0x7euy; 0x63uy; 0x09uy;
0xc6uy; 0x83uy; 0xa1uy; 0xe6uy; 0x5cuy; 0x9cuy; 0xefuy; 0x57uy; 0xecuy; 0xc7uy; 0x73uy; 0x19uy;
0xfbuy; 0x5cuy; 0x20uy; 0xe1uy; 0xdfuy; 0x85uy; 0x76uy; 0xabuy; 0x89uy; 0xb7uy; 0x96uy; 0x8duy;
0xd9uy; 0x8euy; 0xb7uy; 0x00uy; 0xa8uy; 0xc6uy; 0x98uy; 0x47uy; 0x03uy; 0xafuy; 0x56uy; 0x1fuy;
0x35uy; 0x49uy; 0x75uy; 0x4cuy; 0xa2uy; 0xa2uy; 0xdcuy; 0x98uy; 0xbfuy; 0x87uy; 0xeduy; 0x73uy;
0x5fuy; 0x9buy; 0xabuy; 0x3euy; 0x02uy; 0xdcuy; 0xa1uy; 0x4buy; 0x6cuy; 0xacuy; 0x10uy; 0xb2uy;
0x0buy; 0x99uy; 0xeeuy; 0xc8uy; 0xc2uy; 0x82uy; 0xa9uy; 0xf9uy; 0xa9uy; 0xa5uy; 0x4duy; 0xc9uy;
0x39uy; 0x41uy; 0x89uy; 0x0cuy; 0xc6uy; 0xe3uy; 0xaauy; 0x76uy; 0xe7uy; 0x11uy; 0x16uy; 0x8auy;
0x28uy; 0x6buy; 0x22uy; 0x3auy; 0x1euy; 0x7duy; 0xe6uy; 0xf7uy; 0x55uy; 0x85uy; 0x8cuy; 0x36uy;
0x57uy; 0x0buy; 0xdbuy; 0xe6uy; 0xefuy; 0xd9uy; 0xf6uy; 0x94uy; 0x48uy; 0x31uy; 0x7euy; 0xaauy;
0x13uy; 0xd4uy; 0x58uy; 0x9buy; 0xebuy; 0x7cuy; 0x2auy; 0x39uy; 0xdduy; 0xa3uy; 0x3fuy; 0x70uy;
0xfduy; 0x7fuy; 0x30uy; 0xa3uy; 0x34uy; 0xe6uy; 0xacuy; 0x64uy; 0x9buy; 0xf8uy; 0xbbuy; 0x1euy;
0x51uy; 0xe1uy; 0xaduy; 0x61uy; 0xf6uy; 0xffuy; 0xd4uy; 0x4auy; 0x5euy; 0x12uy; 0x40uy; 0xdcuy;
0x07uy; 0x8buy; 0xb2uy; 0xe0uy; 0xb9uy; 0x29uy; 0xaauy; 0x4euy; 0x85uy; 0xf5uy; 0xbduy; 0x5buy;
0x43uy; 0x77uy; 0xc7uy; 0x0buy; 0xfeuy; 0x66uy; 0x49uy; 0xccuy; 0xb5uy; 0x92uy; 0x4auy; 0x14uy;
0x1euy; 0xe2uy; 0xe5uy; 0x20uy; 0xfauy; 0xecuy; 0x0fuy; 0xc9uy; 0x02uy; 0x00uy; 0xffuy; 0xffuy;
0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0xfduy; 0xffuy; 0x02uy; 0x00uy; 0x05uy; 0x00uy;
0x04uy; 0x00uy; 0xfauy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0xfduy; 0xffuy; 0xfduy; 0xffuy;
0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x03uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xfbuy; 0xffuy;
0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy;
0xfauy; 0xffuy; 0xfduy; 0xffuy; 0x04uy; 0x00uy; 0xffuy; 0xffuy; 0x05uy; 0x00uy; 0x05uy; 0x00uy;
0xfeuy; 0xffuy; 0x03uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0xfduy; 0xffuy; 0x02uy; 0x00uy;
0xffuy; 0xffuy; 0xfduy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy;
0x06uy; 0x00uy; 0xffuy; 0xffuy; 0x03uy; 0x00uy; 0x03uy; 0x00uy; 0xfduy; 0xffuy; 0x04uy; 0x00uy;
0x01uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x07uy; 0x00uy; 0xfcuy; 0xffuy; 0x05uy; 0x00uy;
0x04uy; 0x00uy; 0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0xfduy; 0xffuy; 0xfeuy; 0xffuy; 0xfduy; 0xffuy;
0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0x03uy; 0x00uy; 0x02uy; 0x00uy; 0x02uy; 0x00uy;
0x03uy; 0x00uy; 0x06uy; 0x00uy; 0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0x06uy; 0x00uy;
0x02uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xffuy; 0xffuy;
0x04uy; 0x00uy; 0xffuy; 0xffuy; 0x03uy; 0x00uy; 0xfduy; 0xffuy; 0xfduy; 0xffuy; 0xffuy; 0xffuy;
0x03uy; 0x00uy; 0xfduy; 0xffuy; 0xfduy; 0xffuy; 0x03uy; 0x00uy; 0x04uy; 0x00uy; 0x03uy; 0x00uy;
0xfduy; 0xffuy; 0x02uy; 0x00uy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0xffuy; 0xffuy; 0x04uy; 0x00uy;
0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xfcuy; 0xffuy; 0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy;
0xfduy; 0xffuy; 0x02uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy;
0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0xfduy; 0xffuy;
0xffuy; 0xffuy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0xfbuy; 0xffuy; 0x03uy; 0x00uy; 0xfcuy; 0xffuy;
0x04uy; 0x00uy; 0xfbuy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0x02uy; 0x00uy; 0x04uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x02uy; 0x00uy;
0xffuy; 0xffuy; 0xfcuy; 0xffuy; 0x06uy; 0x00uy; 0x02uy; 0x00uy; 0x03uy; 0x00uy; 0xfeuy; 0xffuy;
0xffuy; 0xffuy; 0xfduy; 0xffuy; 0xfeuy; 0xffuy; 0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0x04uy; 0x00uy;
0x04uy; 0x00uy; 0xfcuy; 0xffuy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy; 0x05uy; 0x00uy; 0x01uy; 0x00uy;
0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xfauy; 0xffuy; 0x00uy; 0x00uy; 0x02uy; 0x00uy; 0x02uy; 0x00uy;
0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x07uy; 0x00uy;
0x04uy; 0x00uy; 0x03uy; 0x00uy; 0x01uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x01uy; 0x00uy;
0xfeuy; 0xffuy; 0xfduy; 0xffuy; 0x04uy; 0x00uy; 0x01uy; 0x00uy; 0x03uy; 0x00uy; 0xffuy; 0xffuy;
0x02uy; 0x00uy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy; 0xffuy; 0xffuy;
0x02uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xfbuy; 0xffuy; 0x04uy; 0x00uy;
0x02uy; 0x00uy; 0xfduy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x01uy; 0x00uy;
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0xffuy; 0xffuy;
0x03uy; 0x00uy; 0xfcuy; 0xffuy; 0xfduy; 0xffuy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0x03uy; 0x00uy;
0xffuy; 0xffuy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x04uy; 0x00uy; 0x01uy; 0x00uy;
0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x02uy; 0x00uy;
0x00uy; 0x00uy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x08uy; 0x00uy; 0xfduy; 0xffuy;
0x03uy; 0x00uy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy; 0x02uy; 0x00uy; 0xffuy; 0xffuy; 0xfbuy; 0xffuy;
0x00uy; 0x00uy; 0xfbuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x04uy; 0x00uy; 0x01uy; 0x00uy;
0x03uy; 0x00uy; 0x01uy; 0x00uy; 0xfduy; 0xffuy; 0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy;
0x01uy; 0x00uy; 0xfcuy; 0xffuy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0xfcuy; 0xffuy; 0xfauy; 0xffuy;
0xfauy; 0xffuy; 0xfcuy; 0xffuy; 0xfbuy; 0xffuy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xfduy; 0xffuy;
0x01uy; 0x00uy; 0x05uy; 0x00uy; 0xfbuy; 0xffuy; 0xfduy; 0xffuy; 0xfcuy; 0xffuy; 0x05uy; 0x00uy;
0xfduy; 0xffuy; 0xfbuy; 0xffuy; 0xfduy; 0xffuy; 0xfbuy; 0xffuy; 0x03uy; 0x00uy; 0x03uy; 0x00uy;
0xfcuy; 0xffuy; 0xfduy; 0xffuy; 0x02uy; 0x00uy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0x01uy; 0x00uy;
0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0xfeuy; 0xffuy; 0xfbuy; 0xffuy; 0xfeuy; 0xffuy; 0xfeuy; 0xffuy;
0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0x02uy; 0x00uy; 0x02uy; 0x00uy; 0xfduy; 0xffuy; 0xfeuy; 0xffuy;
0xfeuy; 0xffuy; 0x02uy; 0x00uy; 0xfduy; 0xffuy; 0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy;
0x01uy; 0x00uy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0x06uy; 0x00uy; 0x04uy; 0x00uy;
0xfauy; 0xffuy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy; 0x02uy; 0x00uy; 0x05uy; 0x00uy; 0xffuy; 0xffuy;
0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x04uy; 0x00uy; 0xfcuy; 0xffuy; 0xfduy; 0xffuy;
0xfduy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xfduy; 0xffuy;
0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0xfeuy; 0xffuy; 0x00uy; 0x00uy;
0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x02uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0xfcuy; 0xffuy;
0x03uy; 0x00uy; 0x08uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy;
0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x06uy; 0x00uy; 0xfeuy; 0xffuy; 0x02uy; 0x00uy;
0x09uy; 0x00uy; 0xffuy; 0xffuy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0xfauy; 0xffuy; 0xfduy; 0xffuy;
0x01uy; 0x00uy; 0x06uy; 0x00uy; 0x03uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy;
0xfbuy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy;
0xfcuy; 0xffuy; 0xfbuy; 0xffuy; 0x04uy; 0x00uy; 0xfduy; 0xffuy; 0x00uy; 0x00uy; 0x05uy; 0x00uy;
0xfduy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xfcuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy;
0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xfcuy; 0xffuy; 0x00uy; 0x00uy; 0xfeuy; 0xffuy;
0x01uy; 0x00uy; 0x01uy; 0x00uy; 0xfbuy; 0xffuy; 0xfcuy; 0xffuy; 0xfcuy; 0xffuy; 0x02uy; 0x00uy;
0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0x01uy; 0x00uy; 0xfduy; 0xffuy; 0x01uy; 0x00uy;
0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0x03uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy;
0xffuy; 0xffuy; 0x00uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy;
0xffuy; 0xffuy; 0x03uy; 0x00uy; 0xfeuy; 0xffuy; 0x02uy; 0x00uy; 0x03uy; 0x00uy; 0xfbuy; 0xffuy;
0x00uy; 0x00uy; 0xfduy; 0xffuy; 0xf9uy; 0xffuy; 0x04uy; 0x00uy; 0x02uy; 0x00uy; 0x02uy; 0x00uy;
0xfcuy; 0xffuy; 0x03uy; 0x00uy; 0xfduy; 0xffuy; 0x03uy; 0x00uy; 0x01uy; 0x00uy; 0x01uy; 0x00uy;
0xf7uy; 0xffuy; 0xfduy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0x04uy; 0x00uy; 0x04uy; 0x00uy;
0xfduy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0x03uy; 0x00uy; 0x03uy; 0x00uy;
0x04uy; 0x00uy; 0x05uy; 0x00uy; 0xfduy; 0xffuy; 0xfauy; 0xffuy; 0x01uy; 0x00uy; 0xf8uy; 0xffuy;
0x01uy; 0x00uy; 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0xfduy; 0xffuy; 0xfbuy; 0xffuy; 0x00uy; 0x00uy;
0x02uy; 0x00uy; 0xfauy; 0xffuy; 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0x02uy; 0x00uy; 0x03uy; 0x00uy;
0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0x01uy; 0x00uy; 0x03uy; 0x00uy; 0xffuy; 0xffuy; 0x02uy; 0x00uy;
0xfbuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0xfduy; 0xffuy; 0x02uy; 0x00uy; 0xfcuy; 0xffuy;
0x01uy; 0x00uy; 0x02uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x03uy; 0x00uy; 0x02uy; 0x00uy;
0x01uy; 0x00uy; 0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0xfcuy; 0xffuy; 0xfcuy; 0xffuy; 0x01uy; 0x00uy;
0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0xffuy; 0xffuy; 0x03uy; 0x00uy;
0xfeuy; 0xffuy; 0xffuy; 0xffuy; 0xfduy; 0xffuy; 0xfeuy; 0xffuy; 0xfduy; 0xffuy; 0x03uy; 0x00uy;
0xffuy; 0xffuy; 0xfeuy; 0xffuy; 0xfduy; 0xffuy; 0x01uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy;
0x02uy; 0x00uy; 0xfeuy; 0xffuy; 0x05uy; 0x00uy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0xfduy; 0xffuy;
0xfduy; 0xffuy; 0xffuy; 0xffuy; 0x02uy; 0x00uy; 0x00uy; 0x00uy; 0xfeuy; 0xffuy; 0xffuy; 0xffuy;
0x04uy; 0x00uy; 0x00uy; 0x00uy; 0x04uy; 0x00uy; 0x04uy; 0x00uy; 0xfeuy; 0xffuy; 0x02uy; 0x00uy;
0xf9uy; 0xffuy; 0x02uy; 0x00uy; 0x08uy; 0x00uy; 0x00uy; 0x00uy; 0xffuy; 0xffuy; 0x00uy; 0x00uy;
0xb6uy; 0x27uy; 0xd5uy; 0x5euy; 0x52uy; 0xfduy; 0x89uy; 0x2euy; 0x92uy; 0x59uy; 0x69uy; 0xe7uy;
0x32uy; 0xb2uy; 0xacuy; 0x21uy
] | false |
|
FStar.Algebra.CommMonoid.Fold.fsti | FStar.Algebra.CommMonoid.Fold.init_func_from_expr | val init_func_from_expr
(#c: _)
(#n0: int)
(#nk: not_less_than n0)
(expr: ((ifrom_ito n0 nk) -> c))
(a: ifrom_ito n0 nk)
(b: ifrom_ito a nk)
: (counter_for (ifrom_ito a b) -> c) | val init_func_from_expr
(#c: _)
(#n0: int)
(#nk: not_less_than n0)
(expr: ((ifrom_ito n0 nk) -> c))
(a: ifrom_ito n0 nk)
(b: ifrom_ito a nk)
: (counter_for (ifrom_ito a b) -> c) | let init_func_from_expr #c (#n0: int) (#nk: not_less_than n0)
(expr: (ifrom_ito n0 nk) -> c)
(a: ifrom_ito n0 nk) (b: ifrom_ito a nk)
: (counter_for (ifrom_ito a b) -> c)
= fun (i: counter_for (ifrom_ito a b)) -> expr (n0 + i) | {
"file_name": "ulib/FStar.Algebra.CommMonoid.Fold.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 44,
"start_col": 0,
"start_line": 40
} | (*
Copyright 2008-2022 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.
Author: A. Rozanov
*)
module FStar.Algebra.CommMonoid.Fold
module CE = FStar.Algebra.CommMonoid.Equiv
open FStar.Seq.Base
open FStar.Seq.Properties
open FStar.Seq.Permutation
open FStar.IntegerIntervals
open FStar.Mul
(* Here we define the notion for big sums and big products for
arbitrary commutative monoids. We construct the folds from
an integer range and a function, then calculate the fold --
a sum or a product, depending on the monoid operation. *)
(* We refine multiplication a bit to make proofs smoothier *)
(* Notice how we can't just use a and b if we don't want to break | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.Permutation.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.IntegerIntervals.fst.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Algebra.CommMonoid.Fold.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Permutation",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Properties",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
expr: (_: FStar.IntegerIntervals.ifrom_ito n0 nk -> c) ->
a: FStar.IntegerIntervals.ifrom_ito n0 nk ->
b: FStar.IntegerIntervals.ifrom_ito a nk ->
_: FStar.IntegerIntervals.counter_for (FStar.IntegerIntervals.ifrom_ito a b)
-> c | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"FStar.IntegerIntervals.not_less_than",
"FStar.IntegerIntervals.ifrom_ito",
"FStar.IntegerIntervals.counter_for",
"Prims.op_Addition"
] | [] | false | false | false | false | false | let init_func_from_expr
#c
(#n0: int)
(#nk: not_less_than n0)
(expr: ((ifrom_ito n0 nk) -> c))
(a: ifrom_ito n0 nk)
(b: ifrom_ito a nk)
: (counter_for (ifrom_ito a b) -> c) =
| fun (i: counter_for (ifrom_ito a b)) -> expr (n0 + i) | false |
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.scalar_bit | val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1) | val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1) | let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1) | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 47,
"start_col": 0,
"start_line": 42
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\ | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Hacl.Impl.Curve25519.Generic.scalar -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n < 256}
-> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64 | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Curve25519.Generic.scalar",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint64",
"Lib.IntTypes.int_t",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U64",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.u8",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Lib.IntTypes.op_Percent_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Slash_Dot",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.IntTypes.range_t",
"Lib.IntTypes.mod_mask",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Subtraction",
"Prims.pow2",
"Lib.IntTypes.mod_mask_lemma",
"Lib.Sequence.index",
"Lib.Buffer.as_seq",
"Prims.op_Division",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let scalar_bit s n =
| let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1) | false |
Vale.Stdcalls.X64.GCM_IV.fst | Vale.Stdcalls.X64.GCM_IV.compute_iv_lemma | val compute_iv_lemma : iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE
-> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCM_IV.compute_iv_pre iv)
(Vale.Stdcalls.X64.GCM_IV.compute_iv_post iv) | let compute_iv_lemma (iv:Ghost.erased supported_iv_LE) = as_t
#(VSig.vale_sig_stdcall (compute_iv_pre iv) (compute_iv_post iv))
(compute_iv_lemma' iv) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 124,
"start_col": 0,
"start_line": 122
} | module Vale.Stdcalls.X64.GCM_IV
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module GC = Vale.AES.X64.GCMencryptOpt
open Vale.AES.GCM_s
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in
assert_norm (List.length y = 6);
y
[@__reduce__] noextract
let compute_iv_pre : (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state) ->
GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
[@__reduce__] noextract
let compute_iv_post : (Ghost.erased supported_iv_LE) -> VSig.vale_post dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
va_s1 f
#set-options "--z3rlimit 50"
[@__reduce__] noextract
let compute_iv_lemma'
(iv:Ghost.erased supported_iv_LE)
(code:V.va_code)
(_win:bool)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer iv_b) /\
ME.buffer_writeable (as_vale_buffer hkeys_b) /\
ME.buffer_writeable (as_vale_buffer iv_extra_b) /\
ME.buffer_writeable (as_vale_buffer j0_b))
) = let va_s1, f = GC.va_lemma_Compute_iv_stdcall code va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_extra_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 j0_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b;
va_s1, f
(* Prove that compute1_iv_lemma' has the required type *) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCM_IV.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": "GC"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"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": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE
-> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCM_IV.compute_iv_pre iv)
(Vale.Stdcalls.X64.GCM_IV.compute_iv_post iv) | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"Vale.AES.GCM_s.supported_iv_LE",
"Vale.Stdcalls.X64.GCM_IV.as_t",
"Vale.AsLowStar.ValeSig.vale_sig_stdcall",
"Vale.Stdcalls.X64.GCM_IV.dom",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_pre",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_post",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_lemma'"
] | [] | false | false | false | false | false | let compute_iv_lemma (iv: Ghost.erased supported_iv_LE) =
| as_t #(VSig.vale_sig_stdcall (compute_iv_pre iv) (compute_iv_post iv)) (compute_iv_lemma' iv) | false |
|
Hacl.P256.PrecompTable.fst | Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lseq_w4 | val precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 | val precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 | let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15);
Seq.seq_of_list precomp_g_pow2_192_table_list_w4 | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 266,
"start_col": 0,
"start_line": 264
} | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module SPT = Hacl.Spec.PrecompBaseTable
module SPT256 = Hacl.Spec.PrecompBaseTable256
module SPTK = Hacl.Spec.P256.PrecompTable
module S = Spec.P256
module SL = Spec.P256.Lemmas
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let proj_point_to_list p =
SPTK.proj_point_to_list_lemma p;
SPTK.proj_point_to_list p
let lemma_refl x =
SPTK.proj_point_to_list_lemma x
//-----------------
inline_for_extraction noextract
let proj_g_pow2_64 : S.proj_point =
[@inline_let]
let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in
[@inline_let]
let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in
[@inline_let]
let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in
(rX, rY, rZ)
val lemma_proj_g_pow2_64_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64)
let lemma_proj_g_pow2_64_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64);
let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in
let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in
let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
inline_for_extraction noextract
let proj_g_pow2_128 : S.proj_point =
[@inline_let]
let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in
[@inline_let]
let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in
[@inline_let]
let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in
(rX, rY, rZ)
val lemma_proj_g_pow2_128_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
let lemma_proj_g_pow2_128_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64);
let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in
let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in
let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
inline_for_extraction noextract
let proj_g_pow2_192 : S.proj_point =
[@inline_let]
let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in
[@inline_let]
let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in
[@inline_let]
let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in
(rX, rY, rZ)
val lemma_proj_g_pow2_192_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
let lemma_proj_g_pow2_192_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64);
let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in
let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in
let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
// let proj_g_pow2_64 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64)
// let proj_g_pow2_128 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64)
// let proj_g_pow2_192 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64)
inline_for_extraction noextract
let proj_g_pow2_64_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
inline_for_extraction noextract
let proj_g_pow2_128_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
inline_for_extraction noextract
let proj_g_pow2_192_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64);
Seq.seq_of_list proj_g_pow2_64_list
let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128);
Seq.seq_of_list proj_g_pow2_128_list
let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192);
Seq.seq_of_list proj_g_pow2_192_list
val proj_g_pow2_64_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
let proj_g_pow2_64_lemma () =
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_128_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
let proj_g_pow2_128_lemma () =
lemma_proj_g_pow2_128_eval ();
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_192_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
let proj_g_pow2_192_lemma () =
lemma_proj_g_pow2_192_eval ();
lemma_proj_g_pow2_128_eval ();
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point
let proj_g_pow2_64_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64);
proj_g_pow2_64_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_64
let proj_g_pow2_128_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128);
proj_g_pow2_128_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_128
let proj_g_pow2_192_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192);
proj_g_pow2_192_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_192
let mk_proj_g_pow2_64 () =
createL proj_g_pow2_64_list
let mk_proj_g_pow2_128 () =
createL proj_g_pow2_128_list
let mk_proj_g_pow2_192 () =
createL proj_g_pow2_192_list
//----------------
/// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G]
inline_for_extraction noextract
let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15)
let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15);
Seq.seq_of_list precomp_basepoint_table_list_w4
let precomp_basepoint_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4
let precomp_basepoint_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} =
createL_global precomp_basepoint_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)]
inline_for_extraction noextract
let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15)
let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15);
Seq.seq_of_list precomp_g_pow2_64_table_list_w4
let precomp_g_pow2_64_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table
proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_64_lemma ()
let precomp_g_pow2_64_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_64_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)]
inline_for_extraction noextract
let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15)
let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15);
Seq.seq_of_list precomp_g_pow2_128_table_list_w4
let precomp_g_pow2_128_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table
proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_128_lemma ()
let precomp_g_pow2_128_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_128_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)]
inline_for_extraction noextract
let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.Lemmas.fsti.checked",
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable256.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.PrecompTable.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.P256.PrecompTable.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq Lib.IntTypes.uint64 192 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.P256.PrecompTable.precomp_g_pow2_192_table_list_w4",
"Prims.unit",
"FStar.Pervasives.normalize_term_spec",
"Prims.list",
"Lib.IntTypes.uint_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.uint_to_t",
"Hacl.Spec.PrecompBaseTable.precomp_base_table_list",
"Spec.P256.PointOps.proj_point",
"Hacl.P256.PrecompTable.mk_p256_precomp_base_table",
"Hacl.P256.PrecompTable.proj_g_pow2_192",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64"
] | [] | false | false | false | false | false | let precomp_g_pow2_192_table_lseq_w4:LSeq.lseq uint64 192 =
| normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15);
Seq.seq_of_list precomp_g_pow2_192_table_list_w4 | false |
LowParse.SLow.IfThenElse.fst | LowParse.SLow.IfThenElse.serialize32_ifthenelse | val serialize32_ifthenelse
(#p: parse_ifthenelse_param)
(s:
serialize_ifthenelse_param p
{ let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\ Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high <
4294967296 /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high <
4294967296 })
(st32: serializer32 s.serialize_ifthenelse_tag_serializer)
(syntt:
(x: p.parse_ifthenelse_t
-> Tot (t: p.parse_ifthenelse_tag_t{t == dfst (s.serialize_ifthenelse_synth_recip x)})
))
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(syntp:
(
b: bool ->
x:
p.parse_ifthenelse_t
{b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x))}
-> Tot
(pl:
p.parse_ifthenelse_payload_t b {pl == dsnd (s.serialize_ifthenelse_synth_recip x)}
)))
(sp32: (b: bool -> Tot (serializer32 (s.serialize_ifthenelse_payload_serializer b))))
: Tot (serializer32 (serialize_ifthenelse s)) | val serialize32_ifthenelse
(#p: parse_ifthenelse_param)
(s:
serialize_ifthenelse_param p
{ let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\ Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high <
4294967296 /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high <
4294967296 })
(st32: serializer32 s.serialize_ifthenelse_tag_serializer)
(syntt:
(x: p.parse_ifthenelse_t
-> Tot (t: p.parse_ifthenelse_tag_t{t == dfst (s.serialize_ifthenelse_synth_recip x)})
))
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(syntp:
(
b: bool ->
x:
p.parse_ifthenelse_t
{b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x))}
-> Tot
(pl:
p.parse_ifthenelse_payload_t b {pl == dsnd (s.serialize_ifthenelse_synth_recip x)}
)))
(sp32: (b: bool -> Tot (serializer32 (s.serialize_ifthenelse_payload_serializer b))))
: Tot (serializer32 (serialize_ifthenelse s)) | let serialize32_ifthenelse
(#p: parse_ifthenelse_param)
(s: serialize_ifthenelse_param p {
let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\
Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high + Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high < 4294967296 /\
Some?.v tk.parser_kind_high + Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high < 4294967296
})
(st32: serializer32 s.serialize_ifthenelse_tag_serializer)
(syntt: (x: p.parse_ifthenelse_t) -> Tot (t: p.parse_ifthenelse_tag_t { t == dfst (s.serialize_ifthenelse_synth_recip x) } ))
(b32: (t: p.parse_ifthenelse_tag_t) -> Tot (b: bool { b == p.parse_ifthenelse_tag_cond t } ))
(syntp: (b: bool) -> (x: p.parse_ifthenelse_t { b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) } ) -> Tot (pl: p.parse_ifthenelse_payload_t b { pl == dsnd (s.serialize_ifthenelse_synth_recip x) } ))
(sp32: (b: bool) -> Tot (serializer32 (s.serialize_ifthenelse_payload_serializer b)))
: Tot (serializer32 (serialize_ifthenelse s))
= fun (input: p.parse_ifthenelse_t) -> ((
let t = syntt input in
let st = st32 t in
let b = b32 t in
if b
then
let y = syntp true input in
B32.append st (sp32 true y)
else
let y = syntp false input in
B32.append st (sp32 false y)
) <: (res: _ { serializer32_correct (serialize_ifthenelse s) input res })) | {
"file_name": "src/lowparse/LowParse.SLow.IfThenElse.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 76,
"end_line": 68,
"start_col": 0,
"start_line": 40
} | module LowParse.SLow.IfThenElse
include LowParse.Spec.IfThenElse
include LowParse.SLow.Combinators
module B32 = LowParse.Bytes32
module U32 = FStar.UInt32
inline_for_extraction
let parse32_ifthenelse
(p: parse_ifthenelse_param)
(pt32: parser32 p.parse_ifthenelse_tag_parser)
(b32: (t: p.parse_ifthenelse_tag_t) -> Tot (b: bool { b == p.parse_ifthenelse_tag_cond t } ))
(pp32: (b: bool) -> Tot (parser32 (dsnd (p.parse_ifthenelse_payload_parser b))))
(synt: (b: bool) -> (t: p.parse_ifthenelse_tag_t { b == p.parse_ifthenelse_tag_cond t } ) -> (pl: p.parse_ifthenelse_payload_t b) -> Tot (y: p.parse_ifthenelse_t { y == p.parse_ifthenelse_synth t pl } ))
: Tot (parser32 (parse_ifthenelse p))
= fun input ->
((
[@inline_let]
let _ = parse_ifthenelse_eq p (B32.reveal input) in
match pt32 input with
| None -> None
| Some (t, consumed_t) ->
let b = b32 t in
let input' = B32.slice input consumed_t (B32.len input) in
if b
then
match pp32 true input' with
| None -> None
| Some (pl, consumed_pl) ->
Some (synt true t pl, consumed_t `U32.add` consumed_pl)
else
match pp32 false input' with
| None -> None
| Some (pl, consumed_pl) ->
Some (synt false t pl, consumed_t `U32.add` consumed_pl)
) <: (res: _ { parser32_correct (parse_ifthenelse p) input res } )
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.IfThenElse.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.IfThenElse.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.IfThenElse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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"
} | false |
s:
LowParse.Spec.IfThenElse.serialize_ifthenelse_param p
{ let tk = Mkparse_ifthenelse_param?.parse_ifthenelse_tag_kind p in
Mkparser_kind'?.parser_kind_subkind tk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\
Some? (Mkparser_kind'?.parser_kind_high tk) /\
Some? (Mkparser_kind'?.parser_kind_high (FStar.Pervasives.dfst (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
true))) /\
Some? (Mkparser_kind'?.parser_kind_high (FStar.Pervasives.dfst (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
false))) /\
Some?.v (Mkparser_kind'?.parser_kind_high tk) +
Some?.v (Mkparser_kind'?.parser_kind_high (FStar.Pervasives.dfst (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
true))) <
4294967296 /\
Some?.v (Mkparser_kind'?.parser_kind_high tk) +
Some?.v (Mkparser_kind'?.parser_kind_high (FStar.Pervasives.dfst (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
false))) <
4294967296 } ->
st32:
LowParse.SLow.Base.serializer32 (Mkserialize_ifthenelse_param?.serialize_ifthenelse_tag_serializer
s) ->
syntt:
(x: Mkparse_ifthenelse_param?.parse_ifthenelse_t p
-> t:
Mkparse_ifthenelse_param?.parse_ifthenelse_tag_t p
{ t ==
FStar.Pervasives.dfst (Mkserialize_ifthenelse_param?.serialize_ifthenelse_synth_recip
s
x) }) ->
b32:
(t: Mkparse_ifthenelse_param?.parse_ifthenelse_tag_t p
-> b: Prims.bool{b == Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p t}) ->
syntp:
(
b: Prims.bool ->
x:
Mkparse_ifthenelse_param?.parse_ifthenelse_t p
{ b ==
Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p
(FStar.Pervasives.dfst (Mkserialize_ifthenelse_param?.serialize_ifthenelse_synth_recip
s
x)) }
-> pl:
Mkparse_ifthenelse_param?.parse_ifthenelse_payload_t p b
{ pl ==
FStar.Pervasives.dsnd (Mkserialize_ifthenelse_param?.serialize_ifthenelse_synth_recip
s
x) }) ->
sp32:
(b: Prims.bool
-> LowParse.SLow.Base.serializer32 (Mkserialize_ifthenelse_param?.serialize_ifthenelse_payload_serializer
s
b))
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.IfThenElse.serialize_ifthenelse s) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.IfThenElse.parse_ifthenelse_param",
"LowParse.Spec.IfThenElse.serialize_ifthenelse_param",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.nat",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"FStar.Pervasives.dfst",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Pervasives.Native.__proj__Some__item__v",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind",
"LowParse.SLow.Base.serializer32",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser",
"LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_tag_serializer",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond",
"LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_synth_recip",
"Prims.bool",
"FStar.Pervasives.dsnd",
"Prims.__proj__Mkdtuple2__item___1",
"LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_payload_serializer",
"FStar.Bytes.append",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.IfThenElse.parse_ifthenelse_kind",
"LowParse.Spec.IfThenElse.parse_ifthenelse",
"LowParse.Spec.IfThenElse.serialize_ifthenelse"
] | [] | false | false | false | false | false | let serialize32_ifthenelse
(#p: parse_ifthenelse_param)
(s:
serialize_ifthenelse_param p
{ let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\ Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high <
4294967296 /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high <
4294967296 })
(st32: serializer32 s.serialize_ifthenelse_tag_serializer)
(syntt:
(x: p.parse_ifthenelse_t
-> Tot (t: p.parse_ifthenelse_tag_t{t == dfst (s.serialize_ifthenelse_synth_recip x)})
))
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(syntp:
(
b: bool ->
x:
p.parse_ifthenelse_t
{b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x))}
-> Tot
(pl:
p.parse_ifthenelse_payload_t b {pl == dsnd (s.serialize_ifthenelse_synth_recip x)}
)))
(sp32: (b: bool -> Tot (serializer32 (s.serialize_ifthenelse_payload_serializer b))))
: Tot (serializer32 (serialize_ifthenelse s)) =
| fun (input: p.parse_ifthenelse_t) ->
((let t = syntt input in
let st = st32 t in
let b = b32 t in
if b
then
let y = syntp true input in
B32.append st (sp32 true y)
else
let y = syntp false input in
B32.append st (sp32 false y))
<:
(res: _{serializer32_correct (serialize_ifthenelse s) input res})) | false |
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.ecdh | val ecdh: (#s:field_spec) -> ecdh_st s True | val ecdh: (#s:field_spec) -> ecdh_st s True | let ecdh #s out priv pub =
push_frame ();
let zeros = create 32ul (u8 0) in
scalarmult #s out priv pub;
let r = lbytes_eq #32ul out zeros in
pop_frame();
not r | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 7,
"end_line": 501,
"start_col": 0,
"start_line": 495
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1)
let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1)
inline_for_extraction noextract
val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1)
[@ Meta.Attribute.specialize ]
let decode_point #s o i =
push_frame();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x : felem s = sub o 0ul (nlimb s) in
let z : felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame()
val encode_point:
#s:field_spec
-> o:lbuffer uint8 32ul
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 i /\ disjoint o i /\
state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
as_seq h1 o == S.encodePoint (fget_x h0 i, fget_z h0 i))
[@ Meta.Attribute.specialize ]
let encode_point #s o i =
push_frame();
let x : felem s = sub i 0ul (nlimb s) in
let z : felem s = sub i (nlimb s) (nlimb s) in
let tmp = create_felem s in
let u64s = create 4ul (u64 0) in
let tmp_w = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let h0 = ST.get () in
finv tmp z tmp_w;
fmul tmp tmp x tmp_w;
let h1 = ST.get () in
assert (feval h1 tmp == S.fmul (S.fpow (feval h0 z) (pow2 255 - 21)) (feval h0 x));
assert (feval h1 tmp == S.fmul (feval h0 x) (S.fpow (feval h0 z) (pow2 255 - 21)));
store_felem u64s tmp;
let h2 = ST.get () in
assert (as_seq h2 u64s == BSeq.nat_to_intseq_le 4 (feval h1 tmp));
uints_to_bytes_le #U64 4ul o u64s;
let h3 = ST.get () in
BSeq.uints_to_bytes_le_nat_lemma #U64 #SEC 4 (feval h1 tmp);
assert (as_seq h3 o == BSeq.nat_to_bytes_le 32 (feval h1 tmp));
pop_frame()
// TODO: why re-define the signature here?
val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2))
[@ Meta.Attribute.inline_ ]
let cswap2 #s bit p0 p1 =
C.cswap2 #s bit p0 p1
val ladder_step:
#s:field_spec
-> k:scalar
-> q:point s
-> i:size_t{v i < 251}
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) = S.ladder_step (as_seq h0 k) (fget_xz h0 q) (v i)
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\
b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
#push-options "--z3rlimit 200 --fuel 0 --ifuel 1"
[@ Meta.Attribute.inline_ ]
let ladder_step #s k q i p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let swap : lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let nq = sub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 = sub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
let h0 = ST.get () in
let bit = scalar_bit k (253ul -. i) in
assert (v bit == v (S.ith_bit (as_seq h0 k) (253 - v i)));
let sw = swap.(0ul) ^. bit in
logxor_lemma1 (LSeq.index (as_seq h0 swap) 0) bit;
cswap2 #s sw nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- bit
#pop-options
#push-options "--z3rlimit 300 --fuel 1 --ifuel 1"
val ladder_step_loop:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) =
Lib.LoopCombinators.repeati 251
(S.ladder_step (as_seq h0 k) (fget_xz h0 q))
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder_step_loop #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
[@ inline_let]
let spec_fh h0 =
S.ladder_step (as_seq h0 k) (fget_x h0 q, fget_z h0 q) in
[@ inline_let]
let acc h : GTot (tuple3 S.proj_point S.proj_point uint64) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
(fget_xz h nq, fget_xz h nq_p1, LSeq.index (as_seq h bit) 0) in
[@ inline_let]
let inv h (i:nat{i <= 251}) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h /\
v (LSeq.index (as_seq h bit) 0) <= 1 /\
state_inv_t h (get_x q) /\ state_inv_t h (get_z q) /\
state_inv_t h (get_x nq) /\ state_inv_t h (get_z nq) /\
state_inv_t h (get_x nq_p1) /\ state_inv_t h (get_z nq_p1) /\
acc h == Lib.LoopCombinators.repeati i (spec_fh h0) (acc h0) in
Lib.Loops.for 0ul 251ul inv
(fun i ->
Lib.LoopCombinators.unfold_repeati 251 (spec_fh h0) (acc h0) (v i);
ladder_step #s k q i p01_tmp1_swap tmp2)
#pop-options
#push-options "--z3refresh --fuel 0 --ifuel 1 --z3rlimit 800"
val ladder0_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq ==
M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder0_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let swap:lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
// bit 255 is 0 and bit 254 is 1
cswap2 #s (u64 1) nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- u64 1;
//Got about 1K speedup by removing 4 iterations here.
//First iteration can be skipped because top bit of scalar is 0
ladder_step_loop #s k q p01_tmp1_swap tmp2;
let sw = swap.(0ul) in
cswap2 #s sw nq nq_p1
val ladder1_:
#s:field_spec
-> p01_tmp1:lbuffer (limb s) (8ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 p01_tmp1 /\ live h0 tmp2 /\ disjoint p01_tmp1 tmp2 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1 |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == M.montgomery_ladder1_1 (fget_xz h0 nq)))
[@ Meta.Attribute.inline_ ]
let ladder1_ #s p01_tmp1 tmp2 =
let nq : point s = sub p01_tmp1 0ul (2ul *! nlimb s) in
let tmp1 = sub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) in
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) == tmp1);
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2
val ladder2_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
(let nq' = M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1) in
fget_xz h1 nq == M.montgomery_ladder1_1 nq')))
[@ Meta.Attribute.inline_ ]
let ladder2_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
ladder0_ #s k q p01_tmp1_swap tmp2;
ladder1_ #s p01_tmp1 tmp2
inline_for_extraction noextract
val ladder3_:
#s:field_spec
-> q:point s
-> p01:lbuffer (limb s) (4ul *! nlimb s)
-> Stack unit
(requires fun h0 ->
live h0 q /\ live h0 p01 /\ disjoint q p01 /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01) h0 h1 /\
(let nq = gsub p01 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\
(fget_xz h1 q, fget_xz h1 nq, fget_xz h1 nq_p1) == M.montgomery_ladder1_2 (fget_x h0 q)))
let ladder3_ #s q p01 =
let p0 : point s = sub p01 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
copy p1 q;
let x0 : felem s = sub p0 0ul (nlimb s) in
let z0 : felem s = sub p0 (nlimb s) (nlimb s) in
set_one x0;
set_zero z0;
let h0 = ST.get () in
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
assert (gsub p0 0ul (nlimb s) == x0);
assert (gsub p0 (nlimb s) (nlimb s) == z0);
assert (fget_x h0 p1 == fget_x h0 q);
assert (fget_z h0 p1 == 1);
assert (fget_x h0 p0 == 1);
assert (fget_z h0 p0 == 0);
assert (
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x p0) /\ state_inv_t h0 (get_z p0) /\
state_inv_t h0 (get_x p1) /\ state_inv_t h0 (get_z p1))
val ladder4_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == S.montgomery_ladder (fget_x h0 q) (as_seq h0 k)))
[@ Meta.Attribute.inline_ ]
let ladder4_ #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
let p01 = sub p01_tmp1_swap 0ul (4ul *! nlimb s) in
let p0 : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (4ul *! nlimb s) == p01);
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
ladder3_ #s q p01;
ladder2_ #s k q p01_tmp1_swap tmp2;
let h1 = ST.get () in
assert (fget_xz h1 p0 == M.montgomery_ladder1 (fget_x h0 q) (as_seq h0 k));
M.lemma_montgomery_ladder (fget_x h0 q) (as_seq h0 k)
val montgomery_ladder:
#s:field_spec
-> o:point s
-> k:scalar
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 k /\ live h0 i /\
(disjoint o i \/ o == i) /\ disjoint o k /\ disjoint k i /\
fget_z h0 i == 1 /\ state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 ->
modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_xz h1 o == S.montgomery_ladder (fget_x h0 i) (as_seq h0 k))
[@ Meta.Attribute.specialize ]
let montgomery_ladder #s out key init =
push_frame();
let h0 = ST.get () in
let tmp2 = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let p01_tmp1_swap = create (8ul *! nlimb s +! 1ul) (limb_zero s) in
let p0 : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == p0);
ladder4_ #s key init p01_tmp1_swap tmp2;
copy out p0;
pop_frame ()
#pop-options
#push-options "--fuel 0 --ifuel 1 --z3rlimit 400"
inline_for_extraction noextract
let g25519_t = x:glbuffer byte_t 32ul{witnessed x (Lib.Sequence.of_list S.basepoint_list) /\ recallable x}
/// Public API
/// ==========
val scalarmult: (#s: field_spec) -> scalarmult_st s True
[@ Meta.Attribute.specialize ]
let scalarmult #s out priv pub =
push_frame ();
let init = create (2ul `FStar.UInt32.mul` ((nlimb s) <: FStar.UInt32.t)) (limb_zero s) in
decode_point #s init pub;
montgomery_ladder #s init priv init;
encode_point #s out init;
pop_frame()
val secret_to_public (#s:field_spec) (g25519: g25519_t): secret_to_public_st s True
[@ Meta.Attribute.specialize ]
let secret_to_public #s g25519 pub priv =
push_frame ();
recall_contents g25519 S.basepoint_lseq;
let basepoint = create 32ul (u8 0) in
mapT 32ul basepoint secret g25519;
scalarmult #s pub priv basepoint;
pop_frame()
val ecdh: (#s:field_spec) -> ecdh_st s True | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Impl.Curve25519.Generic.ecdh_st s Prims.l_True | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.op_Negation",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.ByteBuffer.lbytes_eq",
"Hacl.Impl.Curve25519.Generic.scalarmult",
"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.create",
"Lib.IntTypes.u8",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let ecdh #s out priv pub =
| push_frame ();
let zeros = create 32ul (u8 0) in
scalarmult #s out priv pub;
let r = lbytes_eq #32ul out zeros in
pop_frame ();
not r | false |
LowParse.SLow.IfThenElse.fst | LowParse.SLow.IfThenElse.size32_ifthenelse | val size32_ifthenelse
(#p: parse_ifthenelse_param)
(s:
serialize_ifthenelse_param p
{ let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\ Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high <
4294967296 /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high <
4294967296 })
(st32: size32 s.serialize_ifthenelse_tag_serializer)
(syntt:
(x: p.parse_ifthenelse_t
-> Tot (t: p.parse_ifthenelse_tag_t{t == dfst (s.serialize_ifthenelse_synth_recip x)})
))
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(syntp:
(
b: bool ->
x:
p.parse_ifthenelse_t
{b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x))}
-> Tot
(pl:
p.parse_ifthenelse_payload_t b {pl == dsnd (s.serialize_ifthenelse_synth_recip x)}
)))
(sp32: (b: bool -> Tot (size32 (s.serialize_ifthenelse_payload_serializer b))))
: Tot (size32 (serialize_ifthenelse s)) | val size32_ifthenelse
(#p: parse_ifthenelse_param)
(s:
serialize_ifthenelse_param p
{ let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\ Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high <
4294967296 /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high <
4294967296 })
(st32: size32 s.serialize_ifthenelse_tag_serializer)
(syntt:
(x: p.parse_ifthenelse_t
-> Tot (t: p.parse_ifthenelse_tag_t{t == dfst (s.serialize_ifthenelse_synth_recip x)})
))
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(syntp:
(
b: bool ->
x:
p.parse_ifthenelse_t
{b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x))}
-> Tot
(pl:
p.parse_ifthenelse_payload_t b {pl == dsnd (s.serialize_ifthenelse_synth_recip x)}
)))
(sp32: (b: bool -> Tot (size32 (s.serialize_ifthenelse_payload_serializer b))))
: Tot (size32 (serialize_ifthenelse s)) | let size32_ifthenelse
(#p: parse_ifthenelse_param)
(s: serialize_ifthenelse_param p {
let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\
Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high + Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high < 4294967296 /\
Some?.v tk.parser_kind_high + Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high < 4294967296
})
(st32: size32 s.serialize_ifthenelse_tag_serializer)
(syntt: (x: p.parse_ifthenelse_t) -> Tot (t: p.parse_ifthenelse_tag_t { t == dfst (s.serialize_ifthenelse_synth_recip x) } ))
(b32: (t: p.parse_ifthenelse_tag_t) -> Tot (b: bool { b == p.parse_ifthenelse_tag_cond t } ))
(syntp: (b: bool) -> (x: p.parse_ifthenelse_t { b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) } ) -> Tot (pl: p.parse_ifthenelse_payload_t b { pl == dsnd (s.serialize_ifthenelse_synth_recip x) } ))
(sp32: (b: bool) -> Tot (size32 (s.serialize_ifthenelse_payload_serializer b)))
: Tot (size32 (serialize_ifthenelse s))
= fun (input: p.parse_ifthenelse_t) -> ((
let t = syntt input in
let st = st32 t in
let b = b32 t in
if b
then
let y = syntp true input in
U32.add st (sp32 true y)
else
let y = syntp false input in
U32.add st (sp32 false y)
) <: (res: _ { size32_postcond (serialize_ifthenelse s) input res })) | {
"file_name": "src/lowparse/LowParse.SLow.IfThenElse.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 71,
"end_line": 99,
"start_col": 0,
"start_line": 71
} | module LowParse.SLow.IfThenElse
include LowParse.Spec.IfThenElse
include LowParse.SLow.Combinators
module B32 = LowParse.Bytes32
module U32 = FStar.UInt32
inline_for_extraction
let parse32_ifthenelse
(p: parse_ifthenelse_param)
(pt32: parser32 p.parse_ifthenelse_tag_parser)
(b32: (t: p.parse_ifthenelse_tag_t) -> Tot (b: bool { b == p.parse_ifthenelse_tag_cond t } ))
(pp32: (b: bool) -> Tot (parser32 (dsnd (p.parse_ifthenelse_payload_parser b))))
(synt: (b: bool) -> (t: p.parse_ifthenelse_tag_t { b == p.parse_ifthenelse_tag_cond t } ) -> (pl: p.parse_ifthenelse_payload_t b) -> Tot (y: p.parse_ifthenelse_t { y == p.parse_ifthenelse_synth t pl } ))
: Tot (parser32 (parse_ifthenelse p))
= fun input ->
((
[@inline_let]
let _ = parse_ifthenelse_eq p (B32.reveal input) in
match pt32 input with
| None -> None
| Some (t, consumed_t) ->
let b = b32 t in
let input' = B32.slice input consumed_t (B32.len input) in
if b
then
match pp32 true input' with
| None -> None
| Some (pl, consumed_pl) ->
Some (synt true t pl, consumed_t `U32.add` consumed_pl)
else
match pp32 false input' with
| None -> None
| Some (pl, consumed_pl) ->
Some (synt false t pl, consumed_t `U32.add` consumed_pl)
) <: (res: _ { parser32_correct (parse_ifthenelse p) input res } )
)
inline_for_extraction
let serialize32_ifthenelse
(#p: parse_ifthenelse_param)
(s: serialize_ifthenelse_param p {
let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\
Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high + Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high < 4294967296 /\
Some?.v tk.parser_kind_high + Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high < 4294967296
})
(st32: serializer32 s.serialize_ifthenelse_tag_serializer)
(syntt: (x: p.parse_ifthenelse_t) -> Tot (t: p.parse_ifthenelse_tag_t { t == dfst (s.serialize_ifthenelse_synth_recip x) } ))
(b32: (t: p.parse_ifthenelse_tag_t) -> Tot (b: bool { b == p.parse_ifthenelse_tag_cond t } ))
(syntp: (b: bool) -> (x: p.parse_ifthenelse_t { b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) } ) -> Tot (pl: p.parse_ifthenelse_payload_t b { pl == dsnd (s.serialize_ifthenelse_synth_recip x) } ))
(sp32: (b: bool) -> Tot (serializer32 (s.serialize_ifthenelse_payload_serializer b)))
: Tot (serializer32 (serialize_ifthenelse s))
= fun (input: p.parse_ifthenelse_t) -> ((
let t = syntt input in
let st = st32 t in
let b = b32 t in
if b
then
let y = syntp true input in
B32.append st (sp32 true y)
else
let y = syntp false input in
B32.append st (sp32 false y)
) <: (res: _ { serializer32_correct (serialize_ifthenelse s) input res })) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.IfThenElse.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.IfThenElse.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.IfThenElse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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"
} | false |
s:
LowParse.Spec.IfThenElse.serialize_ifthenelse_param p
{ let tk = Mkparse_ifthenelse_param?.parse_ifthenelse_tag_kind p in
Mkparser_kind'?.parser_kind_subkind tk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\
Some? (Mkparser_kind'?.parser_kind_high tk) /\
Some? (Mkparser_kind'?.parser_kind_high (FStar.Pervasives.dfst (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
true))) /\
Some? (Mkparser_kind'?.parser_kind_high (FStar.Pervasives.dfst (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
false))) /\
Some?.v (Mkparser_kind'?.parser_kind_high tk) +
Some?.v (Mkparser_kind'?.parser_kind_high (FStar.Pervasives.dfst (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
true))) <
4294967296 /\
Some?.v (Mkparser_kind'?.parser_kind_high tk) +
Some?.v (Mkparser_kind'?.parser_kind_high (FStar.Pervasives.dfst (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
false))) <
4294967296 } ->
st32:
LowParse.SLow.Base.size32 (Mkserialize_ifthenelse_param?.serialize_ifthenelse_tag_serializer s
) ->
syntt:
(x: Mkparse_ifthenelse_param?.parse_ifthenelse_t p
-> t:
Mkparse_ifthenelse_param?.parse_ifthenelse_tag_t p
{ t ==
FStar.Pervasives.dfst (Mkserialize_ifthenelse_param?.serialize_ifthenelse_synth_recip
s
x) }) ->
b32:
(t: Mkparse_ifthenelse_param?.parse_ifthenelse_tag_t p
-> b: Prims.bool{b == Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p t}) ->
syntp:
(
b: Prims.bool ->
x:
Mkparse_ifthenelse_param?.parse_ifthenelse_t p
{ b ==
Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p
(FStar.Pervasives.dfst (Mkserialize_ifthenelse_param?.serialize_ifthenelse_synth_recip
s
x)) }
-> pl:
Mkparse_ifthenelse_param?.parse_ifthenelse_payload_t p b
{ pl ==
FStar.Pervasives.dsnd (Mkserialize_ifthenelse_param?.serialize_ifthenelse_synth_recip
s
x) }) ->
sp32:
(b: Prims.bool
-> LowParse.SLow.Base.size32 (Mkserialize_ifthenelse_param?.serialize_ifthenelse_payload_serializer
s
b))
-> LowParse.SLow.Base.size32 (LowParse.Spec.IfThenElse.serialize_ifthenelse s) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.IfThenElse.parse_ifthenelse_param",
"LowParse.Spec.IfThenElse.serialize_ifthenelse_param",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.nat",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"FStar.Pervasives.dfst",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Pervasives.Native.__proj__Some__item__v",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind",
"LowParse.SLow.Base.size32",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser",
"LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_tag_serializer",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond",
"LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_synth_recip",
"Prims.bool",
"FStar.Pervasives.dsnd",
"Prims.__proj__Mkdtuple2__item___1",
"LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_payload_serializer",
"FStar.UInt32.add",
"FStar.UInt32.t",
"LowParse.SLow.Base.size32_postcond",
"LowParse.Spec.IfThenElse.parse_ifthenelse_kind",
"LowParse.Spec.IfThenElse.parse_ifthenelse",
"LowParse.Spec.IfThenElse.serialize_ifthenelse"
] | [] | false | false | false | false | false | let size32_ifthenelse
(#p: parse_ifthenelse_param)
(s:
serialize_ifthenelse_param p
{ let tk = p.parse_ifthenelse_tag_kind in
tk.parser_kind_subkind == Some ParserStrong /\ Some? tk.parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high /\
Some? (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser true)).parser_kind_high <
4294967296 /\
Some?.v tk.parser_kind_high +
Some?.v (dfst (p.parse_ifthenelse_payload_parser false)).parser_kind_high <
4294967296 })
(st32: size32 s.serialize_ifthenelse_tag_serializer)
(syntt:
(x: p.parse_ifthenelse_t
-> Tot (t: p.parse_ifthenelse_tag_t{t == dfst (s.serialize_ifthenelse_synth_recip x)})
))
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(syntp:
(
b: bool ->
x:
p.parse_ifthenelse_t
{b == p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x))}
-> Tot
(pl:
p.parse_ifthenelse_payload_t b {pl == dsnd (s.serialize_ifthenelse_synth_recip x)}
)))
(sp32: (b: bool -> Tot (size32 (s.serialize_ifthenelse_payload_serializer b))))
: Tot (size32 (serialize_ifthenelse s)) =
| fun (input: p.parse_ifthenelse_t) ->
((let t = syntt input in
let st = st32 t in
let b = b32 t in
if b
then
let y = syntp true input in
U32.add st (sp32 true y)
else
let y = syntp false input in
U32.add st (sp32 false y))
<:
(res: _{size32_postcond (serialize_ifthenelse s) input res})) | false |
LowParse.SLow.IfThenElse.fst | LowParse.SLow.IfThenElse.parse32_ifthenelse | val parse32_ifthenelse
(p: parse_ifthenelse_param)
(pt32: parser32 p.parse_ifthenelse_tag_parser)
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(pp32: (b: bool -> Tot (parser32 (dsnd (p.parse_ifthenelse_payload_parser b)))))
(synt:
(
b: bool ->
t: p.parse_ifthenelse_tag_t{b == p.parse_ifthenelse_tag_cond t} ->
pl: p.parse_ifthenelse_payload_t b
-> Tot (y: p.parse_ifthenelse_t{y == p.parse_ifthenelse_synth t pl})))
: Tot (parser32 (parse_ifthenelse p)) | val parse32_ifthenelse
(p: parse_ifthenelse_param)
(pt32: parser32 p.parse_ifthenelse_tag_parser)
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(pp32: (b: bool -> Tot (parser32 (dsnd (p.parse_ifthenelse_payload_parser b)))))
(synt:
(
b: bool ->
t: p.parse_ifthenelse_tag_t{b == p.parse_ifthenelse_tag_cond t} ->
pl: p.parse_ifthenelse_payload_t b
-> Tot (y: p.parse_ifthenelse_t{y == p.parse_ifthenelse_synth t pl})))
: Tot (parser32 (parse_ifthenelse p)) | let parse32_ifthenelse
(p: parse_ifthenelse_param)
(pt32: parser32 p.parse_ifthenelse_tag_parser)
(b32: (t: p.parse_ifthenelse_tag_t) -> Tot (b: bool { b == p.parse_ifthenelse_tag_cond t } ))
(pp32: (b: bool) -> Tot (parser32 (dsnd (p.parse_ifthenelse_payload_parser b))))
(synt: (b: bool) -> (t: p.parse_ifthenelse_tag_t { b == p.parse_ifthenelse_tag_cond t } ) -> (pl: p.parse_ifthenelse_payload_t b) -> Tot (y: p.parse_ifthenelse_t { y == p.parse_ifthenelse_synth t pl } ))
: Tot (parser32 (parse_ifthenelse p))
= fun input ->
((
[@inline_let]
let _ = parse_ifthenelse_eq p (B32.reveal input) in
match pt32 input with
| None -> None
| Some (t, consumed_t) ->
let b = b32 t in
let input' = B32.slice input consumed_t (B32.len input) in
if b
then
match pp32 true input' with
| None -> None
| Some (pl, consumed_pl) ->
Some (synt true t pl, consumed_t `U32.add` consumed_pl)
else
match pp32 false input' with
| None -> None
| Some (pl, consumed_pl) ->
Some (synt false t pl, consumed_t `U32.add` consumed_pl)
) <: (res: _ { parser32_correct (parse_ifthenelse p) input res } )
) | {
"file_name": "src/lowparse/LowParse.SLow.IfThenElse.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 37,
"start_col": 0,
"start_line": 9
} | module LowParse.SLow.IfThenElse
include LowParse.Spec.IfThenElse
include LowParse.SLow.Combinators
module B32 = LowParse.Bytes32
module U32 = FStar.UInt32 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.IfThenElse.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.IfThenElse.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.IfThenElse",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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"
} | false |
p: LowParse.Spec.IfThenElse.parse_ifthenelse_param ->
pt32: LowParse.SLow.Base.parser32 (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) ->
b32:
(t: Mkparse_ifthenelse_param?.parse_ifthenelse_tag_t p
-> b: Prims.bool{b == Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p t}) ->
pp32:
(b: Prims.bool
-> LowParse.SLow.Base.parser32 (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser
p
b))) ->
synt:
(
b: Prims.bool ->
t:
Mkparse_ifthenelse_param?.parse_ifthenelse_tag_t p
{b == Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p t} ->
pl: Mkparse_ifthenelse_param?.parse_ifthenelse_payload_t p b
-> y:
Mkparse_ifthenelse_param?.parse_ifthenelse_t p
{y == Mkparse_ifthenelse_param?.parse_ifthenelse_synth p t pl})
-> LowParse.SLow.Base.parser32 (LowParse.Spec.IfThenElse.parse_ifthenelse p) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.IfThenElse.parse_ifthenelse_param",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser",
"Prims.bool",
"Prims.eq2",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond",
"Prims.__proj__Mkdtuple2__item___1",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser",
"FStar.Pervasives.dsnd",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t",
"LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_synth",
"LowParse.SLow.Base.bytes32",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"FStar.UInt32.t",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.UInt32.add",
"FStar.Pervasives.Native.option",
"LowParse.SLow.Base.parser32_correct",
"LowParse.Spec.IfThenElse.parse_ifthenelse_kind",
"LowParse.Spec.IfThenElse.parse_ifthenelse",
"FStar.Bytes.bytes",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"FStar.Bytes.reveal",
"FStar.Seq.Base.slice",
"FStar.UInt32.v",
"FStar.Bytes.len",
"FStar.Bytes.slice",
"Prims.unit",
"LowParse.Spec.IfThenElse.parse_ifthenelse_eq"
] | [] | false | false | false | false | false | let parse32_ifthenelse
(p: parse_ifthenelse_param)
(pt32: parser32 p.parse_ifthenelse_tag_parser)
(b32: (t: p.parse_ifthenelse_tag_t -> Tot (b: bool{b == p.parse_ifthenelse_tag_cond t})))
(pp32: (b: bool -> Tot (parser32 (dsnd (p.parse_ifthenelse_payload_parser b)))))
(synt:
(
b: bool ->
t: p.parse_ifthenelse_tag_t{b == p.parse_ifthenelse_tag_cond t} ->
pl: p.parse_ifthenelse_payload_t b
-> Tot (y: p.parse_ifthenelse_t{y == p.parse_ifthenelse_synth t pl})))
: Tot (parser32 (parse_ifthenelse p)) =
| fun input ->
(([@@ inline_let ]let _ = parse_ifthenelse_eq p (B32.reveal input) in
match pt32 input with
| None -> None
| Some (t, consumed_t) ->
let b = b32 t in
let input' = B32.slice input consumed_t (B32.len input) in
if b
then
match pp32 true input' with
| None -> None
| Some (pl, consumed_pl) -> Some (synt true t pl, consumed_t `U32.add` consumed_pl)
else
match pp32 false input' with
| None -> None
| Some (pl, consumed_pl) -> Some (synt false t pl, consumed_t `U32.add` consumed_pl))
<:
(res: _{parser32_correct (parse_ifthenelse p) input res})) | false |
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.secret_to_public | val secret_to_public (#s:field_spec) (g25519: g25519_t): secret_to_public_st s True | val secret_to_public (#s:field_spec) (g25519: g25519_t): secret_to_public_st s True | let secret_to_public #s g25519 pub priv =
push_frame ();
recall_contents g25519 S.basepoint_lseq;
let basepoint = create 32ul (u8 0) in
mapT 32ul basepoint secret g25519;
scalarmult #s pub priv basepoint;
pop_frame() | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 491,
"start_col": 0,
"start_line": 485
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1)
let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1)
inline_for_extraction noextract
val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1)
[@ Meta.Attribute.specialize ]
let decode_point #s o i =
push_frame();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x : felem s = sub o 0ul (nlimb s) in
let z : felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame()
val encode_point:
#s:field_spec
-> o:lbuffer uint8 32ul
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 i /\ disjoint o i /\
state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
as_seq h1 o == S.encodePoint (fget_x h0 i, fget_z h0 i))
[@ Meta.Attribute.specialize ]
let encode_point #s o i =
push_frame();
let x : felem s = sub i 0ul (nlimb s) in
let z : felem s = sub i (nlimb s) (nlimb s) in
let tmp = create_felem s in
let u64s = create 4ul (u64 0) in
let tmp_w = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let h0 = ST.get () in
finv tmp z tmp_w;
fmul tmp tmp x tmp_w;
let h1 = ST.get () in
assert (feval h1 tmp == S.fmul (S.fpow (feval h0 z) (pow2 255 - 21)) (feval h0 x));
assert (feval h1 tmp == S.fmul (feval h0 x) (S.fpow (feval h0 z) (pow2 255 - 21)));
store_felem u64s tmp;
let h2 = ST.get () in
assert (as_seq h2 u64s == BSeq.nat_to_intseq_le 4 (feval h1 tmp));
uints_to_bytes_le #U64 4ul o u64s;
let h3 = ST.get () in
BSeq.uints_to_bytes_le_nat_lemma #U64 #SEC 4 (feval h1 tmp);
assert (as_seq h3 o == BSeq.nat_to_bytes_le 32 (feval h1 tmp));
pop_frame()
// TODO: why re-define the signature here?
val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2))
[@ Meta.Attribute.inline_ ]
let cswap2 #s bit p0 p1 =
C.cswap2 #s bit p0 p1
val ladder_step:
#s:field_spec
-> k:scalar
-> q:point s
-> i:size_t{v i < 251}
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) = S.ladder_step (as_seq h0 k) (fget_xz h0 q) (v i)
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\
b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
#push-options "--z3rlimit 200 --fuel 0 --ifuel 1"
[@ Meta.Attribute.inline_ ]
let ladder_step #s k q i p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let swap : lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let nq = sub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 = sub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
let h0 = ST.get () in
let bit = scalar_bit k (253ul -. i) in
assert (v bit == v (S.ith_bit (as_seq h0 k) (253 - v i)));
let sw = swap.(0ul) ^. bit in
logxor_lemma1 (LSeq.index (as_seq h0 swap) 0) bit;
cswap2 #s sw nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- bit
#pop-options
#push-options "--z3rlimit 300 --fuel 1 --ifuel 1"
val ladder_step_loop:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) =
Lib.LoopCombinators.repeati 251
(S.ladder_step (as_seq h0 k) (fget_xz h0 q))
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder_step_loop #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
[@ inline_let]
let spec_fh h0 =
S.ladder_step (as_seq h0 k) (fget_x h0 q, fget_z h0 q) in
[@ inline_let]
let acc h : GTot (tuple3 S.proj_point S.proj_point uint64) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
(fget_xz h nq, fget_xz h nq_p1, LSeq.index (as_seq h bit) 0) in
[@ inline_let]
let inv h (i:nat{i <= 251}) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h /\
v (LSeq.index (as_seq h bit) 0) <= 1 /\
state_inv_t h (get_x q) /\ state_inv_t h (get_z q) /\
state_inv_t h (get_x nq) /\ state_inv_t h (get_z nq) /\
state_inv_t h (get_x nq_p1) /\ state_inv_t h (get_z nq_p1) /\
acc h == Lib.LoopCombinators.repeati i (spec_fh h0) (acc h0) in
Lib.Loops.for 0ul 251ul inv
(fun i ->
Lib.LoopCombinators.unfold_repeati 251 (spec_fh h0) (acc h0) (v i);
ladder_step #s k q i p01_tmp1_swap tmp2)
#pop-options
#push-options "--z3refresh --fuel 0 --ifuel 1 --z3rlimit 800"
val ladder0_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq ==
M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder0_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let swap:lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
// bit 255 is 0 and bit 254 is 1
cswap2 #s (u64 1) nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- u64 1;
//Got about 1K speedup by removing 4 iterations here.
//First iteration can be skipped because top bit of scalar is 0
ladder_step_loop #s k q p01_tmp1_swap tmp2;
let sw = swap.(0ul) in
cswap2 #s sw nq nq_p1
val ladder1_:
#s:field_spec
-> p01_tmp1:lbuffer (limb s) (8ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 p01_tmp1 /\ live h0 tmp2 /\ disjoint p01_tmp1 tmp2 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1 |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == M.montgomery_ladder1_1 (fget_xz h0 nq)))
[@ Meta.Attribute.inline_ ]
let ladder1_ #s p01_tmp1 tmp2 =
let nq : point s = sub p01_tmp1 0ul (2ul *! nlimb s) in
let tmp1 = sub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) in
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) == tmp1);
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2
val ladder2_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
(let nq' = M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1) in
fget_xz h1 nq == M.montgomery_ladder1_1 nq')))
[@ Meta.Attribute.inline_ ]
let ladder2_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
ladder0_ #s k q p01_tmp1_swap tmp2;
ladder1_ #s p01_tmp1 tmp2
inline_for_extraction noextract
val ladder3_:
#s:field_spec
-> q:point s
-> p01:lbuffer (limb s) (4ul *! nlimb s)
-> Stack unit
(requires fun h0 ->
live h0 q /\ live h0 p01 /\ disjoint q p01 /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01) h0 h1 /\
(let nq = gsub p01 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\
(fget_xz h1 q, fget_xz h1 nq, fget_xz h1 nq_p1) == M.montgomery_ladder1_2 (fget_x h0 q)))
let ladder3_ #s q p01 =
let p0 : point s = sub p01 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
copy p1 q;
let x0 : felem s = sub p0 0ul (nlimb s) in
let z0 : felem s = sub p0 (nlimb s) (nlimb s) in
set_one x0;
set_zero z0;
let h0 = ST.get () in
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
assert (gsub p0 0ul (nlimb s) == x0);
assert (gsub p0 (nlimb s) (nlimb s) == z0);
assert (fget_x h0 p1 == fget_x h0 q);
assert (fget_z h0 p1 == 1);
assert (fget_x h0 p0 == 1);
assert (fget_z h0 p0 == 0);
assert (
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x p0) /\ state_inv_t h0 (get_z p0) /\
state_inv_t h0 (get_x p1) /\ state_inv_t h0 (get_z p1))
val ladder4_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == S.montgomery_ladder (fget_x h0 q) (as_seq h0 k)))
[@ Meta.Attribute.inline_ ]
let ladder4_ #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
let p01 = sub p01_tmp1_swap 0ul (4ul *! nlimb s) in
let p0 : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (4ul *! nlimb s) == p01);
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
ladder3_ #s q p01;
ladder2_ #s k q p01_tmp1_swap tmp2;
let h1 = ST.get () in
assert (fget_xz h1 p0 == M.montgomery_ladder1 (fget_x h0 q) (as_seq h0 k));
M.lemma_montgomery_ladder (fget_x h0 q) (as_seq h0 k)
val montgomery_ladder:
#s:field_spec
-> o:point s
-> k:scalar
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 k /\ live h0 i /\
(disjoint o i \/ o == i) /\ disjoint o k /\ disjoint k i /\
fget_z h0 i == 1 /\ state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 ->
modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_xz h1 o == S.montgomery_ladder (fget_x h0 i) (as_seq h0 k))
[@ Meta.Attribute.specialize ]
let montgomery_ladder #s out key init =
push_frame();
let h0 = ST.get () in
let tmp2 = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let p01_tmp1_swap = create (8ul *! nlimb s +! 1ul) (limb_zero s) in
let p0 : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == p0);
ladder4_ #s key init p01_tmp1_swap tmp2;
copy out p0;
pop_frame ()
#pop-options
#push-options "--fuel 0 --ifuel 1 --z3rlimit 400"
inline_for_extraction noextract
let g25519_t = x:glbuffer byte_t 32ul{witnessed x (Lib.Sequence.of_list S.basepoint_list) /\ recallable x}
/// Public API
/// ==========
val scalarmult: (#s: field_spec) -> scalarmult_st s True
[@ Meta.Attribute.specialize ]
let scalarmult #s out priv pub =
push_frame ();
let init = create (2ul `FStar.UInt32.mul` ((nlimb s) <: FStar.UInt32.t)) (limb_zero s) in
decode_point #s init pub;
montgomery_ladder #s init priv init;
encode_point #s out init;
pop_frame()
val secret_to_public (#s:field_spec) (g25519: g25519_t): secret_to_public_st s True | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | g25519: Hacl.Impl.Curve25519.Generic.g25519_t
-> Hacl.Impl.Curve25519.Generic.secret_to_public_st s Prims.l_True | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.Generic.g25519_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Curve25519.Generic.scalarmult",
"Lib.Buffer.mapT",
"Lib.Buffer.CONST",
"Lib.IntTypes.byte_t",
"Lib.IntTypes.secret",
"Lib.IntTypes.U8",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.Buffer.recall_contents",
"Spec.Curve25519.basepoint_lseq",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let secret_to_public #s g25519 pub priv =
| push_frame ();
recall_contents g25519 S.basepoint_lseq;
let basepoint = create 32ul (u8 0) in
mapT 32ul basepoint secret g25519;
scalarmult #s pub priv basepoint;
pop_frame () | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.der_length_max | val der_length_max:nat | val der_length_max:nat | let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255 | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 331,
"end_line": 15,
"start_col": 0,
"start_line": 15
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.nat | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let der_length_max:nat =
| 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255 | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.der_length_t | val der_length_t : Type0 | let der_length_t = (x: nat { x <= der_length_max }) | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 51,
"end_line": 23,
"start_col": 0,
"start_line": 23
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.DER.der_length_max"
] | [] | false | false | false | true | true | let der_length_t =
| (x: nat{x <= der_length_max}) | false |
|
Steel.ST.Array.Util.fst | Steel.ST.Array.Util.forall_cond | val forall_cond:
#a: Type0 ->
n: US.t ->
arr: A.array a ->
p: (a -> bool) ->
r: R.ref US.t ->
perm: perm ->
s: G.erased (Seq.seq a) ->
squash (Seq.length s == US.v n) ->
unit
-> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) | val forall_cond:
#a: Type0 ->
n: US.t ->
arr: A.array a ->
p: (a -> bool) ->
r: R.ref US.t ->
perm: perm ->
s: G.erased (Seq.seq a) ->
squash (Seq.length s == US.v n) ->
unit
-> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) | let forall_cond
(#a:Type0)
(n:US.t)
(arr:A.array a)
(p:a -> bool)
(r:R.ref US.t)
(perm:perm)
(s:G.erased (Seq.seq a))
(_:squash (Seq.length s == US.v n))
: unit ->
STT bool
(exists_ (forall_inv n arr p r perm s ()))
(forall_inv n arr p r perm s ())
= fun _ ->
let _ = elim_exists () in
let _ = elim_exists () in
elim_pure _;
elim_pure _;
let i = R.read r in
let b = i = n in
let res =
if b then return false
else let elt = A.read arr i in
return (p elt) in
intro_pure (forall_pure_inv n p s () i);
intro_pure (forall_pure_inv_b n p s () i res);
intro_exists i (forall_pred n arr p r perm s () res);
return res | {
"file_name": "lib/steel/Steel.ST.Array.Util.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 14,
"end_line": 190,
"start_col": 0,
"start_line": 161
} | (*
Copyright 2021 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.ST.Array.Util
module G = FStar.Ghost
module US = FStar.SizeT
module R = Steel.ST.Reference
module A = Steel.ST.Array
module Loops = Steel.ST.Loops
open Steel.FractionalPermission
open Steel.ST.Effect
open Steel.ST.Util
/// Implementation of array_literal using a for loop
let array_literal_inv_pure
(#a:Type0)
(n:US.t)
(f:(i:US.t{US.v i < US.v n} -> a))
(i:Loops.nat_at_most n)
(s:Seq.seq a)
: prop
= forall (j:nat).
(j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j)
[@@ __reduce__]
let array_literal_inv
(#a:Type0)
(n:US.t)
(arr:A.array a)
(f:(i:US.t{US.v i < US.v n} -> a))
(i:Loops.nat_at_most n)
: Seq.seq a -> vprop
= fun s ->
A.pts_to arr full_perm s
`star`
pure (array_literal_inv_pure n f i s)
inline_for_extraction
let array_literal_loop_body
(#a:Type0)
(n:US.t)
(arr:A.array a{A.length arr == US.v n})
(f:(i:US.t{US.v i < US.v n} -> a))
: i:Loops.u32_between 0sz n ->
STT unit
(exists_ (array_literal_inv n arr f (US.v i)))
(fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1)))
= fun i ->
let s = elim_exists () in
();
A.pts_to_length arr s;
elim_pure (array_literal_inv_pure n f (US.v i) s);
A.write arr i (f i);
intro_pure
(array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i)));
intro_exists
(Seq.upd s (US.v i) (f i))
(array_literal_inv n arr f (US.v i + 1))
let array_literal #a n f =
let arr = A.alloc (f 0sz) n in
intro_pure
(array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz)));
intro_exists
(Seq.create (US.v n) (f 0sz))
(array_literal_inv n arr f 1);
Loops.for_loop
1sz
n
(fun i -> exists_ (array_literal_inv n arr f i))
(array_literal_loop_body n arr f);
let s = elim_exists () in
A.pts_to_length arr s;
elim_pure (array_literal_inv_pure n f (US.v n) s);
assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i))));
rewrite (A.pts_to arr full_perm s) _;
return arr
/// Implementation of for_all using a while loop
let forall_pure_inv
(#a:Type0)
(n:US.t)
(p:a -> bool)
(s:Seq.seq a)
(_:squash (Seq.length s == US.v n))
(i:US.t)
: prop
= i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j))
let forall_pure_inv_b
(#a:Type0)
(n:US.t)
(p:a -> bool)
(s:Seq.seq a)
(_:squash (Seq.length s == US.v n))
(i:US.t)
(b:bool)
: prop
= b == (i `US.lt` n && p (Seq.index s (US.v i)))
[@@ __reduce__]
let forall_pred
(#a:Type0)
(n:US.t)
(arr:A.array a)
(p:a -> bool)
(r:R.ref US.t)
(perm:perm)
(s:Seq.seq a)
(_:squash (Seq.length s == US.v n))
(b:bool)
: US.t -> vprop
= fun i ->
A.pts_to arr perm s
`star`
R.pts_to r full_perm i
`star`
pure (forall_pure_inv n p s () i)
`star`
pure (forall_pure_inv_b n p s () i b)
[@@ __reduce__]
let forall_inv
(#a:Type0)
(n:US.t)
(arr:A.array a)
(p:a -> bool)
(r:R.ref US.t)
(perm:perm)
(s:Seq.seq a)
(_:squash (Seq.length s == US.v n))
: bool -> vprop
= fun b -> exists_ (forall_pred n arr p r perm s () b) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Reference.fsti.checked",
"Steel.ST.Loops.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.ST.Array.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.Array.Util.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.ST.Loops",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Steel.ST.Array",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "Steel.ST.Reference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.ST.Array",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "Steel.ST.Array",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Array",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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"
} | false |
n: FStar.SizeT.t ->
arr: Steel.ST.Array.array a ->
p: (_: a -> Prims.bool) ->
r: Steel.ST.Reference.ref FStar.SizeT.t ->
perm: Steel.FractionalPermission.perm ->
s: FStar.Ghost.erased (FStar.Seq.Base.seq a) ->
_: Prims.squash (FStar.Seq.Base.length (FStar.Ghost.reveal s) == FStar.SizeT.v n) ->
_: Prims.unit
-> Steel.ST.Effect.STT Prims.bool | Steel.ST.Effect.STT | [] | [] | [
"FStar.SizeT.t",
"Steel.ST.Array.array",
"Prims.bool",
"Steel.ST.Reference.ref",
"Steel.FractionalPermission.perm",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Prims.squash",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.Ghost.reveal",
"FStar.SizeT.v",
"Prims.unit",
"Steel.ST.Util.return",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.VStar",
"Steel.ST.Array.pts_to",
"Steel.ST.Reference.pts_to",
"Steel.FractionalPermission.full_perm",
"Steel.ST.Util.pure",
"Steel.ST.Array.Util.forall_pure_inv",
"Steel.ST.Array.Util.forall_pure_inv_b",
"Steel.Effect.Common.vprop",
"Steel.ST.Util.intro_exists",
"Steel.ST.Array.Util.forall_pred",
"Steel.ST.Util.intro_pure",
"Steel.ST.Array.read",
"Prims.op_Equality",
"Steel.ST.Reference.read",
"Steel.ST.Util.elim_pure",
"Steel.ST.Util.elim_exists",
"Steel.ST.Array.Util.forall_inv"
] | [] | false | true | false | false | false | let forall_cond
(#a: Type0)
(n: US.t)
(arr: A.array a)
(p: (a -> bool))
(r: R.ref US.t)
(perm: perm)
(s: G.erased (Seq.seq a))
(_: squash (Seq.length s == US.v n))
: unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) =
| fun _ ->
let _ = elim_exists () in
let _ = elim_exists () in
elim_pure _;
elim_pure _;
let i = R.read r in
let b = i = n in
let res =
if b
then return false
else
let elt = A.read arr i in
return (p elt)
in
intro_pure (forall_pure_inv n p s () i);
intro_pure (forall_pure_inv_b n p s () i res);
intro_exists i (forall_pred n arr p r perm s () res);
return res | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.der_length_payload_size | val der_length_payload_size (x: der_length_t) : Tot (y: nat{y <= 126}) | val der_length_payload_size (x: der_length_t) : Tot (y: nat{y <= 126}) | let der_length_payload_size
(x: der_length_t)
: Tot (y: nat { y <= 126 })
= der_length_payload_size_of_tag (tag_of_der_length x) | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 54,
"end_line": 86,
"start_col": 0,
"start_line": 83
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None
[@@(noextract_to "krml")]
let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: LowParse.Spec.DER.der_length_t -> y: Prims.nat{y <= 126} | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.DER.der_length_t",
"LowParse.Spec.DER.der_length_payload_size_of_tag",
"LowParse.Spec.DER.tag_of_der_length",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual"
] | [] | false | false | false | false | false | let der_length_payload_size (x: der_length_t) : Tot (y: nat{y <= 126}) =
| der_length_payload_size_of_tag (tag_of_der_length x) | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.parse_der_length_payload_kind | val parse_der_length_payload_kind (x: U8.t) : Tot parser_kind | val parse_der_length_payload_kind (x: U8.t) : Tot parser_kind | let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 33,
"end_line": 68,
"start_col": 0,
"start_line": 66
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt8.t -> LowParse.Spec.Base.parser_kind | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt8.t",
"LowParse.Spec.Base.strong_parser_kind",
"FStar.Pervasives.Native.None",
"LowParse.Spec.Base.parser_kind_metadata_some",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.DER.der_length_payload_size_of_tag",
"LowParse.Spec.Base.parser_kind"
] | [] | false | false | false | true | false | let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
| let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.tag_of_der_length32 | val tag_of_der_length32 (x: U32.t) : GTot U8.t | val tag_of_der_length32 (x: U32.t) : GTot U8.t | let tag_of_der_length32
(x: U32.t)
: GTot U8.t
= let _ = assert_norm (pow2 32 - 1 <= der_length_max) in
tag_of_der_length (U32.v x) | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 29,
"end_line": 102,
"start_col": 0,
"start_line": 98
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None
[@@(noextract_to "krml")]
let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len
[@@(noextract_to "krml")]
let der_length_payload_size
(x: der_length_t)
: Tot (y: nat { y <= 126 })
= der_length_payload_size_of_tag (tag_of_der_length x)
val der_length_payload_size_le
(x1 x2: der_length_t)
: Lemma
(requires (x1 <= x2))
(ensures (der_length_payload_size x1 <= der_length_payload_size x2))
let lint (len: nat) : Tot Type = (x: nat { x < pow2 (8 * len) })
module U32 = FStar.UInt32 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt32.t -> Prims.GTot FStar.UInt8.t | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.UInt32.t",
"LowParse.Spec.DER.tag_of_der_length",
"FStar.UInt32.v",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"LowParse.Spec.DER.der_length_max",
"FStar.UInt8.t"
] | [] | false | false | false | false | false | let tag_of_der_length32 (x: U32.t) : GTot U8.t =
| let _ = assert_norm (pow2 32 - 1 <= der_length_max) in
tag_of_der_length (U32.v x) | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.parse_bounded_der_length32_kind | val parse_bounded_der_length32_kind
(min: der_length_t)
(max: der_length_t{min <= max /\ max < 4294967296})
: Tot parser_kind | val parse_bounded_der_length32_kind
(min: der_length_t)
(max: der_length_t{min <= max /\ max < 4294967296})
: Tot parser_kind | let parse_bounded_der_length32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
=
[@inline_let]
let k = parse_bounded_der_length_payload32_kind min max in
strong_parser_kind (1 + der_length_payload_size_of_tag (tag_of_der_length32' min)) (1 + der_length_payload_size_of_tag (tag_of_der_length32' max)) None | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 151,
"end_line": 179,
"start_col": 0,
"start_line": 172
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None
[@@(noextract_to "krml")]
let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len
[@@(noextract_to "krml")]
let der_length_payload_size
(x: der_length_t)
: Tot (y: nat { y <= 126 })
= der_length_payload_size_of_tag (tag_of_der_length x)
val der_length_payload_size_le
(x1 x2: der_length_t)
: Lemma
(requires (x1 <= x2))
(ensures (der_length_payload_size x1 <= der_length_payload_size x2))
let lint (len: nat) : Tot Type = (x: nat { x < pow2 (8 * len) })
module U32 = FStar.UInt32
let tag_of_der_length32
(x: U32.t)
: GTot U8.t
= let _ = assert_norm (pow2 32 - 1 <= der_length_max) in
tag_of_der_length (U32.v x)
val parse_der_length_payload32
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
: Tot (parser (parse_der_length_payload_kind x) (refine_with_tag tag_of_der_length32 x))
val parse_der_length_payload32_unfold
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
(input: bytes)
: Lemma
(
let y = parse (parse_der_length_payload32 x) input in
(256 < der_length_max) /\ (
if U8.v x < 128
then tag_of_der_length (U8.v x) == x /\ y == Some (Cast.uint8_to_uint32 x, 0)
else if x = 128uy || x = 255uy
then y == None
else if x = 129uy
then
match parse parse_u8 input with
| None -> y == None
| Some (z, consumed) ->
if U8.v z < 128
then y == None
else tag_of_der_length (U8.v z) == x /\ y == Some (Cast.uint8_to_uint32 z, consumed)
else
let len : nat = U8.v x - 128 in
2 <= len /\ len <= 4 /\
(
let res : option (bounded_integer len & consumed_length input) = parse (parse_bounded_integer len) input in
match res with
| None -> y == None
| Some (z, consumed) ->
len > 0 /\ (
if U32.v z >= pow2 (8 * (len - 1))
then U32.v z <= der_length_max /\ tag_of_der_length32 z == x /\ y == Some ((z <: refine_with_tag tag_of_der_length32 x), consumed)
else y == None
))))
val log256_eq
(x: nat)
: Lemma
(requires (x > 0 /\ x < 4294967296))
(ensures (log256 x == log256' x))
inline_for_extraction
let tag_of_der_length32'
(x: der_length_t { x < 4294967296 } )
: Tot (z: U8.t { z == tag_of_der_length x })
= if x < 128
then U8.uint_to_t x
else
[@inline_let]
let len_len = log256' x in
[@inline_let] let _ =
log256_eq x;
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126)
in
128uy `U8.add` U8.uint_to_t len_len
inline_for_extraction
let parse_bounded_der_length_payload32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
= [@inline_let] let _ = der_length_payload_size_le min max in
strong_parser_kind (der_length_payload_size_of_tag (tag_of_der_length32' min)) (der_length_payload_size_of_tag (tag_of_der_length32' max)) None | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: LowParse.Spec.DER.der_length_t ->
max: LowParse.Spec.DER.der_length_t{min <= max /\ max < 4294967296}
-> LowParse.Spec.Base.parser_kind | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.DER.der_length_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.strong_parser_kind",
"Prims.op_Addition",
"LowParse.Spec.DER.der_length_payload_size_of_tag",
"LowParse.Spec.DER.tag_of_der_length32'",
"FStar.Pervasives.Native.None",
"LowParse.Spec.Base.parser_kind_metadata_some",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.DER.parse_bounded_der_length_payload32_kind"
] | [] | false | false | false | false | false | let parse_bounded_der_length32_kind
(min: der_length_t)
(max: der_length_t{min <= max /\ max < 4294967296})
: Tot parser_kind =
| [@@ inline_let ]let k = parse_bounded_der_length_payload32_kind min max in
strong_parser_kind (1 + der_length_payload_size_of_tag (tag_of_der_length32' min))
(1 + der_length_payload_size_of_tag (tag_of_der_length32' max))
None | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.parse_bounded_der_length_payload32_kind | val parse_bounded_der_length_payload32_kind
(min: der_length_t)
(max: der_length_t{min <= max /\ max < 4294967296})
: Tot parser_kind | val parse_bounded_der_length_payload32_kind
(min: der_length_t)
(max: der_length_t{min <= max /\ max < 4294967296})
: Tot parser_kind | let parse_bounded_der_length_payload32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
= [@inline_let] let _ = der_length_payload_size_le min max in
strong_parser_kind (der_length_payload_size_of_tag (tag_of_der_length32' min)) (der_length_payload_size_of_tag (tag_of_der_length32' max)) None | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 145,
"end_line": 169,
"start_col": 0,
"start_line": 164
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None
[@@(noextract_to "krml")]
let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len
[@@(noextract_to "krml")]
let der_length_payload_size
(x: der_length_t)
: Tot (y: nat { y <= 126 })
= der_length_payload_size_of_tag (tag_of_der_length x)
val der_length_payload_size_le
(x1 x2: der_length_t)
: Lemma
(requires (x1 <= x2))
(ensures (der_length_payload_size x1 <= der_length_payload_size x2))
let lint (len: nat) : Tot Type = (x: nat { x < pow2 (8 * len) })
module U32 = FStar.UInt32
let tag_of_der_length32
(x: U32.t)
: GTot U8.t
= let _ = assert_norm (pow2 32 - 1 <= der_length_max) in
tag_of_der_length (U32.v x)
val parse_der_length_payload32
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
: Tot (parser (parse_der_length_payload_kind x) (refine_with_tag tag_of_der_length32 x))
val parse_der_length_payload32_unfold
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
(input: bytes)
: Lemma
(
let y = parse (parse_der_length_payload32 x) input in
(256 < der_length_max) /\ (
if U8.v x < 128
then tag_of_der_length (U8.v x) == x /\ y == Some (Cast.uint8_to_uint32 x, 0)
else if x = 128uy || x = 255uy
then y == None
else if x = 129uy
then
match parse parse_u8 input with
| None -> y == None
| Some (z, consumed) ->
if U8.v z < 128
then y == None
else tag_of_der_length (U8.v z) == x /\ y == Some (Cast.uint8_to_uint32 z, consumed)
else
let len : nat = U8.v x - 128 in
2 <= len /\ len <= 4 /\
(
let res : option (bounded_integer len & consumed_length input) = parse (parse_bounded_integer len) input in
match res with
| None -> y == None
| Some (z, consumed) ->
len > 0 /\ (
if U32.v z >= pow2 (8 * (len - 1))
then U32.v z <= der_length_max /\ tag_of_der_length32 z == x /\ y == Some ((z <: refine_with_tag tag_of_der_length32 x), consumed)
else y == None
))))
val log256_eq
(x: nat)
: Lemma
(requires (x > 0 /\ x < 4294967296))
(ensures (log256 x == log256' x))
inline_for_extraction
let tag_of_der_length32'
(x: der_length_t { x < 4294967296 } )
: Tot (z: U8.t { z == tag_of_der_length x })
= if x < 128
then U8.uint_to_t x
else
[@inline_let]
let len_len = log256' x in
[@inline_let] let _ =
log256_eq x;
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126)
in
128uy `U8.add` U8.uint_to_t len_len | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: LowParse.Spec.DER.der_length_t ->
max: LowParse.Spec.DER.der_length_t{min <= max /\ max < 4294967296}
-> LowParse.Spec.Base.parser_kind | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.DER.der_length_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.strong_parser_kind",
"LowParse.Spec.DER.der_length_payload_size_of_tag",
"LowParse.Spec.DER.tag_of_der_length32'",
"FStar.Pervasives.Native.None",
"LowParse.Spec.Base.parser_kind_metadata_some",
"Prims.unit",
"LowParse.Spec.DER.der_length_payload_size_le",
"LowParse.Spec.Base.parser_kind"
] | [] | false | false | false | false | false | let parse_bounded_der_length_payload32_kind
(min: der_length_t)
(max: der_length_t{min <= max /\ max < 4294967296})
: Tot parser_kind =
| [@@ inline_let ]let _ = der_length_payload_size_le min max in
strong_parser_kind (der_length_payload_size_of_tag (tag_of_der_length32' min))
(der_length_payload_size_of_tag (tag_of_der_length32' max))
None | false |
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.decode_point | val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1) | val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1) | let decode_point #s o i =
push_frame();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x : felem s = sub o 0ul (nlimb s) in
let z : felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame() | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 81,
"start_col": 0,
"start_line": 60
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1)
let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1)
inline_for_extraction noextract
val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1) | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | o: Hacl.Impl.Curve25519.AddAndDouble.point s -> i: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.AddAndDouble.point",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Curve25519.Fields.load_felem",
"Hacl.Impl.Curve25519.Fields.set_one",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Lib.Buffer.lbuffer_t",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Lib.ByteSequence.nat_from_intseq_le",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.as_seq",
"Lib.IntTypes.uint_t",
"Prims.op_Modulus",
"Lib.ByteSequence.nat_from_bytes_le",
"Prims.pow2",
"Hacl.Spec.Curve25519.Field64.Lemmas.lemma_felem64_mod255",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.Sequence.index",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.IntTypes.range_t",
"Lib.IntTypes.mod_mask",
"Lib.IntTypes.u64",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.op_Subtraction",
"Lib.IntTypes.mod_mask_lemma",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.int_t",
"Lib.Buffer.op_Array_Access",
"Prims.nat",
"Prims.l_or",
"FStar.Mul.op_Star",
"Lib.Sequence.length",
"Lib.IntTypes.bits",
"Lib.IntTypes.U8",
"Lib.ByteSequence.uints_from_bytes_le_nat_lemma",
"Lib.ByteBuffer.uints_from_bytes_le",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let decode_point #s o i =
| push_frame ();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x:felem s = sub o 0ul (nlimb s) in
let z:felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame () | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.log256_32 | val log256_32 (n: U32.t{U32.v n > 0}) : Tot (y: U8.t{U8.v y == log256' (U32.v n)}) | val log256_32 (n: U32.t{U32.v n > 0}) : Tot (y: U8.t{U8.v y == log256' (U32.v n)}) | let log256_32
(n: U32.t { U32.v n > 0 } )
: Tot (y: U8.t { U8.v y == log256' (U32.v n) } )
= if n `U32.lt` 256ul
then 1uy
else if n `U32.lt` 65536ul
then 2uy
else if n `U32.lt` 16777216ul
then 3uy
else 4uy | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 10,
"end_line": 237,
"start_col": 0,
"start_line": 228
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None
[@@(noextract_to "krml")]
let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len
[@@(noextract_to "krml")]
let der_length_payload_size
(x: der_length_t)
: Tot (y: nat { y <= 126 })
= der_length_payload_size_of_tag (tag_of_der_length x)
val der_length_payload_size_le
(x1 x2: der_length_t)
: Lemma
(requires (x1 <= x2))
(ensures (der_length_payload_size x1 <= der_length_payload_size x2))
let lint (len: nat) : Tot Type = (x: nat { x < pow2 (8 * len) })
module U32 = FStar.UInt32
let tag_of_der_length32
(x: U32.t)
: GTot U8.t
= let _ = assert_norm (pow2 32 - 1 <= der_length_max) in
tag_of_der_length (U32.v x)
val parse_der_length_payload32
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
: Tot (parser (parse_der_length_payload_kind x) (refine_with_tag tag_of_der_length32 x))
val parse_der_length_payload32_unfold
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
(input: bytes)
: Lemma
(
let y = parse (parse_der_length_payload32 x) input in
(256 < der_length_max) /\ (
if U8.v x < 128
then tag_of_der_length (U8.v x) == x /\ y == Some (Cast.uint8_to_uint32 x, 0)
else if x = 128uy || x = 255uy
then y == None
else if x = 129uy
then
match parse parse_u8 input with
| None -> y == None
| Some (z, consumed) ->
if U8.v z < 128
then y == None
else tag_of_der_length (U8.v z) == x /\ y == Some (Cast.uint8_to_uint32 z, consumed)
else
let len : nat = U8.v x - 128 in
2 <= len /\ len <= 4 /\
(
let res : option (bounded_integer len & consumed_length input) = parse (parse_bounded_integer len) input in
match res with
| None -> y == None
| Some (z, consumed) ->
len > 0 /\ (
if U32.v z >= pow2 (8 * (len - 1))
then U32.v z <= der_length_max /\ tag_of_der_length32 z == x /\ y == Some ((z <: refine_with_tag tag_of_der_length32 x), consumed)
else y == None
))))
val log256_eq
(x: nat)
: Lemma
(requires (x > 0 /\ x < 4294967296))
(ensures (log256 x == log256' x))
inline_for_extraction
let tag_of_der_length32'
(x: der_length_t { x < 4294967296 } )
: Tot (z: U8.t { z == tag_of_der_length x })
= if x < 128
then U8.uint_to_t x
else
[@inline_let]
let len_len = log256' x in
[@inline_let] let _ =
log256_eq x;
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126)
in
128uy `U8.add` U8.uint_to_t len_len
inline_for_extraction
let parse_bounded_der_length_payload32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
= [@inline_let] let _ = der_length_payload_size_le min max in
strong_parser_kind (der_length_payload_size_of_tag (tag_of_der_length32' min)) (der_length_payload_size_of_tag (tag_of_der_length32' max)) None
inline_for_extraction
let parse_bounded_der_length32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
=
[@inline_let]
let k = parse_bounded_der_length_payload32_kind min max in
strong_parser_kind (1 + der_length_payload_size_of_tag (tag_of_der_length32' min)) (1 + der_length_payload_size_of_tag (tag_of_der_length32' max)) None
val parse_bounded_der_length32
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 })
: Tot (parser (parse_bounded_der_length32_kind min max) (bounded_int32 min max))
val parse_bounded_der_length32_unfold
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 })
(input: bytes)
: Lemma
(let res = parse (parse_bounded_der_length32 min max) input in
match parse parse_u8 input with
| None -> res == None
| Some (x, consumed_x) ->
let len = der_length_payload_size_of_tag x in
if der_length_payload_size min <= len && len <= der_length_payload_size max then
let input' = Seq.slice input consumed_x (Seq.length input) in
len <= 4 /\ (
match parse (parse_der_length_payload32 x) input' with
| Some (y, consumed_y) ->
if min <= U32.v y && U32.v y <= max
then res == Some (y, consumed_x + consumed_y)
else res == None
| None -> res == None
) else
res == None
)
inline_for_extraction
let der_length_payload_size_of_tag8
(x: U8.t)
: Tot (y: U8.t { U8.v y == der_length_payload_size_of_tag x } )
= [@inline_let]
let _ =
assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max)
in
if x `U8.lt` 129uy || x = 255uy
then
0uy
else
x `U8.sub` 128uy | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: FStar.UInt32.t{FStar.UInt32.v n > 0}
-> y: FStar.UInt8.t{FStar.UInt8.v y == LowParse.Spec.BoundedInt.log256' (FStar.UInt32.v n)} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.UInt32.v",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"FStar.UInt8.__uint_to_t",
"Prims.bool",
"FStar.UInt8.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"FStar.UInt8.v",
"LowParse.Spec.BoundedInt.log256'"
] | [] | false | false | false | false | false | let log256_32 (n: U32.t{U32.v n > 0}) : Tot (y: U8.t{U8.v y == log256' (U32.v n)}) =
| if n `U32.lt` 256ul
then 1uy
else if n `U32.lt` 65536ul then 2uy else if n `U32.lt` 16777216ul then 3uy else 4uy | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.arg_is_registered_root | val arg_is_registered_root : h: Vale.X64.Memory.vale_heap -> a: Vale.Interop.Base.arg -> Type0 | let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 88,
"start_col": 0,
"start_line": 82
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: Vale.X64.Memory.vale_heap -> a: Vale.Interop.Base.arg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Memory.vale_heap",
"Vale.Interop.Base.arg",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Types.b8",
"Vale.Interop.Base.mut_to_b8",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Vale.X64.MemoryAdapters.as_mem",
"Vale.Interop.Base.TD_ImmBuffer",
"Vale.Interop.Base.imm_to_b8",
"Prims.dtuple2",
"Vale.Interop.Base.td",
"Prims.b2t"
] | [] | false | false | false | true | true | let arg_is_registered_root (h: ME.vale_heap) (a: arg) =
| match a with
| (| TD_Buffer src bt _ , x |) -> List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _ , x |) -> List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true | false |
|
LowParse.Spec.DER.fsti | LowParse.Spec.DER.tag_of_der_length | val tag_of_der_length (x: der_length_t) : Tot U8.t | val tag_of_der_length (x: der_length_t) : Tot U8.t | let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 39,
"end_line": 80,
"start_col": 0,
"start_line": 71
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: LowParse.Spec.DER.der_length_t -> FStar.UInt8.t | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.DER.der_length_t",
"Prims.op_LessThan",
"FStar.UInt8.uint_to_t",
"Prims.bool",
"FStar.UInt8.add",
"FStar.UInt8.__uint_to_t",
"Prims.unit",
"LowParse.Math.pow2_lt_recip",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"LowParse.Spec.DER.der_length_max",
"Prims.pow2",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Prims.op_Multiply",
"LowParse.Spec.DER.log256",
"FStar.UInt8.t"
] | [] | false | false | false | true | false | let tag_of_der_length (x: der_length_t) : Tot U8.t =
| if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` (U8.uint_to_t len_len) | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.der_length_payload_size_of_tag8 | val der_length_payload_size_of_tag8 (x: U8.t)
: Tot (y: U8.t{U8.v y == der_length_payload_size_of_tag x}) | val der_length_payload_size_of_tag8 (x: U8.t)
: Tot (y: U8.t{U8.v y == der_length_payload_size_of_tag x}) | let der_length_payload_size_of_tag8
(x: U8.t)
: Tot (y: U8.t { U8.v y == der_length_payload_size_of_tag x } )
= [@inline_let]
let _ =
assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max)
in
if x `U8.lt` 129uy || x = 255uy
then
0uy
else
x `U8.sub` 128uy | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 20,
"end_line": 225,
"start_col": 0,
"start_line": 210
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None
[@@(noextract_to "krml")]
let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len
[@@(noextract_to "krml")]
let der_length_payload_size
(x: der_length_t)
: Tot (y: nat { y <= 126 })
= der_length_payload_size_of_tag (tag_of_der_length x)
val der_length_payload_size_le
(x1 x2: der_length_t)
: Lemma
(requires (x1 <= x2))
(ensures (der_length_payload_size x1 <= der_length_payload_size x2))
let lint (len: nat) : Tot Type = (x: nat { x < pow2 (8 * len) })
module U32 = FStar.UInt32
let tag_of_der_length32
(x: U32.t)
: GTot U8.t
= let _ = assert_norm (pow2 32 - 1 <= der_length_max) in
tag_of_der_length (U32.v x)
val parse_der_length_payload32
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
: Tot (parser (parse_der_length_payload_kind x) (refine_with_tag tag_of_der_length32 x))
val parse_der_length_payload32_unfold
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
(input: bytes)
: Lemma
(
let y = parse (parse_der_length_payload32 x) input in
(256 < der_length_max) /\ (
if U8.v x < 128
then tag_of_der_length (U8.v x) == x /\ y == Some (Cast.uint8_to_uint32 x, 0)
else if x = 128uy || x = 255uy
then y == None
else if x = 129uy
then
match parse parse_u8 input with
| None -> y == None
| Some (z, consumed) ->
if U8.v z < 128
then y == None
else tag_of_der_length (U8.v z) == x /\ y == Some (Cast.uint8_to_uint32 z, consumed)
else
let len : nat = U8.v x - 128 in
2 <= len /\ len <= 4 /\
(
let res : option (bounded_integer len & consumed_length input) = parse (parse_bounded_integer len) input in
match res with
| None -> y == None
| Some (z, consumed) ->
len > 0 /\ (
if U32.v z >= pow2 (8 * (len - 1))
then U32.v z <= der_length_max /\ tag_of_der_length32 z == x /\ y == Some ((z <: refine_with_tag tag_of_der_length32 x), consumed)
else y == None
))))
val log256_eq
(x: nat)
: Lemma
(requires (x > 0 /\ x < 4294967296))
(ensures (log256 x == log256' x))
inline_for_extraction
let tag_of_der_length32'
(x: der_length_t { x < 4294967296 } )
: Tot (z: U8.t { z == tag_of_der_length x })
= if x < 128
then U8.uint_to_t x
else
[@inline_let]
let len_len = log256' x in
[@inline_let] let _ =
log256_eq x;
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126)
in
128uy `U8.add` U8.uint_to_t len_len
inline_for_extraction
let parse_bounded_der_length_payload32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
= [@inline_let] let _ = der_length_payload_size_le min max in
strong_parser_kind (der_length_payload_size_of_tag (tag_of_der_length32' min)) (der_length_payload_size_of_tag (tag_of_der_length32' max)) None
inline_for_extraction
let parse_bounded_der_length32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
=
[@inline_let]
let k = parse_bounded_der_length_payload32_kind min max in
strong_parser_kind (1 + der_length_payload_size_of_tag (tag_of_der_length32' min)) (1 + der_length_payload_size_of_tag (tag_of_der_length32' max)) None
val parse_bounded_der_length32
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 })
: Tot (parser (parse_bounded_der_length32_kind min max) (bounded_int32 min max))
val parse_bounded_der_length32_unfold
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 })
(input: bytes)
: Lemma
(let res = parse (parse_bounded_der_length32 min max) input in
match parse parse_u8 input with
| None -> res == None
| Some (x, consumed_x) ->
let len = der_length_payload_size_of_tag x in
if der_length_payload_size min <= len && len <= der_length_payload_size max then
let input' = Seq.slice input consumed_x (Seq.length input) in
len <= 4 /\ (
match parse (parse_der_length_payload32 x) input' with
| Some (y, consumed_y) ->
if min <= U32.v y && U32.v y <= max
then res == Some (y, consumed_x + consumed_y)
else res == None
| None -> res == None
) else
res == None
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt8.t
-> y: FStar.UInt8.t{FStar.UInt8.v y == LowParse.Spec.DER.der_length_payload_size_of_tag x} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt8.t",
"Prims.op_BarBar",
"FStar.UInt8.lt",
"FStar.UInt8.__uint_to_t",
"Prims.op_Equality",
"Prims.bool",
"FStar.UInt8.sub",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"FStar.UInt8.v",
"LowParse.Spec.DER.der_length_payload_size_of_tag",
"Prims.unit",
"Prims._assert",
"LowParse.Spec.DER.der_length_max",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Subtraction",
"FStar.Mul.op_Star"
] | [] | false | false | false | false | false | let der_length_payload_size_of_tag8 (x: U8.t)
: Tot (y: U8.t{U8.v y == der_length_payload_size_of_tag x}) =
| [@@ inline_let ]let _ =
assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max)
in
if x `U8.lt` 129uy || x = 255uy then 0uy else x `U8.sub` 128uy | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.der_length_payload_size_of_tag | val der_length_payload_size_of_tag (x: U8.t) : Tot (y: nat{y <= 126}) | val der_length_payload_size_of_tag (x: U8.t) : Tot (y: nat{y <= 126}) | let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128 | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 12,
"end_line": 63,
"start_col": 0,
"start_line": 49
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt8.t -> y: Prims.nat{y <= 126} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt8.t",
"Prims.op_BarBar",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.op_Subtraction",
"Prims.nat",
"Prims.b2t",
"FStar.UInt.uint_t",
"FStar.UInt8.v",
"Prims.unit",
"Prims._assert",
"LowParse.Spec.DER.der_length_max",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.pow2",
"FStar.Mul.op_Star"
] | [] | false | false | false | false | false | let der_length_payload_size_of_tag (x: U8.t) : Tot (y: nat{y <= 126}) =
| assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@@ inline_let ]let x' = U8.v x in
if x' <= 128 || x' = 255 then 0 else x' - 128 | false |
Hacl.Spec.Chacha20.Lemmas.fst | Hacl.Spec.Chacha20.Lemmas.transpose_lemma_index | val transpose_lemma_index: #w:lanes -> k:state w -> i:nat{i < 16 * w} ->
Lemma ((vec_v (transpose #w k).[i / w]).[i % w] == ((transpose_state k).[i / 16]).[i % 16]) | val transpose_lemma_index: #w:lanes -> k:state w -> i:nat{i < 16 * w} ->
Lemma ((vec_v (transpose #w k).[i / w]).[i % w] == ((transpose_state k).[i / 16]).[i % 16]) | let transpose_lemma_index #w k i =
match w with
| 1 -> ()
| 4 -> transpose4_lemma k i
| 8 -> transpose8_lemma k i | {
"file_name": "code/chacha20/Hacl.Spec.Chacha20.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 43,
"start_col": 0,
"start_line": 39
} | module Hacl.Spec.Chacha20.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.IntVector
open Lib.IntVector.Transpose
open Hacl.Spec.Chacha20.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1"
/// (vec_v (transpose #w k).[i / w]).[i % w] == ((transpose_state k).[i / 16]).[i % 16]
val transpose4_lemma: k:state 4 -> i:nat{i < 16 * 4} ->
Lemma ((vec_v (transpose4 k).[i / 4]).[i % 4] == ((transpose_state k).[i / 16]).[i % 16])
let transpose4_lemma st i =
let r0 = transpose4x4_lseq (sub st 0 4) in
transpose4x4_lemma (sub st 0 4);
let r1 = transpose4x4_lseq (sub st 4 4) in
transpose4x4_lemma (sub st 4 4);
let r2 = transpose4x4_lseq (sub st 8 4) in
transpose4x4_lemma (sub st 8 4);
let r3 = transpose4x4_lseq (sub st 12 4) in
transpose4x4_lemma (sub st 12 4)
val transpose8_lemma: k:state 8 -> i:nat{i < 16 * 8} ->
Lemma ((vec_v (transpose8 k).[i / 8]).[i % 8] == ((transpose_state k).[i / 16]).[i % 16])
let transpose8_lemma st i =
let r0 = transpose8x8_lseq (sub st 0 8) in
transpose8x8_lemma (sub st 0 8);
let r1 = transpose8x8_lseq (sub st 8 8) in
transpose8x8_lemma (sub st 8 8)
val transpose_lemma_index: #w:lanes -> k:state w -> i:nat{i < 16 * w} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.Transpose.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Chacha20.Vec.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Chacha20.Lemmas.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector.Transpose",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Spec.Chacha20.Vec.state w -> i: Prims.nat{i < 16 * w}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.vec_v (Hacl.Spec.Chacha20.Vec.transpose k).[ i / w ]).[ i % w ] ==
(Hacl.Spec.Chacha20.Vec.transpose_state k).[ i / 16 ].[ i % 16 ]) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Chacha20.Vec.lanes",
"Hacl.Spec.Chacha20.Vec.state",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Hacl.Spec.Chacha20.Lemmas.transpose4_lemma",
"Hacl.Spec.Chacha20.Lemmas.transpose8_lemma",
"Prims.unit"
] | [] | false | false | true | false | false | let transpose_lemma_index #w k i =
| match w with
| 1 -> ()
| 4 -> transpose4_lemma k i
| 8 -> transpose8_lemma k i | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.tag_of_der_length32_impl | val tag_of_der_length32_impl (x: U32.t)
: Tot (y: U8.t{U32.v x < der_length_max /\ y == tag_of_der_length (U32.v x)}) | val tag_of_der_length32_impl (x: U32.t)
: Tot (y: U8.t{U32.v x < der_length_max /\ y == tag_of_der_length (U32.v x)}) | let tag_of_der_length32_impl
(x: U32.t)
: Tot (y: U8.t { U32.v x < der_length_max /\ y == tag_of_der_length (U32.v x) } )
= [@inline_let]
let _ = assert_norm (4294967296 <= der_length_max) in
if x `U32.lt` 128ul
then begin
[@inline_let] let _ = FStar.Math.Lemmas.small_modulo_lemma_1 (U32.v x) 256 in
Cast.uint32_to_uint8 x <: U8.t
end else
let len_len = log256_32 x in
[@inline_let] let _ =
log256_eq (U32.v x);
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (U8.v len_len - 1)) (8 * 126)
in
128uy `U8.add` len_len | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 26,
"end_line": 256,
"start_col": 0,
"start_line": 240
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None
[@@(noextract_to "krml")]
let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len
[@@(noextract_to "krml")]
let der_length_payload_size
(x: der_length_t)
: Tot (y: nat { y <= 126 })
= der_length_payload_size_of_tag (tag_of_der_length x)
val der_length_payload_size_le
(x1 x2: der_length_t)
: Lemma
(requires (x1 <= x2))
(ensures (der_length_payload_size x1 <= der_length_payload_size x2))
let lint (len: nat) : Tot Type = (x: nat { x < pow2 (8 * len) })
module U32 = FStar.UInt32
let tag_of_der_length32
(x: U32.t)
: GTot U8.t
= let _ = assert_norm (pow2 32 - 1 <= der_length_max) in
tag_of_der_length (U32.v x)
val parse_der_length_payload32
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
: Tot (parser (parse_der_length_payload_kind x) (refine_with_tag tag_of_der_length32 x))
val parse_der_length_payload32_unfold
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
(input: bytes)
: Lemma
(
let y = parse (parse_der_length_payload32 x) input in
(256 < der_length_max) /\ (
if U8.v x < 128
then tag_of_der_length (U8.v x) == x /\ y == Some (Cast.uint8_to_uint32 x, 0)
else if x = 128uy || x = 255uy
then y == None
else if x = 129uy
then
match parse parse_u8 input with
| None -> y == None
| Some (z, consumed) ->
if U8.v z < 128
then y == None
else tag_of_der_length (U8.v z) == x /\ y == Some (Cast.uint8_to_uint32 z, consumed)
else
let len : nat = U8.v x - 128 in
2 <= len /\ len <= 4 /\
(
let res : option (bounded_integer len & consumed_length input) = parse (parse_bounded_integer len) input in
match res with
| None -> y == None
| Some (z, consumed) ->
len > 0 /\ (
if U32.v z >= pow2 (8 * (len - 1))
then U32.v z <= der_length_max /\ tag_of_der_length32 z == x /\ y == Some ((z <: refine_with_tag tag_of_der_length32 x), consumed)
else y == None
))))
val log256_eq
(x: nat)
: Lemma
(requires (x > 0 /\ x < 4294967296))
(ensures (log256 x == log256' x))
inline_for_extraction
let tag_of_der_length32'
(x: der_length_t { x < 4294967296 } )
: Tot (z: U8.t { z == tag_of_der_length x })
= if x < 128
then U8.uint_to_t x
else
[@inline_let]
let len_len = log256' x in
[@inline_let] let _ =
log256_eq x;
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126)
in
128uy `U8.add` U8.uint_to_t len_len
inline_for_extraction
let parse_bounded_der_length_payload32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
= [@inline_let] let _ = der_length_payload_size_le min max in
strong_parser_kind (der_length_payload_size_of_tag (tag_of_der_length32' min)) (der_length_payload_size_of_tag (tag_of_der_length32' max)) None
inline_for_extraction
let parse_bounded_der_length32_kind
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 } )
: Tot parser_kind
=
[@inline_let]
let k = parse_bounded_der_length_payload32_kind min max in
strong_parser_kind (1 + der_length_payload_size_of_tag (tag_of_der_length32' min)) (1 + der_length_payload_size_of_tag (tag_of_der_length32' max)) None
val parse_bounded_der_length32
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 })
: Tot (parser (parse_bounded_der_length32_kind min max) (bounded_int32 min max))
val parse_bounded_der_length32_unfold
(min: der_length_t)
(max: der_length_t { min <= max /\ max < 4294967296 })
(input: bytes)
: Lemma
(let res = parse (parse_bounded_der_length32 min max) input in
match parse parse_u8 input with
| None -> res == None
| Some (x, consumed_x) ->
let len = der_length_payload_size_of_tag x in
if der_length_payload_size min <= len && len <= der_length_payload_size max then
let input' = Seq.slice input consumed_x (Seq.length input) in
len <= 4 /\ (
match parse (parse_der_length_payload32 x) input' with
| Some (y, consumed_y) ->
if min <= U32.v y && U32.v y <= max
then res == Some (y, consumed_x + consumed_y)
else res == None
| None -> res == None
) else
res == None
)
inline_for_extraction
let der_length_payload_size_of_tag8
(x: U8.t)
: Tot (y: U8.t { U8.v y == der_length_payload_size_of_tag x } )
= [@inline_let]
let _ =
assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max)
in
if x `U8.lt` 129uy || x = 255uy
then
0uy
else
x `U8.sub` 128uy
inline_for_extraction
let log256_32
(n: U32.t { U32.v n > 0 } )
: Tot (y: U8.t { U8.v y == log256' (U32.v n) } )
= if n `U32.lt` 256ul
then 1uy
else if n `U32.lt` 65536ul
then 2uy
else if n `U32.lt` 16777216ul
then 3uy
else 4uy | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt32.t
-> y:
FStar.UInt8.t
{ FStar.UInt32.v x < LowParse.Spec.DER.der_length_max /\
y == LowParse.Spec.DER.tag_of_der_length (FStar.UInt32.v x) } | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"FStar.Int.Cast.uint32_to_uint8",
"FStar.UInt8.t",
"Prims.unit",
"FStar.Math.Lemmas.small_modulo_lemma_1",
"FStar.UInt32.v",
"Prims.bool",
"FStar.UInt8.add",
"FStar.UInt8.__uint_to_t",
"LowParse.Math.pow2_lt_recip",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"FStar.UInt8.v",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"LowParse.Spec.DER.der_length_max",
"Prims.pow2",
"LowParse.Spec.DER.log256_eq",
"Prims.l_or",
"FStar.UInt.size",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.DER.log256_32",
"Prims.op_LessThan",
"LowParse.Spec.DER.tag_of_der_length"
] | [] | false | false | false | false | false | let tag_of_der_length32_impl (x: U32.t)
: Tot (y: U8.t{U32.v x < der_length_max /\ y == tag_of_der_length (U32.v x)}) =
| [@@ inline_let ]let _ = assert_norm (4294967296 <= der_length_max) in
if x `U32.lt` 128ul
then
[@@ inline_let ]let _ = FStar.Math.Lemmas.small_modulo_lemma_1 (U32.v x) 256 in
Cast.uint32_to_uint8 x <: U8.t
else
let len_len = log256_32 x in
[@@ inline_let ]let _ =
log256_eq (U32.v x);
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (U8.v len_len - 1)) (8 * 126)
in
128uy `U8.add` len_len | false |
LowParse.Spec.DER.fsti | LowParse.Spec.DER.tag_of_der_length32' | val tag_of_der_length32' (x: der_length_t{x < 4294967296}) : Tot (z: U8.t{z == tag_of_der_length x}) | val tag_of_der_length32' (x: der_length_t{x < 4294967296}) : Tot (z: U8.t{z == tag_of_der_length x}) | let tag_of_der_length32'
(x: der_length_t { x < 4294967296 } )
: Tot (z: U8.t { z == tag_of_der_length x })
= if x < 128
then U8.uint_to_t x
else
[@inline_let]
let len_len = log256' x in
[@inline_let] let _ =
log256_eq x;
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126)
in
128uy `U8.add` U8.uint_to_t len_len | {
"file_name": "src/lowparse/LowParse.Spec.DER.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 39,
"end_line": 161,
"start_col": 0,
"start_line": 148
} | module LowParse.Spec.DER
include LowParse.Spec.Int
include LowParse.Spec.BoundedInt
open FStar.Mul
module U8 = FStar.UInt8
module UInt = FStar.UInt
module Seq = FStar.Seq
module Math = LowParse.Math
module Cast = FStar.Int.Cast
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0"
let der_length_max : nat = 2743062034396844341627968125593604635037196317966166035056000994228098690879836473582587849768181396806642362668936055872479091931372323951612051859122835149807249350355003132267795098895967012320756270631179897595796976964454084495146379250195728106130226298287754794921070036903071843030324651025760255
// _ by (FStar.Tactics.(exact (norm_term [delta; iota; zeta; primops] (`(pow2 (8 * 126) - 1)))))
val der_length_max_eq : squash (der_length_max == pow2 (8 * 126) - 1)
// let _ = intro_ambient der_length_max
let der_length_t = (x: nat { x <= der_length_max })
[@@(noextract_to "krml")]
val log256
(x: nat { x > 0 })
: Tot (y: nat { y > 0 /\ pow2 (8 * (y - 1)) <= x /\ x < pow2 (8 * y)})
val log256_unique
(x: nat)
(y: nat)
: Lemma
(requires (
x > 0 /\
y > 0 /\
pow2 (8 * (y - 1)) <= x /\
x < pow2 (8 * y)
))
(ensures (y == log256 x))
val log256_le
(x1 x2: nat)
: Lemma
(requires (0 < x1 /\ x1 <= x2))
(ensures (log256 x1 <= log256 x2))
inline_for_extraction // for parser_kind
let der_length_payload_size_of_tag
(x: U8.t)
: Tot (y: nat { y <= 126 })
= assert_norm (der_length_max == pow2 (8 * 126) - 1);
assert_norm (pow2 7 == 128);
assert_norm (pow2 8 == 256);
assert_norm (256 < der_length_max);
assert (U8.v x <= der_length_max);
[@inline_let]
let x' = U8.v x in
if x' <= 128 || x' = 255
then
0
else
x' - 128
inline_for_extraction
let parse_der_length_payload_kind (x: U8.t) : Tot parser_kind =
let len = der_length_payload_size_of_tag x in
strong_parser_kind len len None
[@@(noextract_to "krml")]
let tag_of_der_length
(x: der_length_t)
: Tot U8.t
= if x < 128
then U8.uint_to_t x
else
let len_len = log256 x in
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126);
128uy `U8.add` U8.uint_to_t len_len
[@@(noextract_to "krml")]
let der_length_payload_size
(x: der_length_t)
: Tot (y: nat { y <= 126 })
= der_length_payload_size_of_tag (tag_of_der_length x)
val der_length_payload_size_le
(x1 x2: der_length_t)
: Lemma
(requires (x1 <= x2))
(ensures (der_length_payload_size x1 <= der_length_payload_size x2))
let lint (len: nat) : Tot Type = (x: nat { x < pow2 (8 * len) })
module U32 = FStar.UInt32
let tag_of_der_length32
(x: U32.t)
: GTot U8.t
= let _ = assert_norm (pow2 32 - 1 <= der_length_max) in
tag_of_der_length (U32.v x)
val parse_der_length_payload32
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
: Tot (parser (parse_der_length_payload_kind x) (refine_with_tag tag_of_der_length32 x))
val parse_der_length_payload32_unfold
(x: U8.t { der_length_payload_size_of_tag x <= 4 } )
(input: bytes)
: Lemma
(
let y = parse (parse_der_length_payload32 x) input in
(256 < der_length_max) /\ (
if U8.v x < 128
then tag_of_der_length (U8.v x) == x /\ y == Some (Cast.uint8_to_uint32 x, 0)
else if x = 128uy || x = 255uy
then y == None
else if x = 129uy
then
match parse parse_u8 input with
| None -> y == None
| Some (z, consumed) ->
if U8.v z < 128
then y == None
else tag_of_der_length (U8.v z) == x /\ y == Some (Cast.uint8_to_uint32 z, consumed)
else
let len : nat = U8.v x - 128 in
2 <= len /\ len <= 4 /\
(
let res : option (bounded_integer len & consumed_length input) = parse (parse_bounded_integer len) input in
match res with
| None -> y == None
| Some (z, consumed) ->
len > 0 /\ (
if U32.v z >= pow2 (8 * (len - 1))
then U32.v z <= der_length_max /\ tag_of_der_length32 z == x /\ y == Some ((z <: refine_with_tag tag_of_der_length32 x), consumed)
else y == None
))))
val log256_eq
(x: nat)
: Lemma
(requires (x > 0 /\ x < 4294967296))
(ensures (log256 x == log256' x)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.DER.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "Math"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt",
"short_module": "UInt"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: LowParse.Spec.DER.der_length_t{x < 4294967296}
-> z: FStar.UInt8.t{z == LowParse.Spec.DER.tag_of_der_length x} | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.DER.der_length_t",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt8.uint_to_t",
"Prims.bool",
"FStar.UInt8.add",
"FStar.UInt8.__uint_to_t",
"Prims.unit",
"LowParse.Math.pow2_lt_recip",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"LowParse.Spec.DER.der_length_max",
"Prims.pow2",
"LowParse.Spec.DER.log256_eq",
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.log256'",
"FStar.UInt8.t",
"LowParse.Spec.DER.tag_of_der_length"
] | [] | false | false | false | false | false | let tag_of_der_length32' (x: der_length_t{x < 4294967296}) : Tot (z: U8.t{z == tag_of_der_length x}) =
| if x < 128
then U8.uint_to_t x
else
[@@ inline_let ]let len_len = log256' x in
[@@ inline_let ]let _ =
log256_eq x;
assert_norm (der_length_max == pow2 (8 * 126) - 1);
Math.pow2_lt_recip (8 * (len_len - 1)) (8 * 126)
in
128uy `U8.add` (U8.uint_to_t len_len) | false |
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.cswap2 | val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2)) | val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2)) | let cswap2 #s bit p0 p1 =
C.cswap2 #s bit p0 p1 | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 132,
"start_col": 0,
"start_line": 131
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1)
let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1)
inline_for_extraction noextract
val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1)
[@ Meta.Attribute.specialize ]
let decode_point #s o i =
push_frame();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x : felem s = sub o 0ul (nlimb s) in
let z : felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame()
val encode_point:
#s:field_spec
-> o:lbuffer uint8 32ul
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 i /\ disjoint o i /\
state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
as_seq h1 o == S.encodePoint (fget_x h0 i, fget_z h0 i))
[@ Meta.Attribute.specialize ]
let encode_point #s o i =
push_frame();
let x : felem s = sub i 0ul (nlimb s) in
let z : felem s = sub i (nlimb s) (nlimb s) in
let tmp = create_felem s in
let u64s = create 4ul (u64 0) in
let tmp_w = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let h0 = ST.get () in
finv tmp z tmp_w;
fmul tmp tmp x tmp_w;
let h1 = ST.get () in
assert (feval h1 tmp == S.fmul (S.fpow (feval h0 z) (pow2 255 - 21)) (feval h0 x));
assert (feval h1 tmp == S.fmul (feval h0 x) (S.fpow (feval h0 z) (pow2 255 - 21)));
store_felem u64s tmp;
let h2 = ST.get () in
assert (as_seq h2 u64s == BSeq.nat_to_intseq_le 4 (feval h1 tmp));
uints_to_bytes_le #U64 4ul o u64s;
let h3 = ST.get () in
BSeq.uints_to_bytes_le_nat_lemma #U64 #SEC 4 (feval h1 tmp);
assert (as_seq h3 o == BSeq.nat_to_bytes_le 32 (feval h1 tmp));
pop_frame()
// TODO: why re-define the signature here?
val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2)) | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
bit: Lib.IntTypes.uint64{Lib.IntTypes.v bit <= 1} ->
p1: Hacl.Impl.Curve25519.Fields.Core.felem2 s ->
p2: Hacl.Impl.Curve25519.Fields.Core.felem2 s
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.IntTypes.uint64",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Hacl.Impl.Curve25519.Fields.Core.cswap2",
"Prims.unit"
] | [] | false | true | false | false | false | let cswap2 #s bit p0 p1 =
| C.cswap2 #s bit p0 p1 | false |
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.dec_metric | val dec_metric : lo: FStar.DM4F.Heap.IntStoreFixed.id ->
hi: FStar.DM4F.Heap.IntStoreFixed.id{lo <> hi} ->
h: Rel.rel FStar.DM4F.Heap.IntStoreFixed.heap
-> Prims.int | let dec_metric (lo:id) (hi:id{lo<>hi}) (h :rel heap) =
nat_of (sel (R?.l h) hi) +
nat_of (sel (R?.r h) hi) | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 54,
"start_col": 0,
"start_line": 52
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi))
let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1)
let p1_r lo (hi:id{lo<>hi}) h = (* normalize_term *) (snd (reify (p1 lo hi h) h))
let nat_of (x:int) : nat = if x < 0 then 0 else x | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
lo: FStar.DM4F.Heap.IntStoreFixed.id ->
hi: FStar.DM4F.Heap.IntStoreFixed.id{lo <> hi} ->
h: Rel.rel FStar.DM4F.Heap.IntStoreFixed.heap
-> Prims.int | Prims.Tot | [
"total"
] | [] | [
"FStar.DM4F.Heap.IntStoreFixed.id",
"Prims.b2t",
"Prims.op_disEquality",
"Rel.rel",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"Prims.op_Addition",
"IfcRecursiveHeapReify.nat_of",
"FStar.DM4F.Heap.IntStoreFixed.sel",
"Rel.__proj__R__item__l",
"Rel.__proj__R__item__r",
"Prims.int"
] | [] | false | false | false | false | false | let dec_metric (lo: id) (hi: id{lo <> hi}) (h: rel heap) =
| nat_of (sel (R?.l h) hi) + nat_of (sel (R?.r h) hi) | false |
|
Hacl.Spec.Chacha20.Lemmas.fst | Hacl.Spec.Chacha20.Lemmas.transpose4_lemma | val transpose4_lemma: k:state 4 -> i:nat{i < 16 * 4} ->
Lemma ((vec_v (transpose4 k).[i / 4]).[i % 4] == ((transpose_state k).[i / 16]).[i % 16]) | val transpose4_lemma: k:state 4 -> i:nat{i < 16 * 4} ->
Lemma ((vec_v (transpose4 k).[i / 4]).[i % 4] == ((transpose_state k).[i / 16]).[i % 16]) | let transpose4_lemma st i =
let r0 = transpose4x4_lseq (sub st 0 4) in
transpose4x4_lemma (sub st 0 4);
let r1 = transpose4x4_lseq (sub st 4 4) in
transpose4x4_lemma (sub st 4 4);
let r2 = transpose4x4_lseq (sub st 8 4) in
transpose4x4_lemma (sub st 8 4);
let r3 = transpose4x4_lseq (sub st 12 4) in
transpose4x4_lemma (sub st 12 4) | {
"file_name": "code/chacha20/Hacl.Spec.Chacha20.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 25,
"start_col": 0,
"start_line": 17
} | module Hacl.Spec.Chacha20.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.IntVector
open Lib.IntVector.Transpose
open Hacl.Spec.Chacha20.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1"
/// (vec_v (transpose #w k).[i / w]).[i % w] == ((transpose_state k).[i / 16]).[i % 16]
val transpose4_lemma: k:state 4 -> i:nat{i < 16 * 4} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.Transpose.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Chacha20.Vec.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Chacha20.Lemmas.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector.Transpose",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Spec.Chacha20.Vec.state 4 -> i: Prims.nat{i < 16 * 4}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.vec_v (Hacl.Spec.Chacha20.Vec.transpose4 k).[ i / 4 ]).[ i % 4 ] ==
(Hacl.Spec.Chacha20.Vec.transpose_state k).[ i / 16 ].[ i % 16 ]) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Chacha20.Vec.state",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Lib.IntVector.Transpose.transpose4x4_lemma",
"Lib.IntTypes.U32",
"Lib.Sequence.sub",
"Hacl.Spec.Chacha20.Vec.uint32xN",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.IntVector.Transpose.transpose4x4_lseq",
"Prims.unit"
] | [] | true | false | true | false | false | let transpose4_lemma st i =
| let r0 = transpose4x4_lseq (sub st 0 4) in
transpose4x4_lemma (sub st 0 4);
let r1 = transpose4x4_lseq (sub st 4 4) in
transpose4x4_lemma (sub st 4 4);
let r2 = transpose4x4_lseq (sub st 8 4) in
transpose4x4_lemma (sub st 8 4);
let r3 = transpose4x4_lseq (sub st 12 4) in
transpose4x4_lemma (sub st 12 4) | false |
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.op_Star | val op_Star : _: Prims.int -> _: Prims.int -> Prims.int | let op_Star = op_Multiply | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 25,
"end_line": 114,
"start_col": 0,
"start_line": 114
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi))
let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1)
let p1_r lo (hi:id{lo<>hi}) h = (* normalize_term *) (snd (reify (p1 lo hi h) h))
let nat_of (x:int) : nat = if x < 0 then 0 else x
//inlining this leads to a crash!
let dec_metric (lo:id) (hi:id{lo<>hi}) (h :rel heap) =
nat_of (sel (R?.l h) hi) +
nat_of (sel (R?.r h) hi)
#set-options "--z3rlimit 60"
let rec ni_p1 (lo:id) (hi:id{lo<>hi}) (env:env) (h :rel heap) :
Lemma
(requires (Low? (env lo) /\
High? (env hi) /\
low_equiv env h))
(ensures (low_equiv env (R (p1_r lo hi (R?.l h)) (p1_r lo hi (R?.r h)))))
(decreases (dec_metric lo hi h)) =
let R hl hr = h in
let hl' = upd hl hi (sel hl hi - 1) in
let hr' = upd hr hi (sel hr hi - 1) in
match sel hl hi <= 0, sel hr hi <= 0 with
| true , true ->
begin
let hl'' = upd hl lo (sel hl lo + 1) in
let hr'' = upd hr lo (sel hr lo + 1) in
cut (low_equiv env (R hl'' hr''))
end
| true , false ->
begin
let hl2 = p1_r lo hi hl in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl hr');
cut (low_equiv env (R hl2 hr2));
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2 hr2''))
end
| false, true ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr in
ni_p1 lo hi env (R hl' hr);
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (low_equiv env (R hl2'' hr2))
end
| false, false ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl' hr');
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2'' hr2''))
end | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.int -> _: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.op_Multiply"
] | [] | false | false | false | true | false | let op_Star =
| op_Multiply | false |
|
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.p1 | val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi)) | val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi)) | let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1) | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 44,
"start_col": 1,
"start_line": 36
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True)) | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
lo: FStar.DM4F.Heap.IntStoreFixed.id ->
hi: FStar.DM4F.Heap.IntStoreFixed.id ->
gh: FStar.DM4F.Heap.IntStoreFixed.heap
-> FStar.DM4F.IntStoreFixed.IntStore Prims.unit | FStar.DM4F.IntStoreFixed.IntStore | [
""
] | [] | [
"FStar.DM4F.Heap.IntStoreFixed.id",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.DM4F.IntStoreFixed.write",
"Prims.unit",
"Prims.int",
"Prims.op_Addition",
"FStar.DM4F.IntStoreFixed.read",
"Prims.op_Subtraction",
"IfcRecursiveHeapReify.p1",
"FStar.DM4F.IntStoreFixed.get",
"Prims.bool",
"Prims.op_GreaterThan"
] | [
"recursion"
] | false | true | false | false | false | let rec p1 lo hi gh =
| if (read hi) > 0
then
(write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1));
write lo (read lo + 1) | false |
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.fac_r | val fac_r : a: FStar.DM4F.Heap.IntStoreFixed.id ->
n: FStar.DM4F.Heap.IntStoreFixed.id{a <> n} ->
h: FStar.DM4F.Heap.IntStoreFixed.heap
-> FStar.DM4F.Heap.IntStoreFixed.heap | let fac_r a n h = (snd (reify (fac a n h) h)) | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 45,
"end_line": 135,
"start_col": 0,
"start_line": 135
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi))
let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1)
let p1_r lo (hi:id{lo<>hi}) h = (* normalize_term *) (snd (reify (p1 lo hi h) h))
let nat_of (x:int) : nat = if x < 0 then 0 else x
//inlining this leads to a crash!
let dec_metric (lo:id) (hi:id{lo<>hi}) (h :rel heap) =
nat_of (sel (R?.l h) hi) +
nat_of (sel (R?.r h) hi)
#set-options "--z3rlimit 60"
let rec ni_p1 (lo:id) (hi:id{lo<>hi}) (env:env) (h :rel heap) :
Lemma
(requires (Low? (env lo) /\
High? (env hi) /\
low_equiv env h))
(ensures (low_equiv env (R (p1_r lo hi (R?.l h)) (p1_r lo hi (R?.r h)))))
(decreases (dec_metric lo hi h)) =
let R hl hr = h in
let hl' = upd hl hi (sel hl hi - 1) in
let hr' = upd hr hi (sel hr hi - 1) in
match sel hl hi <= 0, sel hr hi <= 0 with
| true , true ->
begin
let hl'' = upd hl lo (sel hl lo + 1) in
let hr'' = upd hr lo (sel hr lo + 1) in
cut (low_equiv env (R hl'' hr''))
end
| true , false ->
begin
let hl2 = p1_r lo hi hl in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl hr');
cut (low_equiv env (R hl2 hr2));
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2 hr2''))
end
| false, true ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr in
ni_p1 lo hi env (R hl' hr);
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (low_equiv env (R hl2'' hr2))
end
| false, false ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl' hr');
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2'' hr2''))
end
let op_Star = op_Multiply
let rec fac (a:id) (n:id{a <> n}) (gh:heap)
: IntStore unit
(requires (fun h -> h == gh))
(ensures (fun h1 _ h2 -> True))
(decreases (nat_of (sel gh n)))
= let vn = read n in
if vn <= 0 then
write a 1
else
begin
let va = read a in
let an = va * vn in
write a an;
let n_1 = vn - 1 in
write n n_1;
let h = X.get () in
fac a n h
end | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: FStar.DM4F.Heap.IntStoreFixed.id ->
n: FStar.DM4F.Heap.IntStoreFixed.id{a <> n} ->
h: FStar.DM4F.Heap.IntStoreFixed.heap
-> FStar.DM4F.Heap.IntStoreFixed.heap | Prims.Tot | [
"total"
] | [] | [
"FStar.DM4F.Heap.IntStoreFixed.id",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.Pervasives.Native.snd",
"Prims.unit",
"IfcRecursiveHeapReify.fac"
] | [] | false | false | false | false | false | let fac_r a n h =
| (snd (reify (fac a n h) h)) | false |
|
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.p1_r | val p1_r : lo: FStar.DM4F.Heap.IntStoreFixed.id ->
hi: FStar.DM4F.Heap.IntStoreFixed.id{lo <> hi} ->
h: FStar.DM4F.Heap.IntStoreFixed.heap
-> FStar.DM4F.Heap.IntStoreFixed.heap | let p1_r lo (hi:id{lo<>hi}) h = (* normalize_term *) (snd (reify (p1 lo hi h) h)) | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 81,
"end_line": 47,
"start_col": 0,
"start_line": 47
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi))
let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1) | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
lo: FStar.DM4F.Heap.IntStoreFixed.id ->
hi: FStar.DM4F.Heap.IntStoreFixed.id{lo <> hi} ->
h: FStar.DM4F.Heap.IntStoreFixed.heap
-> FStar.DM4F.Heap.IntStoreFixed.heap | Prims.Tot | [
"total"
] | [] | [
"FStar.DM4F.Heap.IntStoreFixed.id",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.Pervasives.Native.snd",
"Prims.unit",
"IfcRecursiveHeapReify.p1"
] | [] | false | false | false | false | false | let p1_r lo (hi: id{lo <> hi}) h =
| (snd (reify (p1 lo hi h) h)) | false |
|
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.readable_live_one | val readable_live_one (h: ME.vale_heap) (a: arg)
: Lemma (VSig.readable_one h a ==> live_arg (hs_of_mem (as_mem h)) a) | val readable_live_one (h: ME.vale_heap) (a: arg)
: Lemma (VSig.readable_one h a ==> live_arg (hs_of_mem (as_mem h)) a) | let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> () | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 147,
"start_col": 0,
"start_line": 137
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false | h: Vale.X64.Memory.vale_heap -> a: Vale.Interop.Base.arg
-> FStar.Pervasives.Lemma
(ensures
Vale.AsLowStar.ValeSig.readable_one h a ==>
Vale.Interop.Base.live_arg (Vale.Interop.Heap_s.hs_of_mem (Vale.X64.MemoryAdapters.as_mem h))
a) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.X64.Memory.vale_heap",
"Vale.Interop.Base.arg",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"Vale.AsLowStar.MemoryHelpers.readable_live",
"Vale.Interop.Base.TD_ImmBuffer",
"FStar.Pervasives.assert_norm",
"Prims.l_iff",
"Vale.X64.Memory.buffer_readable",
"Vale.X64.MemoryAdapters.as_vale_immbuffer",
"Vale.AsLowStar.ValeSig.readable_one",
"Prims.Mkdtuple2",
"Vale.Interop.Base.td",
"Prims.unit",
"Vale.AsLowStar.MemoryHelpers.readable_imm_live",
"Vale.Interop.Base.valid_base_type",
"Vale.Interop.Base.TD_Base",
"Prims.l_True",
"Prims.squash",
"Prims.l_imp",
"Vale.Interop.Base.live_arg",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.X64.MemoryAdapters.as_mem",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let readable_live_one (h: ME.vale_heap) (a: arg)
: Lemma (VSig.readable_one h a ==> live_arg (hs_of_mem (as_mem h)) a) =
| match a with
| (| TD_Buffer src bt _ , x |) -> Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig , x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _ , _ |) -> () | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.args_b8_lemma | val args_b8_lemma (args: list arg) (x: arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _ , x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _ , x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True)) | val args_b8_lemma (args: list arg) (x: arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _ , x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _ , x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True)) | let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 75,
"start_col": 0,
"start_line": 64
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 2,
"max_fuel": 1,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | args: Prims.list Vale.Interop.Base.arg -> x: Vale.Interop.Base.arg
-> FStar.Pervasives.Lemma
(ensures
FStar.List.Tot.Base.memP x args ==>
(match x with
| Prims.Mkdtuple2 #_ #_ (Vale.Interop.Base.TD_Buffer src _ _) x ->
FStar.List.Tot.Base.memP (Vale.Interop.Base.mut_to_b8 src x)
(Vale.Interop.Base.args_b8 args)
| Prims.Mkdtuple2 #_ #_ (Vale.Interop.Base.TD_ImmBuffer src _ _) x ->
FStar.List.Tot.Base.memP (Vale.Interop.Base.imm_to_b8 src x)
(Vale.Interop.Base.args_b8 args)
| _ -> Prims.l_True)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.list",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.Wrapper.args_b8_lemma",
"Prims.unit",
"Prims._assert",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Prims.l_True",
"Prims.squash",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"Vale.Interop.Types.b8",
"Vale.Interop.Base.mut_to_b8",
"Vale.Interop.Base.args_b8",
"Vale.Interop.Base.TD_ImmBuffer",
"Vale.Interop.Base.imm_to_b8",
"Prims.dtuple2",
"Vale.Interop.Base.td",
"Prims.logical",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec args_b8_lemma (args: list arg) (x: arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _ , x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _ , x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True)) =
| match args with
| [] -> ()
| a :: q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.readable_cons | val readable_cons (hd: arg) (tl: list arg) (s: ME.vale_heap)
: Lemma VSig.(readable (hd :: tl) s <==> (readable_one s hd /\ readable tl s)) | val readable_cons (hd: arg) (tl: list arg) (s: ME.vale_heap)
: Lemma VSig.(readable (hd :: tl) s <==> (readable_one s hd /\ readable tl s)) | let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 80,
"start_col": 0,
"start_line": 78
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | hd: Vale.Interop.Base.arg -> tl: Prims.list Vale.Interop.Base.arg -> s: Vale.X64.Memory.vale_heap
-> FStar.Pervasives.Lemma
(ensures
Vale.AsLowStar.ValeSig.readable (hd :: tl) s <==>
Vale.AsLowStar.ValeSig.readable_one s hd /\ Vale.AsLowStar.ValeSig.readable tl s) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Interop.Base.arg",
"Prims.list",
"Vale.X64.Memory.vale_heap",
"FStar.BigOps.big_and'_cons",
"Vale.AsLowStar.ValeSig.readable_one",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"Vale.AsLowStar.ValeSig.readable",
"Prims.Cons",
"Prims.l_and",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let readable_cons (hd: arg) (tl: list arg) (s: ME.vale_heap)
: Lemma VSig.(readable (hd :: tl) s <==> (readable_one s hd /\ readable tl s)) =
| BigOps.big_and'_cons VSig.(readable_one s) hd tl | false |
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.nat_of | val nat_of (x: int) : nat | val nat_of (x: int) : nat | let nat_of (x:int) : nat = if x < 0 then 0 else x | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 49,
"start_col": 0,
"start_line": 49
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi))
let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1)
let p1_r lo (hi:id{lo<>hi}) h = (* normalize_term *) (snd (reify (p1 lo hi h) h)) | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_LessThan",
"Prims.bool",
"Prims.nat"
] | [] | false | false | false | true | false | let nat_of (x: int) : nat =
| if x < 0 then 0 else x | false |
Hacl.P256.PrecompTable.fst | Hacl.P256.PrecompTable.precomp_basepoint_table_list_w5 | val precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 384} | val precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 384} | let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 384} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31) | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 89,
"end_line": 283,
"start_col": 0,
"start_line": 282
} | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module SPT = Hacl.Spec.PrecompBaseTable
module SPT256 = Hacl.Spec.PrecompBaseTable256
module SPTK = Hacl.Spec.P256.PrecompTable
module S = Spec.P256
module SL = Spec.P256.Lemmas
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let proj_point_to_list p =
SPTK.proj_point_to_list_lemma p;
SPTK.proj_point_to_list p
let lemma_refl x =
SPTK.proj_point_to_list_lemma x
//-----------------
inline_for_extraction noextract
let proj_g_pow2_64 : S.proj_point =
[@inline_let]
let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in
[@inline_let]
let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in
[@inline_let]
let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in
(rX, rY, rZ)
val lemma_proj_g_pow2_64_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64)
let lemma_proj_g_pow2_64_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64);
let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in
let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in
let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
inline_for_extraction noextract
let proj_g_pow2_128 : S.proj_point =
[@inline_let]
let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in
[@inline_let]
let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in
[@inline_let]
let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in
(rX, rY, rZ)
val lemma_proj_g_pow2_128_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
let lemma_proj_g_pow2_128_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64);
let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in
let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in
let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
inline_for_extraction noextract
let proj_g_pow2_192 : S.proj_point =
[@inline_let]
let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in
[@inline_let]
let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in
[@inline_let]
let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in
(rX, rY, rZ)
val lemma_proj_g_pow2_192_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
let lemma_proj_g_pow2_192_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64);
let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in
let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in
let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
// let proj_g_pow2_64 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64)
// let proj_g_pow2_128 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64)
// let proj_g_pow2_192 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64)
inline_for_extraction noextract
let proj_g_pow2_64_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
inline_for_extraction noextract
let proj_g_pow2_128_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
inline_for_extraction noextract
let proj_g_pow2_192_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64);
Seq.seq_of_list proj_g_pow2_64_list
let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128);
Seq.seq_of_list proj_g_pow2_128_list
let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192);
Seq.seq_of_list proj_g_pow2_192_list
val proj_g_pow2_64_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
let proj_g_pow2_64_lemma () =
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_128_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
let proj_g_pow2_128_lemma () =
lemma_proj_g_pow2_128_eval ();
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_192_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
let proj_g_pow2_192_lemma () =
lemma_proj_g_pow2_192_eval ();
lemma_proj_g_pow2_128_eval ();
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point
let proj_g_pow2_64_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64);
proj_g_pow2_64_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_64
let proj_g_pow2_128_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128);
proj_g_pow2_128_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_128
let proj_g_pow2_192_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192);
proj_g_pow2_192_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_192
let mk_proj_g_pow2_64 () =
createL proj_g_pow2_64_list
let mk_proj_g_pow2_128 () =
createL proj_g_pow2_128_list
let mk_proj_g_pow2_192 () =
createL proj_g_pow2_192_list
//----------------
/// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G]
inline_for_extraction noextract
let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15)
let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15);
Seq.seq_of_list precomp_basepoint_table_list_w4
let precomp_basepoint_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4
let precomp_basepoint_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} =
createL_global precomp_basepoint_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)]
inline_for_extraction noextract
let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15)
let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15);
Seq.seq_of_list precomp_g_pow2_64_table_list_w4
let precomp_g_pow2_64_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table
proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_64_lemma ()
let precomp_g_pow2_64_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_64_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)]
inline_for_extraction noextract
let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15)
let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15);
Seq.seq_of_list precomp_g_pow2_128_table_list_w4
let precomp_g_pow2_128_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table
proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_128_lemma ()
let precomp_g_pow2_128_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_128_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)]
inline_for_extraction noextract
let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15)
let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15);
Seq.seq_of_list precomp_g_pow2_192_table_list_w4
let precomp_g_pow2_192_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table
proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_192_lemma ()
let precomp_g_pow2_192_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_192_table_list_w4
/// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G] | {
"checked_file": "/",
"dependencies": [
"Spec.P256.Lemmas.fsti.checked",
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable256.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.PrecompTable.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.P256.PrecompTable.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length x = 384} | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.normalize_term",
"Prims.list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Hacl.Spec.PrecompBaseTable.precomp_base_table_list",
"Spec.P256.PointOps.proj_point",
"FStar.UInt32.uint_to_t",
"Hacl.P256.PrecompTable.mk_p256_precomp_base_table",
"Spec.P256.PointOps.base_point"
] | [] | false | false | false | false | false | let precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 384} =
| normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31) | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.eval_code_ts | val eval_code_ts (c: BS.code) (s0: BS.machine_state) (f0: nat) (s1: BS.machine_state) : Type0 | val eval_code_ts (c: BS.code) (s0: BS.machine_state) (f0: nat) (s1: BS.machine_state) : Type0 | let eval_code_ts (c:BS.code)
(s0:BS.machine_state)
(f0:nat)
(s1:BS.machine_state) : Type0 =
VL.state_eq_opt true (BS.machine_eval_code c f0 s0) (Some s1) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 503,
"start_col": 0,
"start_line": 499
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd)
let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal ()
let frame_update_valid_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let rec stack_of_args_stack_args'_aux
(max_arity:nat)
(n_init:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
(v:MS.nat64)
: Lemma
(requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack)))
= match args with
| [] -> ()
| hd::tl ->
stack_of_args_stack_args'_aux max_arity n_init (n-1) tl rsp stack v;
if n <= max_arity then ()
else (
let fixed = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
calc ( <= ) {
((n - max_arity) - 1) * 8;
( <= ) { FStar.Math.Lemmas.lemma_mult_le_right 8 ((n - max_arity) - 1) (n_init - max_arity) }
(n_init - max_arity) * 8;
};
frame_update_get_heap fixed v stack ptr;
frame_update_valid_heap fixed v stack ptr
)
#push-options "--max_fuel 1 --max_ifuel 0 --z3rlimit 150 --z3refresh"
let stack_of_args_stack_args'
(max_arity:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(init_rsp:MS.nat64{init_rsp >= 4096}) : Lemma
(let mem = Map.const_on Set.empty 0 in
stack_args' max_arity n args init_rsp (IX64.stack_of_args max_arity n init_rsp args mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
let rec aux (args:IX64.arg_list) (accu:Map.t int Vale.Def.Words_s.nat8) : Lemma (ensures (
stack_args' max_arity (List.length args) args init_rsp
(IX64.stack_of_args max_arity (List.length args) init_rsp args accu)))
(decreases (List.length args))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
match args with
| [] -> ()
| hd::tl ->
aux tl accu;
let n = List.length args in
if n <= max_arity then ()
else (
let ptr = ((n - max_arity) - 1) * 8 // Arguments on the stack are pushed from right to left
+ (if IA.win then 32 else 0) // The shadow space on Windows comes next
+ 8 // The return address is then pushed on the stack
+ init_rsp // And we then have all the extra slots required for the Vale procedure
in
let accu' = IX64.stack_of_args max_arity (n-1) init_rsp tl accu in
let v = IX64.arg_as_nat64 hd in // We will store the arg hd
let h_final = BS.update_heap64 ptr v accu' in
stack_of_args_stack_args'_aux max_arity (n-1) (n-1) tl init_rsp accu' v;
Vale.Arch.MachineHeap.correct_update_get64 ptr v accu';
BS.update_heap64_reveal ()
)
in aux args (Map.const_on Set.empty 0)
#pop-options
#reset-options "--z3rlimit 40"
let core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let init_rsp = IA.init_regs MS.rRsp in
let stack = Map.const_on Set.empty 0 in
let stack_map = IX64.stack_of_args max_arity (List.Tot.length args) init_rsp args stack in
let stack_f = BS.Machine_stack init_rsp stack_map in
let rec aux (accu:IX64.arg_list{List.length accu <= List.length args}) : Lemma
(requires
stack_args' max_arity (List.length accu) accu init_rsp stack_map)
(ensures LSig.stack_args max_arity (List.length accu) accu va_s)
(decreases (List.length accu))
=
match accu with
| [] -> ()
| hd::tl ->
aux tl;
let i = List.length accu in
if i <= max_arity then ()
else (
let ptr =
((i - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ init_rsp
in
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal stack_f;
SI.lemma_valid_taint_stack64_reveal ptr MS.Public va_s.VS.vs_stackTaint;
let aux2 () : Lemma (IX64.arg_as_nat64 hd == LSig.arg_as_nat64 hd va_s) =
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args h0
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args h0
| _ -> ()
in aux2()
)
in
stack_of_args_stack_args' max_arity (List.length args) args init_rsp;
aux args
let core_create_lemma
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s /\
LSig.mem_correspondence args h0 va_s /\
VSig.disjoint_or_eq args /\
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap) /\
LSig.vale_pre_hyp #max_arity #arg_reg args va_s /\
ST.equal_domains h0 (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap))
))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let t_state = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let t_stack = t_state.BS.ms_stack in
core_create_lemma_mem_correspondance #max_arity #arg_reg args h0;
core_create_lemma_disjointness args;
core_create_lemma_readable #max_arity #arg_reg args h0;
core_create_lemma_register_args #max_arity #arg_reg args h0;
core_create_lemma_stack_args #max_arity #arg_reg args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal t_stack;
Vale.AsLowStar.MemoryHelpers.core_create_lemma_taint_hyp #max_arity #arg_reg args h0;
core_create_lemma_state #max_arity #arg_reg args h0 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Vale.X64.Machine_Semantics_s.code ->
s0: Vale.X64.Machine_Semantics_s.machine_state ->
f0: Prims.nat ->
s1: Vale.X64.Machine_Semantics_s.machine_state
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.code",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.nat",
"Vale.X64.Lemmas.state_eq_opt",
"Vale.X64.Machine_Semantics_s.machine_eval_code",
"FStar.Pervasives.Native.Some"
] | [] | false | false | false | true | true | let eval_code_ts (c: BS.code) (s0: BS.machine_state) (f0: nat) (s1: BS.machine_state) : Type0 =
| VL.state_eq_opt true (BS.machine_eval_code c f0 s0) (Some s1) | false |
Hacl.Spec.Chacha20.Lemmas.fst | Hacl.Spec.Chacha20.Lemmas.transpose8_lemma | val transpose8_lemma: k:state 8 -> i:nat{i < 16 * 8} ->
Lemma ((vec_v (transpose8 k).[i / 8]).[i % 8] == ((transpose_state k).[i / 16]).[i % 16]) | val transpose8_lemma: k:state 8 -> i:nat{i < 16 * 8} ->
Lemma ((vec_v (transpose8 k).[i / 8]).[i % 8] == ((transpose_state k).[i / 16]).[i % 16]) | let transpose8_lemma st i =
let r0 = transpose8x8_lseq (sub st 0 8) in
transpose8x8_lemma (sub st 0 8);
let r1 = transpose8x8_lseq (sub st 8 8) in
transpose8x8_lemma (sub st 8 8) | {
"file_name": "code/chacha20/Hacl.Spec.Chacha20.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 34,
"start_col": 0,
"start_line": 30
} | module Hacl.Spec.Chacha20.Lemmas
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.IntVector
open Lib.IntVector.Transpose
open Hacl.Spec.Chacha20.Vec
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1"
/// (vec_v (transpose #w k).[i / w]).[i % w] == ((transpose_state k).[i / 16]).[i % 16]
val transpose4_lemma: k:state 4 -> i:nat{i < 16 * 4} ->
Lemma ((vec_v (transpose4 k).[i / 4]).[i % 4] == ((transpose_state k).[i / 16]).[i % 16])
let transpose4_lemma st i =
let r0 = transpose4x4_lseq (sub st 0 4) in
transpose4x4_lemma (sub st 0 4);
let r1 = transpose4x4_lseq (sub st 4 4) in
transpose4x4_lemma (sub st 4 4);
let r2 = transpose4x4_lseq (sub st 8 4) in
transpose4x4_lemma (sub st 8 4);
let r3 = transpose4x4_lseq (sub st 12 4) in
transpose4x4_lemma (sub st 12 4)
val transpose8_lemma: k:state 8 -> i:nat{i < 16 * 8} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.Transpose.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Chacha20.Vec.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Chacha20.Lemmas.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector.Transpose",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Spec.Chacha20.Vec.state 8 -> i: Prims.nat{i < 16 * 8}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.vec_v (Hacl.Spec.Chacha20.Vec.transpose8 k).[ i / 8 ]).[ i % 8 ] ==
(Hacl.Spec.Chacha20.Vec.transpose_state k).[ i / 16 ].[ i % 16 ]) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Chacha20.Vec.state",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Lib.IntVector.Transpose.transpose8x8_lemma",
"Lib.IntTypes.U32",
"Lib.Sequence.sub",
"Hacl.Spec.Chacha20.Vec.uint32xN",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.IntVector.Transpose.transpose8x8_lseq",
"Prims.unit"
] | [] | true | false | true | false | false | let transpose8_lemma st i =
| let r0 = transpose8x8_lseq (sub st 0 8) in
transpose8x8_lemma (sub st 0 8);
let r1 = transpose8x8_lseq (sub st 8 8) in
transpose8x8_lemma (sub st 8 8) | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.readable_all_live | val readable_all_live (h: ME.vale_heap) (args: list arg)
: Lemma (VSig.readable args h ==> all_live (hs_of_mem (as_mem h)) args) | val readable_all_live (h: ME.vale_heap) (args: list arg)
: Lemma (VSig.readable args h ==> all_live (hs_of_mem (as_mem h)) args) | let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 158,
"start_col": 0,
"start_line": 149
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> () | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false | h: Vale.X64.Memory.vale_heap -> args: Prims.list Vale.Interop.Base.arg
-> FStar.Pervasives.Lemma
(ensures
Vale.AsLowStar.ValeSig.readable args h ==>
Vale.Interop.Base.all_live (Vale.Interop.Heap_s.hs_of_mem (Vale.X64.MemoryAdapters.as_mem h))
args) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.X64.Memory.vale_heap",
"Prims.list",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.Wrapper.readable_all_live",
"Prims.unit",
"Vale.AsLowStar.Wrapper.readable_live_one",
"Vale.Interop.Base.all_live_cons",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.X64.MemoryAdapters.as_mem",
"Vale.AsLowStar.Wrapper.readable_cons",
"Prims.l_True",
"Prims.squash",
"Prims.l_imp",
"Vale.AsLowStar.ValeSig.readable",
"Vale.Interop.Base.all_live",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec readable_all_live (h: ME.vale_heap) (args: list arg)
: Lemma (VSig.readable args h ==> all_live (hs_of_mem (as_mem h)) args) =
| match args with
| [] -> ()
| hd :: tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl | false |
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.fac | val fac (a: id) (n: id{a <> n}) (gh: heap)
: IntStore unit
(requires (fun h -> h == gh))
(ensures (fun h1 _ h2 -> True))
(decreases (nat_of (sel gh n))) | val fac (a: id) (n: id{a <> n}) (gh: heap)
: IntStore unit
(requires (fun h -> h == gh))
(ensures (fun h1 _ h2 -> True))
(decreases (nat_of (sel gh n))) | let rec fac (a:id) (n:id{a <> n}) (gh:heap)
: IntStore unit
(requires (fun h -> h == gh))
(ensures (fun h1 _ h2 -> True))
(decreases (nat_of (sel gh n)))
= let vn = read n in
if vn <= 0 then
write a 1
else
begin
let va = read a in
let an = va * vn in
write a an;
let n_1 = vn - 1 in
write n n_1;
let h = X.get () in
fac a n h
end | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 133,
"start_col": 0,
"start_line": 116
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi))
let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1)
let p1_r lo (hi:id{lo<>hi}) h = (* normalize_term *) (snd (reify (p1 lo hi h) h))
let nat_of (x:int) : nat = if x < 0 then 0 else x
//inlining this leads to a crash!
let dec_metric (lo:id) (hi:id{lo<>hi}) (h :rel heap) =
nat_of (sel (R?.l h) hi) +
nat_of (sel (R?.r h) hi)
#set-options "--z3rlimit 60"
let rec ni_p1 (lo:id) (hi:id{lo<>hi}) (env:env) (h :rel heap) :
Lemma
(requires (Low? (env lo) /\
High? (env hi) /\
low_equiv env h))
(ensures (low_equiv env (R (p1_r lo hi (R?.l h)) (p1_r lo hi (R?.r h)))))
(decreases (dec_metric lo hi h)) =
let R hl hr = h in
let hl' = upd hl hi (sel hl hi - 1) in
let hr' = upd hr hi (sel hr hi - 1) in
match sel hl hi <= 0, sel hr hi <= 0 with
| true , true ->
begin
let hl'' = upd hl lo (sel hl lo + 1) in
let hr'' = upd hr lo (sel hr lo + 1) in
cut (low_equiv env (R hl'' hr''))
end
| true , false ->
begin
let hl2 = p1_r lo hi hl in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl hr');
cut (low_equiv env (R hl2 hr2));
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2 hr2''))
end
| false, true ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr in
ni_p1 lo hi env (R hl' hr);
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (low_equiv env (R hl2'' hr2))
end
| false, false ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl' hr');
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2'' hr2''))
end
let op_Star = op_Multiply | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: FStar.DM4F.Heap.IntStoreFixed.id ->
n: FStar.DM4F.Heap.IntStoreFixed.id{a <> n} ->
gh: FStar.DM4F.Heap.IntStoreFixed.heap
-> FStar.DM4F.IntStoreFixed.IntStore Prims.unit | FStar.DM4F.IntStoreFixed.IntStore | [
""
] | [] | [
"FStar.DM4F.Heap.IntStoreFixed.id",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"Prims.op_LessThanOrEqual",
"FStar.DM4F.IntStoreFixed.write",
"Prims.unit",
"Prims.bool",
"IfcRecursiveHeapReify.fac",
"FStar.DM4F.IntStoreFixed.get",
"Prims.int",
"Prims.op_Subtraction",
"IfcRecursiveHeapReify.op_Star",
"FStar.DM4F.IntStoreFixed.read",
"Prims.eq2",
"Prims.l_True"
] | [
"recursion"
] | false | true | false | false | false | let rec fac (a: id) (n: id{a <> n}) (gh: heap)
: IntStore unit
(requires (fun h -> h == gh))
(ensures (fun h1 _ h2 -> True))
(decreases (nat_of (sel gh n))) =
| let vn = read n in
if vn <= 0
then write a 1
else
let va = read a in
let an = va * vn in
write a an;
let n_1 = vn - 1 in
write n n_1;
let h = X.get () in
fac a n h | false |
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.fac_mon | val fac_mon (a: id) (n: id{a <> n}) (h: rel heap)
: Lemma
(requires
(sel (R?.l h) n <= sel (R?.r h) n /\ sel (R?.l h) a <= sel (R?.r h) a /\ sel (R?.l h) a >= 0 /\
sel (R?.r h) a >= 0))
(ensures (sel (fac_r a n (R?.l h)) a <= sel (fac_r a n (R?.r h)) a))
(decreases (dec_metric a n h)) | val fac_mon (a: id) (n: id{a <> n}) (h: rel heap)
: Lemma
(requires
(sel (R?.l h) n <= sel (R?.r h) n /\ sel (R?.l h) a <= sel (R?.r h) a /\ sel (R?.l h) a >= 0 /\
sel (R?.r h) a >= 0))
(ensures (sel (fac_r a n (R?.l h)) a <= sel (fac_r a n (R?.r h)) a))
(decreases (dec_metric a n h)) | let rec fac_mon (a:id) (n:id{a<>n}) (h:rel heap) :
Lemma
(requires (sel (R?.l h) n <= sel (R?.r h) n /\
sel (R?.l h) a <= sel (R?.r h) a /\
sel (R?.l h) a >= 0 /\
sel (R?.r h) a >= 0))
(ensures (sel (fac_r a n (R?.l h)) a <= sel (fac_r a n (R?.r h)) a))
(decreases (dec_metric a n h)) =
let R hl hr = h in
let hl'' = upd hl a (sel hl a * sel hl n) in
let hl' = upd hl'' n (sel hl'' n - 1) in
let hr'' = upd hr a (sel hr a * sel hr n) in
let hr' = upd hr'' n (sel hr'' n - 1) in
match sel hl n <= 0 , sel hr n <= 0 with
| true , true -> ()
| true , false -> fac_mon a n (R hl hr')
| false, false -> fac_mon a n (R hl' hr') | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 43,
"end_line": 155,
"start_col": 0,
"start_line": 139
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi))
let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1)
let p1_r lo (hi:id{lo<>hi}) h = (* normalize_term *) (snd (reify (p1 lo hi h) h))
let nat_of (x:int) : nat = if x < 0 then 0 else x
//inlining this leads to a crash!
let dec_metric (lo:id) (hi:id{lo<>hi}) (h :rel heap) =
nat_of (sel (R?.l h) hi) +
nat_of (sel (R?.r h) hi)
#set-options "--z3rlimit 60"
let rec ni_p1 (lo:id) (hi:id{lo<>hi}) (env:env) (h :rel heap) :
Lemma
(requires (Low? (env lo) /\
High? (env hi) /\
low_equiv env h))
(ensures (low_equiv env (R (p1_r lo hi (R?.l h)) (p1_r lo hi (R?.r h)))))
(decreases (dec_metric lo hi h)) =
let R hl hr = h in
let hl' = upd hl hi (sel hl hi - 1) in
let hr' = upd hr hi (sel hr hi - 1) in
match sel hl hi <= 0, sel hr hi <= 0 with
| true , true ->
begin
let hl'' = upd hl lo (sel hl lo + 1) in
let hr'' = upd hr lo (sel hr lo + 1) in
cut (low_equiv env (R hl'' hr''))
end
| true , false ->
begin
let hl2 = p1_r lo hi hl in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl hr');
cut (low_equiv env (R hl2 hr2));
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2 hr2''))
end
| false, true ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr in
ni_p1 lo hi env (R hl' hr);
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (low_equiv env (R hl2'' hr2))
end
| false, false ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl' hr');
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2'' hr2''))
end
let op_Star = op_Multiply
let rec fac (a:id) (n:id{a <> n}) (gh:heap)
: IntStore unit
(requires (fun h -> h == gh))
(ensures (fun h1 _ h2 -> True))
(decreases (nat_of (sel gh n)))
= let vn = read n in
if vn <= 0 then
write a 1
else
begin
let va = read a in
let an = va * vn in
write a an;
let n_1 = vn - 1 in
write n n_1;
let h = X.get () in
fac a n h
end
let fac_r a n h = (snd (reify (fac a n h) h))
#set-options "--z3rlimit 40" | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: FStar.DM4F.Heap.IntStoreFixed.id ->
n: FStar.DM4F.Heap.IntStoreFixed.id{a <> n} ->
h: Rel.rel FStar.DM4F.Heap.IntStoreFixed.heap
-> FStar.Pervasives.Lemma
(requires
FStar.DM4F.Heap.IntStoreFixed.sel (R?.l h) n <= FStar.DM4F.Heap.IntStoreFixed.sel (R?.r h) n /\
FStar.DM4F.Heap.IntStoreFixed.sel (R?.l h) a <= FStar.DM4F.Heap.IntStoreFixed.sel (R?.r h) a /\
FStar.DM4F.Heap.IntStoreFixed.sel (R?.l h) a >= 0 /\
FStar.DM4F.Heap.IntStoreFixed.sel (R?.r h) a >= 0)
(ensures
FStar.DM4F.Heap.IntStoreFixed.sel (IfcRecursiveHeapReify.fac_r a n (R?.l h)) a <=
FStar.DM4F.Heap.IntStoreFixed.sel (IfcRecursiveHeapReify.fac_r a n (R?.r h)) a)
(decreases IfcRecursiveHeapReify.dec_metric a n h) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"FStar.DM4F.Heap.IntStoreFixed.id",
"Prims.b2t",
"Prims.op_disEquality",
"Rel.rel",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_LessThanOrEqual",
"FStar.DM4F.Heap.IntStoreFixed.sel",
"IfcRecursiveHeapReify.fac_mon",
"Rel.R",
"Prims.unit",
"FStar.DM4F.Heap.IntStoreFixed.upd",
"Prims.op_Subtraction",
"IfcRecursiveHeapReify.op_Star",
"Prims.l_and",
"Rel.__proj__R__item__l",
"Rel.__proj__R__item__r",
"Prims.op_GreaterThanOrEqual",
"Prims.squash",
"IfcRecursiveHeapReify.fac_r",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec fac_mon (a: id) (n: id{a <> n}) (h: rel heap)
: Lemma
(requires
(sel (R?.l h) n <= sel (R?.r h) n /\ sel (R?.l h) a <= sel (R?.r h) a /\ sel (R?.l h) a >= 0 /\
sel (R?.r h) a >= 0))
(ensures (sel (fac_r a n (R?.l h)) a <= sel (fac_r a n (R?.r h)) a))
(decreases (dec_metric a n h)) =
| let R hl hr = h in
let hl'' = upd hl a (sel hl a * sel hl n) in
let hl' = upd hl'' n (sel hl'' n - 1) in
let hr'' = upd hr a (sel hr a * sel hr n) in
let hr' = upd hr'' n (sel hr'' n - 1) in
match sel hl n <= 0, sel hr n <= 0 with
| true, true -> ()
| true, false -> fac_mon a n (R hl hr')
| false, false -> fac_mon a n (R hl' hr') | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.core_create_lemma_state | val core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s)) | val core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s)) | let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 312,
"start_col": 0,
"start_line": 285
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
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
FStar.Pervasives.Native.fst (Vale.Interop.X64.create_initial_trusted_state max_arity
arg_reg
args
h0) ==
Vale.X64.StateLemmas.state_to_S va_s)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"Vale.AsLowStar.MemoryHelpers.mk_stack_reveal",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack",
"Prims.unit",
"Prims._assert",
"FStar.FunctionalExtensionality.feq",
"Vale.X64.Machine_s.reg",
"Vale.X64.Machine_s.t_reg",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs",
"FStar.Classical.forall_intro",
"Prims.eq2",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.X64.Machine_s.flag",
"Vale.X64.Machine_Semantics_s.flag_val_t",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags",
"FStar.Pervasives.Native.option",
"Prims.bool",
"Vale.Arch.HeapTypes_s.memTaint_t",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint",
"Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.StateLemmas.state_to_S",
"FStar.Pervasives.Native.fst",
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.X64.create_initial_trusted_state",
"Vale.X64.Decls.vale_state_with_inv",
"Vale.AsLowStar.LowStarSig.create_initial_vale_state"
] | [] | false | false | true | false | false | let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s)) =
| let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
let aux_flag (f: MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f) = () in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
let aux_reg (r: MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r) = () in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.core_create_lemma_readable | val core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap))) | val core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap))) | let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0 | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 135,
"start_col": 0,
"start_line": 92
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20" | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
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.ValeSig.readable args
(Vale.X64.Memory.get_vale_heap (Mkvale_state?.vs_heap va_s)))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"Prims.list",
"Vale.Interop.Base.arg",
"Vale.Interop.Base.mem_roots",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Vale.AsLowStar.ValeSig.readable",
"Vale.X64.MemoryAdapters.create_initial_vale_heap",
"Vale.Interop.Base.mk_mem",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Classical.forall_intro",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"Vale.Interop.Types.b8",
"Vale.Interop.Base.mut_to_b8",
"Vale.Interop.Base.args_b8",
"Vale.Interop.Base.TD_ImmBuffer",
"Vale.Interop.Base.imm_to_b8",
"Prims.dtuple2",
"Vale.Interop.Base.td",
"Prims.logical",
"FStar.Classical.move_requires",
"Vale.AsLowStar.Wrapper.args_b8_lemma",
"Vale.Interop.Heap_s.interop_heap",
"Vale.X64.Memory.vale_heap",
"Prims.l_Forall",
"Vale.AsLowStar.Wrapper.arg_is_registered_root",
"Vale.AsLowStar.Wrapper.readable_cons",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.l_iff",
"Vale.AsLowStar.ValeSig.readable_one",
"Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal",
"Vale.AsLowStar.MemoryHelpers.reveal_readable",
"FStar.Pervasives.assert_norm",
"Vale.X64.Memory.buffer_readable",
"Vale.X64.MemoryAdapters.as_vale_immbuffer",
"Prims.Mkdtuple2",
"Vale.AsLowStar.MemoryHelpers.reveal_imm_readable",
"Vale.Interop.Base.valid_base_type",
"Vale.Interop.Base.TD_Base",
"Vale.X64.Memory.get_vale_heap",
"Vale.X64.State.__proj__Mkvale_state__item__vs_heap",
"Vale.X64.Decls.vale_state_with_inv",
"Vale.AsLowStar.LowStarSig.create_initial_vale_state"
] | [] | false | false | true | false | false | let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap))) =
| let readable_registered_one (a: arg) (h: ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a) =
match a with
| (| TD_Buffer src bt _ , x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig , x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _ , _ |) -> ()
in
let rec readable_registered_all
(args: list arg)
(h: ME.vale_heap{forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h) =
match args with
| [] -> ()
| hd :: tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem (args: list arg) (h: mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem)) =
let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0 | false |
IfcRecursiveHeapReify.fst | IfcRecursiveHeapReify.ni_p1 | val ni_p1 (lo: id) (hi: id{lo <> hi}) (env: env) (h: rel heap)
: Lemma (requires (Low? (env lo) /\ High? (env hi) /\ low_equiv env h))
(ensures (low_equiv env (R (p1_r lo hi (R?.l h)) (p1_r lo hi (R?.r h)))))
(decreases (dec_metric lo hi h)) | val ni_p1 (lo: id) (hi: id{lo <> hi}) (env: env) (h: rel heap)
: Lemma (requires (Low? (env lo) /\ High? (env hi) /\ low_equiv env h))
(ensures (low_equiv env (R (p1_r lo hi (R?.l h)) (p1_r lo hi (R?.r h)))))
(decreases (dec_metric lo hi h)) | let rec ni_p1 (lo:id) (hi:id{lo<>hi}) (env:env) (h :rel heap) :
Lemma
(requires (Low? (env lo) /\
High? (env hi) /\
low_equiv env h))
(ensures (low_equiv env (R (p1_r lo hi (R?.l h)) (p1_r lo hi (R?.r h)))))
(decreases (dec_metric lo hi h)) =
let R hl hr = h in
let hl' = upd hl hi (sel hl hi - 1) in
let hr' = upd hr hi (sel hr hi - 1) in
match sel hl hi <= 0, sel hr hi <= 0 with
| true , true ->
begin
let hl'' = upd hl lo (sel hl lo + 1) in
let hr'' = upd hr lo (sel hr lo + 1) in
cut (low_equiv env (R hl'' hr''))
end
| true , false ->
begin
let hl2 = p1_r lo hi hl in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl hr');
cut (low_equiv env (R hl2 hr2));
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2 hr2''))
end
| false, true ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr in
ni_p1 lo hi env (R hl' hr);
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (low_equiv env (R hl2'' hr2))
end
| false, false ->
begin
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl' hr');
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2'' hr2''))
end | {
"file_name": "examples/rel/IfcRecursiveHeapReify.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 111,
"start_col": 0,
"start_line": 58
} | (*
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 IfcRecursiveHeapReify
open FStar.DM4F.Heap.IntStoreFixed
open FStar.DM4F.IntStoreFixed
open Rel
module X = FStar.DM4F.IntStoreFixed
type label =
| Low
| High
type env = id -> Tot label
type low_equiv (env:env) (h : rel heap) =
forall (x:id). {:pattern (Low? (env x))} (Low? (env x) ==> sel (R?.l h) x = sel (R?.r h) x)
val p1 (lo hi :id ): gh:heap ->
IntStore unit
(requires (fun h -> h == gh /\ lo <> hi))
(ensures (fun h1 _ h2 -> True))
(decreases (sel gh hi))
let rec p1 lo hi gh =
if (read hi) > 0 then
begin
write hi (read hi - 1);
let h = X.get () in
p1 lo hi h;
write lo (read lo - 1)
end;
write lo (read lo + 1)
let p1_r lo (hi:id{lo<>hi}) h = (* normalize_term *) (snd (reify (p1 lo hi h) h))
let nat_of (x:int) : nat = if x < 0 then 0 else x
//inlining this leads to a crash!
let dec_metric (lo:id) (hi:id{lo<>hi}) (h :rel heap) =
nat_of (sel (R?.l h) hi) +
nat_of (sel (R?.r h) hi)
#set-options "--z3rlimit 60" | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixed.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "IfcRecursiveHeapReify.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": "X"
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
lo: FStar.DM4F.Heap.IntStoreFixed.id ->
hi: FStar.DM4F.Heap.IntStoreFixed.id{lo <> hi} ->
env: IfcRecursiveHeapReify.env ->
h: Rel.rel FStar.DM4F.Heap.IntStoreFixed.heap
-> FStar.Pervasives.Lemma
(requires Low? (env lo) /\ High? (env hi) /\ IfcRecursiveHeapReify.low_equiv env h)
(ensures
IfcRecursiveHeapReify.low_equiv env
(Rel.R (IfcRecursiveHeapReify.p1_r lo hi (R?.l h))
(IfcRecursiveHeapReify.p1_r lo hi (R?.r h))))
(decreases IfcRecursiveHeapReify.dec_metric lo hi h) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"FStar.DM4F.Heap.IntStoreFixed.id",
"Prims.b2t",
"Prims.op_disEquality",
"IfcRecursiveHeapReify.env",
"Rel.rel",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_LessThanOrEqual",
"FStar.DM4F.Heap.IntStoreFixed.sel",
"Prims.cut",
"IfcRecursiveHeapReify.low_equiv",
"Rel.R",
"FStar.DM4F.Heap.IntStoreFixed.upd",
"Prims.op_Addition",
"Prims.unit",
"Prims.eq2",
"IfcRecursiveHeapReify.p1_r",
"Prims.op_Subtraction",
"IfcRecursiveHeapReify.ni_p1",
"Prims.l_and",
"IfcRecursiveHeapReify.uu___is_Low",
"IfcRecursiveHeapReify.uu___is_High",
"Prims.squash",
"Rel.__proj__R__item__l",
"Rel.__proj__R__item__r",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec ni_p1 (lo: id) (hi: id{lo <> hi}) (env: env) (h: rel heap)
: Lemma (requires (Low? (env lo) /\ High? (env hi) /\ low_equiv env h))
(ensures (low_equiv env (R (p1_r lo hi (R?.l h)) (p1_r lo hi (R?.r h)))))
(decreases (dec_metric lo hi h)) =
| let R hl hr = h in
let hl' = upd hl hi (sel hl hi - 1) in
let hr' = upd hr hi (sel hr hi - 1) in
match sel hl hi <= 0, sel hr hi <= 0 with
| true, true ->
let hl'' = upd hl lo (sel hl lo + 1) in
let hr'' = upd hr lo (sel hr lo + 1) in
cut (low_equiv env (R hl'' hr''))
| true, false ->
let hl2 = p1_r lo hi hl in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl hr');
cut (low_equiv env (R hl2 hr2));
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2 hr2''))
| false, true ->
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr in
ni_p1 lo hi env (R hl' hr);
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (low_equiv env (R hl2'' hr2))
| false, false ->
let hl2 = p1_r lo hi hl' in
let hr2 = p1_r lo hi hr' in
ni_p1 lo hi env (R hl' hr');
cut (low_equiv env (R hl2 hr2));
let hl2' = upd hl2 lo (sel hl2 lo - 1) in
let hr2' = upd hr2 lo (sel hr2 lo - 1) in
let hl2'' = upd hl2' lo (sel hl2' lo + 1) in
let hr2'' = upd hr2' lo (sel hr2' lo + 1) in
cut (hl2'' == p1_r lo hi hl);
cut (hr2'' == p1_r lo hi hr);
cut (low_equiv env (R hl2'' hr2'')) | false |
Vale.Stdcalls.X64.GCM_IV.fst | Vale.Stdcalls.X64.GCM_IV.compute_iv_lemma' | val compute_iv_lemma'
(iv: Ghost.erased supported_iv_LE)
(code: V.va_code)
(_win: bool)
(iv_b: b128)
(num_bytes len: uint64)
(j0_b iv_extra_b hkeys_b: b128)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer iv_b) /\
ME.buffer_writeable (as_vale_buffer hkeys_b) /\
ME.buffer_writeable (as_vale_buffer iv_extra_b) /\
ME.buffer_writeable (as_vale_buffer j0_b))) | val compute_iv_lemma'
(iv: Ghost.erased supported_iv_LE)
(code: V.va_code)
(_win: bool)
(iv_b: b128)
(num_bytes len: uint64)
(j0_b iv_extra_b hkeys_b: b128)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer iv_b) /\
ME.buffer_writeable (as_vale_buffer hkeys_b) /\
ME.buffer_writeable (as_vale_buffer iv_extra_b) /\
ME.buffer_writeable (as_vale_buffer j0_b))) | let compute_iv_lemma'
(iv:Ghost.erased supported_iv_LE)
(code:V.va_code)
(_win:bool)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer iv_b) /\
ME.buffer_writeable (as_vale_buffer hkeys_b) /\
ME.buffer_writeable (as_vale_buffer iv_extra_b) /\
ME.buffer_writeable (as_vale_buffer j0_b))
) = let va_s1, f = GC.va_lemma_Compute_iv_stdcall code va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_extra_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 j0_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b;
va_s1, f | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 118,
"start_col": 0,
"start_line": 89
} | module Vale.Stdcalls.X64.GCM_IV
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module GC = Vale.AES.X64.GCMencryptOpt
open Vale.AES.GCM_s
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in
assert_norm (List.length y = 6);
y
[@__reduce__] noextract
let compute_iv_pre : (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state) ->
GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
[@__reduce__] noextract
let compute_iv_post : (Ghost.erased supported_iv_LE) -> VSig.vale_post dom =
fun (iv:Ghost.erased supported_iv_LE)
(c:V.va_code)
(iv_b:b128)
(num_bytes:uint64)
(len:uint64)
(j0_b:b128)
(iv_extra_b:b128)
(hkeys_b:b128)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv)
(as_vale_buffer iv_b) (UInt64.v num_bytes)
(UInt64.v len) (as_vale_buffer j0_b)
(as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b)
va_s1 f
#set-options "--z3rlimit 50" | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCM_IV.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": "GC"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"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": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE ->
code: Vale.X64.Decls.va_code ->
_win: Prims.bool ->
iv_b: Vale.Stdcalls.X64.GCM_IV.b128 ->
num_bytes: Vale.Stdcalls.X64.GCM_IV.uint64 ->
len: Vale.Stdcalls.X64.GCM_IV.uint64 ->
j0_b: Vale.Stdcalls.X64.GCM_IV.b128 ->
iv_extra_b: Vale.Stdcalls.X64.GCM_IV.b128 ->
hkeys_b: Vale.Stdcalls.X64.GCM_IV.b128 ->
va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"FStar.Ghost.erased",
"Vale.AES.GCM_s.supported_iv_LE",
"Vale.X64.Decls.va_code",
"Prims.bool",
"Vale.Stdcalls.X64.GCM_IV.b128",
"Vale.Stdcalls.X64.GCM_IV.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.AES.X64.GCMencryptOpt.va_lemma_Compute_iv_stdcall",
"Vale.Interop.Assumptions.win",
"FStar.Ghost.reveal",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"FStar.UInt64.v",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_pre",
"Prims.l_and",
"Vale.X64.Decls.eval_code",
"Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall",
"Vale.Stdcalls.X64.GCM_IV.compute_iv_post",
"Vale.X64.Memory.buffer_writeable"
] | [] | false | false | false | false | false | let compute_iv_lemma'
(iv: Ghost.erased supported_iv_LE)
(code: V.va_code)
(_win: bool)
(iv_b: b128)
(num_bytes len: uint64)
(j0_b iv_extra_b hkeys_b: b128)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer iv_b) /\
ME.buffer_writeable (as_vale_buffer hkeys_b) /\
ME.buffer_writeable (as_vale_buffer iv_extra_b) /\
ME.buffer_writeable (as_vale_buffer j0_b))) =
| let va_s1, f =
GC.va_lemma_Compute_iv_stdcall code va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b)
(UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b)
(as_vale_buffer hkeys_b)
in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_extra_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 j0_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b;
va_s1, f | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.core_create_lemma_disjointness | val core_create_lemma_disjointness (args: list arg {disjoint_or_eq args})
: Lemma (ensures VSig.disjoint_or_eq args) | val core_create_lemma_disjointness (args: list arg {disjoint_or_eq args})
: Lemma (ensures VSig.disjoint_or_eq args) | let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 60,
"start_col": 0,
"start_line": 39
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = () | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 1,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | args: Prims.list Vale.Interop.Base.arg {Vale.Interop.Base.disjoint_or_eq args}
-> FStar.Pervasives.Lemma (ensures Vale.AsLowStar.ValeSig.disjoint_or_eq args) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.list",
"Vale.Interop.Base.arg",
"Vale.Interop.Base.disjoint_or_eq",
"Prims.unit",
"FStar.BigOps.big_and'",
"Vale.Interop.Base.disjoint_or_eq_1",
"Prims.squash",
"Vale.AsLowStar.ValeSig.disjoint_or_eq_1",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.BigOps.big_and'_cons",
"Prims._assert",
"Vale.AsLowStar.ValeSig.disjoint_or_eq",
"Vale.AsLowStar.Wrapper.core_create_lemma_disjointness",
"FStar.BigOps.pairwise_and'_cons",
"Vale.Interop.Base.disjoint_or_eq_cons",
"Prims.l_True"
] | [
"recursion"
] | false | false | true | false | false | let rec core_create_lemma_disjointness (args: list arg {disjoint_or_eq args})
: Lemma (ensures VSig.disjoint_or_eq args) =
| match args with
| [] -> ()
| hd :: tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n: list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n :: ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl | false |
Vale.X64.Memory.fst | Vale.X64.Memory.b8 | val b8 : Type0 | let b8 = IB.b8 | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 23,
"start_col": 0,
"start_line": 23
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1" | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Types.b8"
] | [] | false | false | false | true | true | let b8 =
| IB.b8 | false |
|
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.lemma_register_args'_aux | val lemma_register_args'_aux
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.length args = n})
(regs1 regs2: IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r.
(forall (i: IX64.reg_nat max_arity {i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r)) (ensures register_args' max_arity arg_reg n args regs2) | val lemma_register_args'_aux
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.length args = n})
(regs1 regs2: IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r.
(forall (i: IX64.reg_nat max_arity {i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r)) (ensures register_args' max_arity arg_reg n args regs2) | let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2 | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 69,
"end_line": 225,
"start_col": 0,
"start_line": 209
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
max_arity: Prims.nat ->
arg_reg: Vale.Interop.X64.arg_reg_relation max_arity ->
n: Prims.nat ->
args: Prims.list Vale.Interop.Base.arg {FStar.List.Tot.Base.length args = n} ->
regs1: Vale.Interop.X64.registers ->
regs2: Vale.Interop.X64.registers
-> FStar.Pervasives.Lemma
(requires
Vale.AsLowStar.Wrapper.register_args' max_arity arg_reg n args regs1 /\
(forall (r: Vale.X64.Machine_s.reg_64).
(forall (i: Vale.Interop.X64.reg_nat max_arity {i >= n}). r <> Rel?.of_arg arg_reg i) /\
r <> Vale.X64.Machine_s.rRsp ==>
regs1 r == regs2 r))
(ensures Vale.AsLowStar.Wrapper.register_args' max_arity arg_reg n args regs2) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Prims.list",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_Equality",
"FStar.List.Tot.Base.length",
"Vale.Interop.X64.registers",
"Vale.AsLowStar.Wrapper.lemma_register_args'_aux",
"Prims.op_Subtraction",
"Prims.unit",
"Prims.l_and",
"Vale.AsLowStar.Wrapper.register_args'",
"Prims.l_Forall",
"Vale.X64.Machine_s.reg_64",
"Prims.l_imp",
"Vale.Interop.X64.reg_nat",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"Vale.Interop.X64.__proj__Rel__item__of_arg",
"Vale.X64.Machine_s.rRsp",
"Prims.eq2",
"Vale.X64.Machine_s.nat64",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_register_args'_aux
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.length args = n})
(regs1 regs2: IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r.
(forall (i: IX64.reg_nat max_arity {i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r)) (ensures register_args' max_arity arg_reg n args regs2) =
| match args with
| [] -> ()
| hd :: tl -> lemma_register_args'_aux max_arity arg_reg (n - 1) tl regs1 regs2 | false |
Vale.X64.Memory.fst | Vale.X64.Memory.get_heaplet_id | val get_heaplet_id (h:vale_heap) : option heaplet_id | val get_heaplet_id (h:vale_heap) : option heaplet_id | let get_heaplet_id h =
h.heapletId | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 29,
"start_col": 0,
"start_line": 28
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: Vale.Arch.HeapImpl.vale_heap -> FStar.Pervasives.Native.option Vale.Arch.HeapImpl.heaplet_id | Prims.Tot | [
"total"
] | [] | [
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__heapletId",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.heaplet_id"
] | [] | false | false | false | true | false | let get_heaplet_id h =
| h.heapletId | false |
Vale.X64.Memory.fst | Vale.X64.Memory.uint8_view | val uint8_view : LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt8.t | let uint8_view = Vale.Interop.Views.up_view8 | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 44,
"end_line": 58,
"start_col": 0,
"start_line": 58
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
() | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt8.t | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Views.up_view8"
] | [] | false | false | false | true | false | let uint8_view =
| Vale.Interop.Views.up_view8 | false |
|
Vale.X64.Memory.fst | Vale.X64.Memory.tuint16 | val tuint16 : Prims.eqtype | let tuint16 = UInt16.t | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 32,
"start_col": 0,
"start_line": 32
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt16.t"
] | [] | false | false | false | true | false | let tuint16 =
| UInt16.t | false |
|
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.stack_args' | val stack_args'
(max_arity n: nat)
(args: list arg {List.Tot.length args = n})
(rsp: int)
(stack: Map.t int Vale.Def.Words_s.nat8)
: prop | val stack_args'
(max_arity n: nat)
(args: list arg {List.Tot.length args = n})
(rsp: int)
(stack: Map.t int Vale.Def.Words_s.nat8)
: prop | let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 332,
"start_col": 0,
"start_line": 314
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
max_arity: Prims.nat ->
n: Prims.nat ->
args: Prims.list Vale.Interop.Base.arg {FStar.List.Tot.Base.length args = n} ->
rsp: Prims.int ->
stack: FStar.Map.t Prims.int Vale.Def.Words_s.nat8
-> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.list",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_Equality",
"FStar.List.Tot.Base.length",
"Prims.int",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Prims.l_True",
"Prims.l_and",
"Vale.AsLowStar.Wrapper.stack_args'",
"Prims.op_Subtraction",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"Vale.Arch.MachineHeap_s.valid_addr64",
"Prims.eq2",
"Vale.Def.Types_s.nat64",
"Vale.Arch.MachineHeap_s.get_heap_val64",
"Vale.Interop.X64.arg_as_nat64",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Vale.Interop.Assumptions.win",
"Prims.logical",
"Prims.prop"
] | [
"recursion"
] | false | false | false | false | true | let rec stack_args'
(max_arity n: nat)
(args: list arg {List.Tot.length args = n})
(rsp: int)
(stack: Map.t int Vale.Def.Words_s.nat8)
: prop =
| match args with
| [] -> True
| hd :: tl ->
stack_args' max_arity (n - 1) tl rsp stack /\
(if n <= max_arity
then True
else
let ptr = ((n - max_arity) - 1) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
BS.valid_addr64 ptr stack /\ BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd) | false |
Vale.X64.Memory.fst | Vale.X64.Memory.uint16_view | val uint16_view : LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt16.t | let uint16_view = Vale.Interop.Views.up_view16 | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 59,
"start_col": 0,
"start_line": 59
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
() | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt16.t | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Views.up_view16"
] | [] | false | false | false | true | false | let uint16_view =
| Vale.Interop.Views.up_view16 | false |
|
Vale.X64.Memory.fst | Vale.X64.Memory.tuint64 | val tuint64 : Prims.eqtype | let tuint64 = UInt64.t | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 34,
"start_col": 0,
"start_line": 34
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt64.t"
] | [] | false | false | false | true | false | let tuint64 =
| UInt64.t | false |
|
Vale.X64.Memory.fst | Vale.X64.Memory.uint64_view | val uint64_view : LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt64.t | let uint64_view = Vale.Interop.Views.up_view64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 61,
"start_col": 0,
"start_line": 61
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt64.t | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Views.up_view64"
] | [] | false | false | false | true | false | let uint64_view =
| Vale.Interop.Views.up_view64 | false |
|
Vale.X64.Memory.fst | Vale.X64.Memory.tuint32 | val tuint32 : Prims.eqtype | let tuint32 = UInt32.t | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 33,
"start_col": 0,
"start_line": 33
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t"
] | [] | false | false | false | true | false | let tuint32 =
| UInt32.t | false |
|
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.register_args' | val register_args'
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.length args = n})
(regs: IX64.registers)
: prop | val register_args'
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.length args = n})
(regs: IX64.registers)
: prop | let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 207,
"start_col": 0,
"start_line": 195
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
max_arity: Prims.nat ->
arg_reg: Vale.Interop.X64.arg_reg_relation max_arity ->
n: Prims.nat ->
args: Prims.list Vale.Interop.Base.arg {FStar.List.Tot.Base.length args = n} ->
regs: Vale.Interop.X64.registers
-> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Prims.list",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_Equality",
"FStar.List.Tot.Base.length",
"Vale.Interop.X64.registers",
"Prims.l_True",
"Prims.l_and",
"Vale.AsLowStar.Wrapper.register_args'",
"Prims.op_Subtraction",
"Prims.op_GreaterThan",
"Prims.bool",
"Prims.eq2",
"Vale.X64.Machine_s.nat64",
"Vale.Interop.X64.__proj__Rel__item__of_arg",
"Vale.Interop.X64.arg_as_nat64",
"Prims.logical",
"Prims.prop"
] | [
"recursion"
] | false | false | false | false | true | let rec register_args'
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(n: nat)
(args: list arg {List.length args = n})
(regs: IX64.registers)
: prop =
| match args with
| [] -> True
| hd :: tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd) | false |
Vale.X64.Memory.fst | Vale.X64.Memory.uint128_view | val uint128_view : LowStar.BufferView.Up.view FStar.UInt8.t Vale.Def.Types_s.quad32 | let uint128_view = Vale.Interop.Views.up_view128 | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 62,
"start_col": 0,
"start_line": 62
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowStar.BufferView.Up.view FStar.UInt8.t Vale.Def.Types_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Views.up_view128"
] | [] | false | false | false | true | false | let uint128_view =
| Vale.Interop.Views.up_view128 | false |
|
Vale.X64.Memory.fst | Vale.X64.Memory.tuint8 | val tuint8 : Prims.eqtype | let tuint8 = UInt8.t | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt8.t"
] | [] | false | false | false | true | false | let tuint8 =
| UInt8.t | false |
|
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.lemma_register_args' | val lemma_register_args'
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(args: IX64.arg_list)
(regs: IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs)) | val lemma_register_args'
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(args: IX64.arg_list)
(regs: IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs)) | let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 243,
"start_col": 0,
"start_line": 227
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
max_arity: Prims.nat ->
arg_reg: Vale.Interop.X64.arg_reg_relation max_arity ->
args: Vale.Interop.X64.arg_list ->
regs: Vale.Interop.X64.registers
-> FStar.Pervasives.Lemma
(ensures
(let final_regs =
Vale.Interop.X64.register_of_args max_arity
arg_reg
(FStar.List.Tot.Base.length args)
args
regs
in
Vale.AsLowStar.Wrapper.register_args' max_arity
arg_reg
(FStar.List.Tot.Base.length args)
args
final_regs)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.Interop.X64.arg_list",
"Vale.Interop.X64.registers",
"Vale.Interop.Base.arg",
"Prims.list",
"Vale.AsLowStar.Wrapper.lemma_register_args'_aux",
"Prims.op_Subtraction",
"Prims.unit",
"Vale.AsLowStar.Wrapper.lemma_register_args'",
"Prims.eq2",
"Vale.Def.Words_s.nat64",
"Vale.Interop.X64.register_of_args",
"FStar.List.Tot.Base.length",
"Prims.l_True",
"Prims.squash",
"Vale.AsLowStar.Wrapper.register_args'",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_register_args'
(max_arity: nat)
(arg_reg: IX64.arg_reg_relation max_arity)
(args: IX64.arg_list)
(regs: IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs)) =
| let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd :: tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n - 1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n - 1) tl regs' final_regs | false |
Vale.X64.Memory.fst | Vale.X64.Memory.uint32_view | val uint32_view : LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt32.t | let uint32_view = Vale.Interop.Views.up_view32 | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 60,
"start_col": 0,
"start_line": 60
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Views.up_view32"
] | [] | false | false | false | true | false | let uint32_view =
| Vale.Interop.Views.up_view32 | false |
|
Vale.X64.Memory.fst | Vale.X64.Memory.buffer_readable | val buffer_readable (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot prop0 | val buffer_readable (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot prop0 | let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h)) | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 76,
"start_col": 0,
"start_line": 76
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: Vale.Arch.HeapImpl.vale_heap -> b: Vale.X64.Memory.buffer t -> Prims.GTot Vale.Def.Prop_s.prop0 | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.X64.Memory.buffer",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Vale.Arch.HeapImpl._ih",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | false | false | let buffer_readable #t h b =
| List.memP b (IB.ptrs_of_mem (_ih h)) | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.loc_includes_union | val loc_includes_union (l1 l1' l: B.loc)
: Lemma (requires B.(loc_includes l1 l1'))
(ensures B.(loc_includes (loc_union l1 l) (loc_union l1' l))) | val loc_includes_union (l1 l1' l: B.loc)
: Lemma (requires B.(loc_includes l1 l1'))
(ensures B.(loc_includes (loc_union l1 l) (loc_union l1' l))) | let loc_includes_union (l1 l1' l:B.loc)
: Lemma (requires B.(loc_includes l1 l1'))
(ensures B.(loc_includes (loc_union l1 l) (loc_union l1' l)))
= let open B in
loc_includes_union_l l1 l l1';
loc_includes_union_l l1 l l;
loc_includes_union_r (loc_union l1 l) l1' l | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 537,
"start_col": 0,
"start_line": 531
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd)
let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal ()
let frame_update_valid_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let rec stack_of_args_stack_args'_aux
(max_arity:nat)
(n_init:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
(v:MS.nat64)
: Lemma
(requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack)))
= match args with
| [] -> ()
| hd::tl ->
stack_of_args_stack_args'_aux max_arity n_init (n-1) tl rsp stack v;
if n <= max_arity then ()
else (
let fixed = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
calc ( <= ) {
((n - max_arity) - 1) * 8;
( <= ) { FStar.Math.Lemmas.lemma_mult_le_right 8 ((n - max_arity) - 1) (n_init - max_arity) }
(n_init - max_arity) * 8;
};
frame_update_get_heap fixed v stack ptr;
frame_update_valid_heap fixed v stack ptr
)
#push-options "--max_fuel 1 --max_ifuel 0 --z3rlimit 150 --z3refresh"
let stack_of_args_stack_args'
(max_arity:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(init_rsp:MS.nat64{init_rsp >= 4096}) : Lemma
(let mem = Map.const_on Set.empty 0 in
stack_args' max_arity n args init_rsp (IX64.stack_of_args max_arity n init_rsp args mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
let rec aux (args:IX64.arg_list) (accu:Map.t int Vale.Def.Words_s.nat8) : Lemma (ensures (
stack_args' max_arity (List.length args) args init_rsp
(IX64.stack_of_args max_arity (List.length args) init_rsp args accu)))
(decreases (List.length args))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
match args with
| [] -> ()
| hd::tl ->
aux tl accu;
let n = List.length args in
if n <= max_arity then ()
else (
let ptr = ((n - max_arity) - 1) * 8 // Arguments on the stack are pushed from right to left
+ (if IA.win then 32 else 0) // The shadow space on Windows comes next
+ 8 // The return address is then pushed on the stack
+ init_rsp // And we then have all the extra slots required for the Vale procedure
in
let accu' = IX64.stack_of_args max_arity (n-1) init_rsp tl accu in
let v = IX64.arg_as_nat64 hd in // We will store the arg hd
let h_final = BS.update_heap64 ptr v accu' in
stack_of_args_stack_args'_aux max_arity (n-1) (n-1) tl init_rsp accu' v;
Vale.Arch.MachineHeap.correct_update_get64 ptr v accu';
BS.update_heap64_reveal ()
)
in aux args (Map.const_on Set.empty 0)
#pop-options
#reset-options "--z3rlimit 40"
let core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let init_rsp = IA.init_regs MS.rRsp in
let stack = Map.const_on Set.empty 0 in
let stack_map = IX64.stack_of_args max_arity (List.Tot.length args) init_rsp args stack in
let stack_f = BS.Machine_stack init_rsp stack_map in
let rec aux (accu:IX64.arg_list{List.length accu <= List.length args}) : Lemma
(requires
stack_args' max_arity (List.length accu) accu init_rsp stack_map)
(ensures LSig.stack_args max_arity (List.length accu) accu va_s)
(decreases (List.length accu))
=
match accu with
| [] -> ()
| hd::tl ->
aux tl;
let i = List.length accu in
if i <= max_arity then ()
else (
let ptr =
((i - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ init_rsp
in
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal stack_f;
SI.lemma_valid_taint_stack64_reveal ptr MS.Public va_s.VS.vs_stackTaint;
let aux2 () : Lemma (IX64.arg_as_nat64 hd == LSig.arg_as_nat64 hd va_s) =
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args h0
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args h0
| _ -> ()
in aux2()
)
in
stack_of_args_stack_args' max_arity (List.length args) args init_rsp;
aux args
let core_create_lemma
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s /\
LSig.mem_correspondence args h0 va_s /\
VSig.disjoint_or_eq args /\
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap) /\
LSig.vale_pre_hyp #max_arity #arg_reg args va_s /\
ST.equal_domains h0 (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap))
))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let t_state = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let t_stack = t_state.BS.ms_stack in
core_create_lemma_mem_correspondance #max_arity #arg_reg args h0;
core_create_lemma_disjointness args;
core_create_lemma_readable #max_arity #arg_reg args h0;
core_create_lemma_register_args #max_arity #arg_reg args h0;
core_create_lemma_stack_args #max_arity #arg_reg args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal t_stack;
Vale.AsLowStar.MemoryHelpers.core_create_lemma_taint_hyp #max_arity #arg_reg args h0;
core_create_lemma_state #max_arity #arg_reg args h0
let eval_code_ts (c:BS.code)
(s0:BS.machine_state)
(f0:nat)
(s1:BS.machine_state) : Type0 =
VL.state_eq_opt true (BS.machine_eval_code c f0 s0) (Some s1)
let eval_code_rel (c:BS.code)
(va_s0 va_s1:V.va_state) (f:V.va_fuel)
: Lemma
(requires (V.eval_code c va_s0 f va_s1))
(ensures (eval_code_ts c (SL.state_to_S va_s0) (coerce f) (SL.state_to_S va_s1)))
= Vale.AsLowStar.MemoryHelpers.decls_eval_code_reveal c va_s0 va_s1 f
let rec mem_correspondence_refl (args:list arg)
(va_s:V.va_state)
: Lemma
(ensures LSig.mem_correspondence args (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap)) va_s)
=
let h = hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap) in
match args with
| [] -> ()
| hd::tl ->
mem_correspondence_refl tl va_s;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal2 src bt x va_s
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal2 src bt x va_s
| _ -> ()
//////////////////////////////////////////////////////////////////////////////// | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l1: LowStar.Monotonic.Buffer.loc ->
l1': LowStar.Monotonic.Buffer.loc ->
l: LowStar.Monotonic.Buffer.loc
-> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.loc_includes l1 l1')
(ensures
LowStar.Monotonic.Buffer.loc_includes (LowStar.Monotonic.Buffer.loc_union l1 l)
(LowStar.Monotonic.Buffer.loc_union l1' l)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowStar.Monotonic.Buffer.loc",
"LowStar.Monotonic.Buffer.loc_includes_union_r",
"LowStar.Monotonic.Buffer.loc_union",
"Prims.unit",
"LowStar.Monotonic.Buffer.loc_includes_union_l",
"LowStar.Monotonic.Buffer.loc_includes",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let loc_includes_union (l1 l1' l: B.loc)
: Lemma (requires B.(loc_includes l1 l1'))
(ensures B.(loc_includes (loc_union l1 l) (loc_union l1' l))) =
| let open B in
loc_includes_union_l l1 l l1';
loc_includes_union_l l1 l l;
loc_includes_union_r (loc_union l1 l) l1' l | false |
Vale.X64.Memory.fst | Vale.X64.Memory.buffer_writeable | val buffer_writeable (#t:base_typ) (b:buffer t) : GTot prop0 | val buffer_writeable (#t:base_typ) (b:buffer t) : GTot prop0 | let buffer_writeable #t b = b.writeable | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 77,
"start_col": 0,
"start_line": 77
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Vale.X64.Memory.buffer t -> Prims.GTot Vale.Def.Prop_s.prop0 | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.X64.Memory.buffer",
"Prims.b2t",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | false | false | let buffer_writeable #t b =
| b.writeable | false |
Vale.X64.Memory.fst | Vale.X64.Memory.loc | val loc : Type u#0 | val loc : Type u#0 | let loc = M.loc | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 79,
"start_col": 0,
"start_line": 79
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"LowStar.Monotonic.Buffer.loc"
] | [] | false | false | false | true | true | let loc =
| M.loc | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.eval_code_rel | val eval_code_rel (c: BS.code) (va_s0 va_s1: V.va_state) (f: V.va_fuel)
: Lemma (requires (V.eval_code c va_s0 f va_s1))
(ensures (eval_code_ts c (SL.state_to_S va_s0) (coerce f) (SL.state_to_S va_s1))) | val eval_code_rel (c: BS.code) (va_s0 va_s1: V.va_state) (f: V.va_fuel)
: Lemma (requires (V.eval_code c va_s0 f va_s1))
(ensures (eval_code_ts c (SL.state_to_S va_s0) (coerce f) (SL.state_to_S va_s1))) | let eval_code_rel (c:BS.code)
(va_s0 va_s1:V.va_state) (f:V.va_fuel)
: Lemma
(requires (V.eval_code c va_s0 f va_s1))
(ensures (eval_code_ts c (SL.state_to_S va_s0) (coerce f) (SL.state_to_S va_s1)))
= Vale.AsLowStar.MemoryHelpers.decls_eval_code_reveal c va_s0 va_s1 f | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 510,
"start_col": 0,
"start_line": 505
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd)
let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal ()
let frame_update_valid_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let rec stack_of_args_stack_args'_aux
(max_arity:nat)
(n_init:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
(v:MS.nat64)
: Lemma
(requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack)))
= match args with
| [] -> ()
| hd::tl ->
stack_of_args_stack_args'_aux max_arity n_init (n-1) tl rsp stack v;
if n <= max_arity then ()
else (
let fixed = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
calc ( <= ) {
((n - max_arity) - 1) * 8;
( <= ) { FStar.Math.Lemmas.lemma_mult_le_right 8 ((n - max_arity) - 1) (n_init - max_arity) }
(n_init - max_arity) * 8;
};
frame_update_get_heap fixed v stack ptr;
frame_update_valid_heap fixed v stack ptr
)
#push-options "--max_fuel 1 --max_ifuel 0 --z3rlimit 150 --z3refresh"
let stack_of_args_stack_args'
(max_arity:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(init_rsp:MS.nat64{init_rsp >= 4096}) : Lemma
(let mem = Map.const_on Set.empty 0 in
stack_args' max_arity n args init_rsp (IX64.stack_of_args max_arity n init_rsp args mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
let rec aux (args:IX64.arg_list) (accu:Map.t int Vale.Def.Words_s.nat8) : Lemma (ensures (
stack_args' max_arity (List.length args) args init_rsp
(IX64.stack_of_args max_arity (List.length args) init_rsp args accu)))
(decreases (List.length args))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
match args with
| [] -> ()
| hd::tl ->
aux tl accu;
let n = List.length args in
if n <= max_arity then ()
else (
let ptr = ((n - max_arity) - 1) * 8 // Arguments on the stack are pushed from right to left
+ (if IA.win then 32 else 0) // The shadow space on Windows comes next
+ 8 // The return address is then pushed on the stack
+ init_rsp // And we then have all the extra slots required for the Vale procedure
in
let accu' = IX64.stack_of_args max_arity (n-1) init_rsp tl accu in
let v = IX64.arg_as_nat64 hd in // We will store the arg hd
let h_final = BS.update_heap64 ptr v accu' in
stack_of_args_stack_args'_aux max_arity (n-1) (n-1) tl init_rsp accu' v;
Vale.Arch.MachineHeap.correct_update_get64 ptr v accu';
BS.update_heap64_reveal ()
)
in aux args (Map.const_on Set.empty 0)
#pop-options
#reset-options "--z3rlimit 40"
let core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let init_rsp = IA.init_regs MS.rRsp in
let stack = Map.const_on Set.empty 0 in
let stack_map = IX64.stack_of_args max_arity (List.Tot.length args) init_rsp args stack in
let stack_f = BS.Machine_stack init_rsp stack_map in
let rec aux (accu:IX64.arg_list{List.length accu <= List.length args}) : Lemma
(requires
stack_args' max_arity (List.length accu) accu init_rsp stack_map)
(ensures LSig.stack_args max_arity (List.length accu) accu va_s)
(decreases (List.length accu))
=
match accu with
| [] -> ()
| hd::tl ->
aux tl;
let i = List.length accu in
if i <= max_arity then ()
else (
let ptr =
((i - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ init_rsp
in
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal stack_f;
SI.lemma_valid_taint_stack64_reveal ptr MS.Public va_s.VS.vs_stackTaint;
let aux2 () : Lemma (IX64.arg_as_nat64 hd == LSig.arg_as_nat64 hd va_s) =
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args h0
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args h0
| _ -> ()
in aux2()
)
in
stack_of_args_stack_args' max_arity (List.length args) args init_rsp;
aux args
let core_create_lemma
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s /\
LSig.mem_correspondence args h0 va_s /\
VSig.disjoint_or_eq args /\
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap) /\
LSig.vale_pre_hyp #max_arity #arg_reg args va_s /\
ST.equal_domains h0 (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap))
))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let t_state = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let t_stack = t_state.BS.ms_stack in
core_create_lemma_mem_correspondance #max_arity #arg_reg args h0;
core_create_lemma_disjointness args;
core_create_lemma_readable #max_arity #arg_reg args h0;
core_create_lemma_register_args #max_arity #arg_reg args h0;
core_create_lemma_stack_args #max_arity #arg_reg args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal t_stack;
Vale.AsLowStar.MemoryHelpers.core_create_lemma_taint_hyp #max_arity #arg_reg args h0;
core_create_lemma_state #max_arity #arg_reg args h0
let eval_code_ts (c:BS.code)
(s0:BS.machine_state)
(f0:nat)
(s1:BS.machine_state) : Type0 =
VL.state_eq_opt true (BS.machine_eval_code c f0 s0) (Some s1) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Vale.X64.Machine_Semantics_s.code ->
va_s0: Vale.X64.Decls.va_state ->
va_s1: Vale.X64.Decls.va_state ->
f: Vale.X64.Decls.va_fuel
-> FStar.Pervasives.Lemma (requires Vale.X64.Decls.eval_code c va_s0 f va_s1)
(ensures
Vale.AsLowStar.Wrapper.eval_code_ts c
(Vale.X64.StateLemmas.state_to_S va_s0)
(Vale.Interop.Base.coerce f)
(Vale.X64.StateLemmas.state_to_S va_s1)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.X64.Machine_Semantics_s.code",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.AsLowStar.MemoryHelpers.decls_eval_code_reveal",
"Prims.unit",
"Vale.X64.Decls.eval_code",
"Prims.squash",
"Vale.AsLowStar.Wrapper.eval_code_ts",
"Vale.X64.StateLemmas.state_to_S",
"Vale.Interop.Base.coerce",
"Prims.nat",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let eval_code_rel (c: BS.code) (va_s0 va_s1: V.va_state) (f: V.va_fuel)
: Lemma (requires (V.eval_code c va_s0 f va_s1))
(ensures (eval_code_ts c (SL.state_to_S va_s0) (coerce f) (SL.state_to_S va_s1))) =
| Vale.AsLowStar.MemoryHelpers.decls_eval_code_reveal c va_s0 va_s1 f | false |
Vale.X64.Memory.fst | Vale.X64.Memory.loc_includes | val loc_includes (s1 s2:loc) : GTot prop0 | val loc_includes (s1 s2:loc) : GTot prop0 | let loc_includes = M.loc_includes | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 84,
"start_col": 0,
"start_line": 84
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s1: Vale.X64.Memory.loc -> s2: Vale.X64.Memory.loc -> Prims.GTot Vale.Def.Prop_s.prop0 | Prims.GTot | [
"sometrivial"
] | [] | [
"LowStar.Monotonic.Buffer.loc_includes"
] | [] | false | false | false | false | false | let loc_includes =
| M.loc_includes | false |
Vale.X64.Memory.fst | Vale.X64.Memory.loc_buffer | val loc_buffer (#t:base_typ) (b:buffer t) : GTot loc | val loc_buffer (#t:base_typ) (b:buffer t) : GTot loc | let loc_buffer #t b = M.loc_buffer b.bsrc | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 82,
"start_col": 0,
"start_line": 82
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Vale.X64.Memory.buffer t -> Prims.GTot Vale.X64.Memory.loc | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.X64.Memory.buffer",
"LowStar.Monotonic.Buffer.loc_buffer",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.X64.Memory.loc"
] | [] | false | false | false | false | false | let loc_buffer #t b =
| M.loc_buffer b.bsrc | false |
Vale.X64.Memory.fst | Vale.X64.Memory.loc_none | val loc_none : loc | val loc_none : loc | let loc_none = M.loc_none | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 80,
"start_col": 0,
"start_line": 80
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.X64.Memory.loc | Prims.Tot | [
"total"
] | [] | [
"LowStar.Monotonic.Buffer.loc_none"
] | [] | false | false | false | true | false | let loc_none =
| M.loc_none | false |
Vale.X64.Memory.fst | Vale.X64.Memory.buffer_addr | val buffer_addr (#t:base_typ) (b:buffer t) (h:vale_heap) : GTot int | val buffer_addr (#t:base_typ) (b:buffer t) (h:vale_heap) : GTot int | let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 92,
"start_col": 0,
"start_line": 92
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Vale.X64.Memory.buffer t -> h: Vale.Arch.HeapImpl.vale_heap -> Prims.GTot Prims.int | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.X64.Memory.buffer",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Interop.Heap_s.addrs_of_mem",
"Vale.Arch.HeapImpl._ih",
"Prims.int"
] | [] | false | false | false | false | false | let buffer_addr #t b h =
| IB.addrs_of_mem (_ih h) b | false |
Vale.X64.Memory.fst | Vale.X64.Memory.loc_union | val loc_union (s1 s2:loc) : GTot loc | val loc_union (s1 s2:loc) : GTot loc | let loc_union = M.loc_union | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 81,
"start_col": 0,
"start_line": 81
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s1: Vale.X64.Memory.loc -> s2: Vale.X64.Memory.loc -> Prims.GTot Vale.X64.Memory.loc | Prims.GTot | [
"sometrivial"
] | [] | [
"LowStar.Monotonic.Buffer.loc_union"
] | [] | false | false | false | false | false | let loc_union =
| M.loc_union | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.core_create_lemma | val core_create_lemma
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s /\
LSig.mem_correspondence args h0 va_s /\ VSig.disjoint_or_eq args /\
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap) /\
LSig.vale_pre_hyp #max_arity #arg_reg args va_s /\
ST.equal_domains h0 (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap)))) | val core_create_lemma
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s /\
LSig.mem_correspondence args h0 va_s /\ VSig.disjoint_or_eq args /\
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap) /\
LSig.vale_pre_hyp #max_arity #arg_reg args va_s /\
ST.equal_domains h0 (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap)))) | let core_create_lemma
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s /\
LSig.mem_correspondence args h0 va_s /\
VSig.disjoint_or_eq args /\
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap) /\
LSig.vale_pre_hyp #max_arity #arg_reg args va_s /\
ST.equal_domains h0 (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap))
))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let t_state = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let t_stack = t_state.BS.ms_stack in
core_create_lemma_mem_correspondance #max_arity #arg_reg args h0;
core_create_lemma_disjointness args;
core_create_lemma_readable #max_arity #arg_reg args h0;
core_create_lemma_register_args #max_arity #arg_reg args h0;
core_create_lemma_stack_args #max_arity #arg_reg args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal t_stack;
Vale.AsLowStar.MemoryHelpers.core_create_lemma_taint_hyp #max_arity #arg_reg args h0;
core_create_lemma_state #max_arity #arg_reg args h0 | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 497,
"start_col": 0,
"start_line": 472
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd)
let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal ()
let frame_update_valid_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let rec stack_of_args_stack_args'_aux
(max_arity:nat)
(n_init:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
(v:MS.nat64)
: Lemma
(requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack)))
= match args with
| [] -> ()
| hd::tl ->
stack_of_args_stack_args'_aux max_arity n_init (n-1) tl rsp stack v;
if n <= max_arity then ()
else (
let fixed = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
calc ( <= ) {
((n - max_arity) - 1) * 8;
( <= ) { FStar.Math.Lemmas.lemma_mult_le_right 8 ((n - max_arity) - 1) (n_init - max_arity) }
(n_init - max_arity) * 8;
};
frame_update_get_heap fixed v stack ptr;
frame_update_valid_heap fixed v stack ptr
)
#push-options "--max_fuel 1 --max_ifuel 0 --z3rlimit 150 --z3refresh"
let stack_of_args_stack_args'
(max_arity:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(init_rsp:MS.nat64{init_rsp >= 4096}) : Lemma
(let mem = Map.const_on Set.empty 0 in
stack_args' max_arity n args init_rsp (IX64.stack_of_args max_arity n init_rsp args mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
let rec aux (args:IX64.arg_list) (accu:Map.t int Vale.Def.Words_s.nat8) : Lemma (ensures (
stack_args' max_arity (List.length args) args init_rsp
(IX64.stack_of_args max_arity (List.length args) init_rsp args accu)))
(decreases (List.length args))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
match args with
| [] -> ()
| hd::tl ->
aux tl accu;
let n = List.length args in
if n <= max_arity then ()
else (
let ptr = ((n - max_arity) - 1) * 8 // Arguments on the stack are pushed from right to left
+ (if IA.win then 32 else 0) // The shadow space on Windows comes next
+ 8 // The return address is then pushed on the stack
+ init_rsp // And we then have all the extra slots required for the Vale procedure
in
let accu' = IX64.stack_of_args max_arity (n-1) init_rsp tl accu in
let v = IX64.arg_as_nat64 hd in // We will store the arg hd
let h_final = BS.update_heap64 ptr v accu' in
stack_of_args_stack_args'_aux max_arity (n-1) (n-1) tl init_rsp accu' v;
Vale.Arch.MachineHeap.correct_update_get64 ptr v accu';
BS.update_heap64_reveal ()
)
in aux args (Map.const_on Set.empty 0)
#pop-options
#reset-options "--z3rlimit 40"
let core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let init_rsp = IA.init_regs MS.rRsp in
let stack = Map.const_on Set.empty 0 in
let stack_map = IX64.stack_of_args max_arity (List.Tot.length args) init_rsp args stack in
let stack_f = BS.Machine_stack init_rsp stack_map in
let rec aux (accu:IX64.arg_list{List.length accu <= List.length args}) : Lemma
(requires
stack_args' max_arity (List.length accu) accu init_rsp stack_map)
(ensures LSig.stack_args max_arity (List.length accu) accu va_s)
(decreases (List.length accu))
=
match accu with
| [] -> ()
| hd::tl ->
aux tl;
let i = List.length accu in
if i <= max_arity then ()
else (
let ptr =
((i - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ init_rsp
in
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal stack_f;
SI.lemma_valid_taint_stack64_reveal ptr MS.Public va_s.VS.vs_stackTaint;
let aux2 () : Lemma (IX64.arg_as_nat64 hd == LSig.arg_as_nat64 hd va_s) =
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args h0
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args h0
| _ -> ()
in aux2()
)
in
stack_of_args_stack_args' max_arity (List.length args) args init_rsp;
aux args | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
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
FStar.Pervasives.Native.fst (Vale.Interop.X64.create_initial_trusted_state max_arity
arg_reg
args
h0) ==
Vale.X64.StateLemmas.state_to_S va_s /\
Vale.AsLowStar.LowStarSig.mem_correspondence args h0 va_s /\
Vale.AsLowStar.ValeSig.disjoint_or_eq args /\
Vale.AsLowStar.ValeSig.readable args
(Vale.X64.Memory.get_vale_heap (Mkvale_state?.vs_heap va_s)) /\
Vale.AsLowStar.LowStarSig.vale_pre_hyp args va_s /\
FStar.HyperStack.ST.equal_domains h0
(Vale.Interop.Heap_s.hs_of_mem (Vale.X64.MemoryAdapters.as_mem (Mkvale_full_heap?.vf_heap (
Mkvale_state?.vs_heap va_s)))))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"Vale.AsLowStar.Wrapper.core_create_lemma_state",
"Prims.unit",
"Vale.AsLowStar.MemoryHelpers.core_create_lemma_taint_hyp",
"Vale.AsLowStar.MemoryHelpers.mk_stack_reveal",
"Vale.AsLowStar.Wrapper.core_create_lemma_stack_args",
"Vale.AsLowStar.Wrapper.core_create_lemma_register_args",
"Vale.AsLowStar.Wrapper.core_create_lemma_readable",
"Vale.AsLowStar.Wrapper.core_create_lemma_disjointness",
"Vale.AsLowStar.Wrapper.core_create_lemma_mem_correspondance",
"Vale.X64.Machine_Semantics_s.machine_stack",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Pervasives.Native.fst",
"Vale.Interop.Heap_s.interop_heap",
"Vale.Interop.X64.create_initial_trusted_state",
"Vale.X64.Decls.vale_state_with_inv",
"Vale.AsLowStar.LowStarSig.create_initial_vale_state",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"Prims.eq2",
"Vale.X64.StateLemmas.state_to_S",
"Vale.AsLowStar.LowStarSig.mem_correspondence",
"Vale.AsLowStar.ValeSig.disjoint_or_eq",
"Vale.AsLowStar.ValeSig.readable",
"Vale.X64.Memory.get_vale_heap",
"Vale.X64.State.__proj__Mkvale_state__item__vs_heap",
"Vale.AsLowStar.LowStarSig.vale_pre_hyp",
"FStar.HyperStack.ST.equal_domains",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.X64.MemoryAdapters.as_mem",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let core_create_lemma
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s /\
LSig.mem_correspondence args h0 va_s /\ VSig.disjoint_or_eq args /\
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap) /\
LSig.vale_pre_hyp #max_arity #arg_reg args va_s /\
ST.equal_domains h0 (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap)))) =
| let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let t_state = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let t_stack = t_state.BS.ms_stack in
core_create_lemma_mem_correspondance #max_arity #arg_reg args h0;
core_create_lemma_disjointness args;
core_create_lemma_readable #max_arity #arg_reg args h0;
core_create_lemma_register_args #max_arity #arg_reg args h0;
core_create_lemma_stack_args #max_arity #arg_reg args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal t_stack;
Vale.AsLowStar.MemoryHelpers.core_create_lemma_taint_hyp #max_arity #arg_reg args h0;
core_create_lemma_state #max_arity #arg_reg args h0 | false |
Vale.X64.Memory.fst | Vale.X64.Memory.loc_disjoint | val loc_disjoint (s1 s2:loc) : GTot prop0 | val loc_disjoint (s1 s2:loc) : GTot prop0 | let loc_disjoint = M.loc_disjoint | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 83,
"start_col": 0,
"start_line": 83
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s1: Vale.X64.Memory.loc -> s2: Vale.X64.Memory.loc -> Prims.GTot Vale.Def.Prop_s.prop0 | Prims.GTot | [
"sometrivial"
] | [] | [
"LowStar.Monotonic.Buffer.loc_disjoint"
] | [] | false | false | false | false | false | let loc_disjoint =
| M.loc_disjoint | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.stack_of_args_stack_args'_aux | val stack_of_args_stack_args'_aux
(max_arity n_init n: nat)
(args: IX64.arg_list{List.Tot.length args = n})
(rsp: int)
(stack: Map.t int Vale.Def.Words_s.nat8)
(v: MS.nat64)
: Lemma (requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack))) | val stack_of_args_stack_args'_aux
(max_arity n_init n: nat)
(args: IX64.arg_list{List.Tot.length args = n})
(rsp: int)
(stack: Map.t int Vale.Def.Words_s.nat8)
(v: MS.nat64)
: Lemma (requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack))) | let rec stack_of_args_stack_args'_aux
(max_arity:nat)
(n_init:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
(v:MS.nat64)
: Lemma
(requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack)))
= match args with
| [] -> ()
| hd::tl ->
stack_of_args_stack_args'_aux max_arity n_init (n-1) tl rsp stack v;
if n <= max_arity then ()
else (
let fixed = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
calc ( <= ) {
((n - max_arity) - 1) * 8;
( <= ) { FStar.Math.Lemmas.lemma_mult_le_right 8 ((n - max_arity) - 1) (n_init - max_arity) }
(n_init - max_arity) * 8;
};
frame_update_get_heap fixed v stack ptr;
frame_update_valid_heap fixed v stack ptr
) | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 380,
"start_col": 0,
"start_line": 348
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd)
let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal ()
let frame_update_valid_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal () | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
max_arity: Prims.nat ->
n_init: Prims.nat ->
n: Prims.nat ->
args: Vale.Interop.X64.arg_list{FStar.List.Tot.Base.length args = n} ->
rsp: Prims.int ->
stack: FStar.Map.t Prims.int Vale.Def.Words_s.nat8 ->
v: Vale.X64.Machine_s.nat64
-> FStar.Pervasives.Lemma
(requires Vale.AsLowStar.Wrapper.stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr =
(n_init - max_arity) * 8 +
(match Vale.Interop.Assumptions.win with
| true -> 32
| _ -> 0) +
8 +
rsp
in
Vale.AsLowStar.Wrapper.stack_args' max_arity
n
args
rsp
(Vale.Arch.MachineHeap_s.update_heap64 ptr v stack))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_list",
"Prims.b2t",
"Prims.op_Equality",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.arg",
"Prims.int",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.X64.Machine_s.nat64",
"Prims.list",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"Vale.AsLowStar.Wrapper.frame_update_valid_heap",
"Prims.unit",
"Vale.AsLowStar.Wrapper.frame_update_get_heap",
"FStar.Calc.calc_finish",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.lemma_mult_le_right",
"Prims.squash",
"Prims.op_Addition",
"Vale.Interop.Assumptions.win",
"Vale.AsLowStar.Wrapper.stack_of_args_stack_args'_aux",
"Prims.l_and",
"Vale.AsLowStar.Wrapper.stack_args'",
"Prims.op_GreaterThanOrEqual",
"Vale.Arch.MachineHeap_s.update_heap64",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec stack_of_args_stack_args'_aux
(max_arity n_init n: nat)
(args: IX64.arg_list{List.Tot.length args = n})
(rsp: int)
(stack: Map.t int Vale.Def.Words_s.nat8)
(v: MS.nat64)
: Lemma (requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack))) =
| match args with
| [] -> ()
| hd :: tl ->
stack_of_args_stack_args'_aux max_arity n_init (n - 1) tl rsp stack v;
if n <= max_arity
then ()
else
(let fixed = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
let ptr = ((n - max_arity) - 1) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
calc ( <= ) {
((n - max_arity) - 1) * 8;
( <= ) { FStar.Math.Lemmas.lemma_mult_le_right 8 ((n - max_arity) - 1) (n_init - max_arity) }
(n_init - max_arity) * 8;
};
frame_update_get_heap fixed v stack ptr;
frame_update_valid_heap fixed v stack ptr) | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.mem_correspondence_refl | val mem_correspondence_refl (args: list arg) (va_s: V.va_state)
: Lemma (ensures LSig.mem_correspondence args (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap)) va_s) | val mem_correspondence_refl (args: list arg) (va_s: V.va_state)
: Lemma (ensures LSig.mem_correspondence args (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap)) va_s) | let rec mem_correspondence_refl (args:list arg)
(va_s:V.va_state)
: Lemma
(ensures LSig.mem_correspondence args (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap)) va_s)
=
let h = hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap) in
match args with
| [] -> ()
| hd::tl ->
mem_correspondence_refl tl va_s;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal2 src bt x va_s
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal2 src bt x va_s
| _ -> () | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 527,
"start_col": 0,
"start_line": 512
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd)
let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal ()
let frame_update_valid_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let rec stack_of_args_stack_args'_aux
(max_arity:nat)
(n_init:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
(v:MS.nat64)
: Lemma
(requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack)))
= match args with
| [] -> ()
| hd::tl ->
stack_of_args_stack_args'_aux max_arity n_init (n-1) tl rsp stack v;
if n <= max_arity then ()
else (
let fixed = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
calc ( <= ) {
((n - max_arity) - 1) * 8;
( <= ) { FStar.Math.Lemmas.lemma_mult_le_right 8 ((n - max_arity) - 1) (n_init - max_arity) }
(n_init - max_arity) * 8;
};
frame_update_get_heap fixed v stack ptr;
frame_update_valid_heap fixed v stack ptr
)
#push-options "--max_fuel 1 --max_ifuel 0 --z3rlimit 150 --z3refresh"
let stack_of_args_stack_args'
(max_arity:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(init_rsp:MS.nat64{init_rsp >= 4096}) : Lemma
(let mem = Map.const_on Set.empty 0 in
stack_args' max_arity n args init_rsp (IX64.stack_of_args max_arity n init_rsp args mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
let rec aux (args:IX64.arg_list) (accu:Map.t int Vale.Def.Words_s.nat8) : Lemma (ensures (
stack_args' max_arity (List.length args) args init_rsp
(IX64.stack_of_args max_arity (List.length args) init_rsp args accu)))
(decreases (List.length args))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
match args with
| [] -> ()
| hd::tl ->
aux tl accu;
let n = List.length args in
if n <= max_arity then ()
else (
let ptr = ((n - max_arity) - 1) * 8 // Arguments on the stack are pushed from right to left
+ (if IA.win then 32 else 0) // The shadow space on Windows comes next
+ 8 // The return address is then pushed on the stack
+ init_rsp // And we then have all the extra slots required for the Vale procedure
in
let accu' = IX64.stack_of_args max_arity (n-1) init_rsp tl accu in
let v = IX64.arg_as_nat64 hd in // We will store the arg hd
let h_final = BS.update_heap64 ptr v accu' in
stack_of_args_stack_args'_aux max_arity (n-1) (n-1) tl init_rsp accu' v;
Vale.Arch.MachineHeap.correct_update_get64 ptr v accu';
BS.update_heap64_reveal ()
)
in aux args (Map.const_on Set.empty 0)
#pop-options
#reset-options "--z3rlimit 40"
let core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let init_rsp = IA.init_regs MS.rRsp in
let stack = Map.const_on Set.empty 0 in
let stack_map = IX64.stack_of_args max_arity (List.Tot.length args) init_rsp args stack in
let stack_f = BS.Machine_stack init_rsp stack_map in
let rec aux (accu:IX64.arg_list{List.length accu <= List.length args}) : Lemma
(requires
stack_args' max_arity (List.length accu) accu init_rsp stack_map)
(ensures LSig.stack_args max_arity (List.length accu) accu va_s)
(decreases (List.length accu))
=
match accu with
| [] -> ()
| hd::tl ->
aux tl;
let i = List.length accu in
if i <= max_arity then ()
else (
let ptr =
((i - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ init_rsp
in
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal stack_f;
SI.lemma_valid_taint_stack64_reveal ptr MS.Public va_s.VS.vs_stackTaint;
let aux2 () : Lemma (IX64.arg_as_nat64 hd == LSig.arg_as_nat64 hd va_s) =
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args h0
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args h0
| _ -> ()
in aux2()
)
in
stack_of_args_stack_args' max_arity (List.length args) args init_rsp;
aux args
let core_create_lemma
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s /\
LSig.mem_correspondence args h0 va_s /\
VSig.disjoint_or_eq args /\
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap) /\
LSig.vale_pre_hyp #max_arity #arg_reg args va_s /\
ST.equal_domains h0 (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap))
))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let t_state = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let t_stack = t_state.BS.ms_stack in
core_create_lemma_mem_correspondance #max_arity #arg_reg args h0;
core_create_lemma_disjointness args;
core_create_lemma_readable #max_arity #arg_reg args h0;
core_create_lemma_register_args #max_arity #arg_reg args h0;
core_create_lemma_stack_args #max_arity #arg_reg args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal t_stack;
Vale.AsLowStar.MemoryHelpers.core_create_lemma_taint_hyp #max_arity #arg_reg args h0;
core_create_lemma_state #max_arity #arg_reg args h0
let eval_code_ts (c:BS.code)
(s0:BS.machine_state)
(f0:nat)
(s1:BS.machine_state) : Type0 =
VL.state_eq_opt true (BS.machine_eval_code c f0 s0) (Some s1)
let eval_code_rel (c:BS.code)
(va_s0 va_s1:V.va_state) (f:V.va_fuel)
: Lemma
(requires (V.eval_code c va_s0 f va_s1))
(ensures (eval_code_ts c (SL.state_to_S va_s0) (coerce f) (SL.state_to_S va_s1)))
= Vale.AsLowStar.MemoryHelpers.decls_eval_code_reveal c va_s0 va_s1 f | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | args: Prims.list Vale.Interop.Base.arg -> va_s: Vale.X64.Decls.va_state
-> FStar.Pervasives.Lemma
(ensures
Vale.AsLowStar.LowStarSig.mem_correspondence args
(Vale.Interop.Heap_s.hs_of_mem (Vale.X64.MemoryAdapters.as_mem (Mkvale_full_heap?.vf_heap (Mkvale_state?.vs_heap
va_s))))
va_s) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.list",
"Vale.Interop.Base.arg",
"Vale.X64.Decls.va_state",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal2",
"Vale.Interop.Base.TD_ImmBuffer",
"Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal2",
"Prims.dtuple2",
"Vale.Interop.Base.td",
"Prims.unit",
"Vale.AsLowStar.Wrapper.mem_correspondence_refl",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.X64.MemoryAdapters.as_mem",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap",
"Vale.X64.State.__proj__Mkvale_state__item__vs_heap",
"Prims.l_True",
"Prims.squash",
"Vale.AsLowStar.LowStarSig.mem_correspondence",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec mem_correspondence_refl (args: list arg) (va_s: V.va_state)
: Lemma (ensures LSig.mem_correspondence args (hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap)) va_s) =
| let h = hs_of_mem (as_mem va_s.VS.vs_heap.vf_heap) in
match args with
| [] -> ()
| hd :: tl ->
mem_correspondence_refl tl va_s;
match hd with
| (| TD_Buffer src bt _ , x |) -> Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal2 src bt x va_s
| (| TD_ImmBuffer src bt _ , x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal2 src bt x va_s
| _ -> () | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.core_create_lemma_mem_correspondance | val core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s)) | val core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s)) | let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 193,
"start_col": 0,
"start_line": 160
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
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.mem_correspondence args h0 va_s)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"Prims.unit",
"FStar.BigOps.big_and'_forall",
"Vale.Interop.Base.arg",
"Vale.Interop.Base.live_arg",
"Prims.list",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Prims.squash",
"Vale.AsLowStar.LowStarSig.mem_correspondence",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.BufferView.Up.as_seq",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.mk_buffer",
"FStar.UInt8.t",
"Vale.AsLowStar.LowStarSig.view_of_base_typ",
"LowStar.BufferView.Down.length_eq",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"LowStar.Buffer.trivial_preorder",
"Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal",
"Vale.Interop.Base.TD_ImmBuffer",
"LowStar.ImmutableBuffer.immutable_preorder",
"Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal",
"Vale.Interop.Base.valid_base_type",
"Vale.Interop.Base.TD_Base",
"Vale.X64.Decls.vale_state_with_inv",
"Vale.AsLowStar.LowStarSig.create_initial_vale_state",
"Prims.l_True"
] | [] | false | false | true | false | false | let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s)) =
| let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu: list arg)
: Lemma (requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd :: tl ->
aux tl;
match hd with
| (| TD_Buffer src bt _ , x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _ , x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _ , _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.core_create_lemma_stack_args | val core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s)) | val core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s)) | let core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let init_rsp = IA.init_regs MS.rRsp in
let stack = Map.const_on Set.empty 0 in
let stack_map = IX64.stack_of_args max_arity (List.Tot.length args) init_rsp args stack in
let stack_f = BS.Machine_stack init_rsp stack_map in
let rec aux (accu:IX64.arg_list{List.length accu <= List.length args}) : Lemma
(requires
stack_args' max_arity (List.length accu) accu init_rsp stack_map)
(ensures LSig.stack_args max_arity (List.length accu) accu va_s)
(decreases (List.length accu))
=
match accu with
| [] -> ()
| hd::tl ->
aux tl;
let i = List.length accu in
if i <= max_arity then ()
else (
let ptr =
((i - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ init_rsp
in
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal stack_f;
SI.lemma_valid_taint_stack64_reveal ptr MS.Public va_s.VS.vs_stackTaint;
let aux2 () : Lemma (IX64.arg_as_nat64 hd == LSig.arg_as_nat64 hd va_s) =
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args h0
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args h0
| _ -> ()
in aux2()
)
in
stack_of_args_stack_args' max_arity (List.length args) args init_rsp;
aux args | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 470,
"start_col": 0,
"start_line": 425
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd)
let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal ()
let frame_update_valid_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let rec stack_of_args_stack_args'_aux
(max_arity:nat)
(n_init:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
(v:MS.nat64)
: Lemma
(requires stack_args' max_arity n args rsp stack /\ n_init >= n)
(ensures
(let ptr = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
stack_args' max_arity n args rsp (BS.update_heap64 ptr v stack)))
= match args with
| [] -> ()
| hd::tl ->
stack_of_args_stack_args'_aux max_arity n_init (n-1) tl rsp stack v;
if n <= max_arity then ()
else (
let fixed = (n_init - max_arity) * 8 + (if IA.win then 32 else 0) + 8 + rsp in
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
calc ( <= ) {
((n - max_arity) - 1) * 8;
( <= ) { FStar.Math.Lemmas.lemma_mult_le_right 8 ((n - max_arity) - 1) (n_init - max_arity) }
(n_init - max_arity) * 8;
};
frame_update_get_heap fixed v stack ptr;
frame_update_valid_heap fixed v stack ptr
)
#push-options "--max_fuel 1 --max_ifuel 0 --z3rlimit 150 --z3refresh"
let stack_of_args_stack_args'
(max_arity:nat)
(n:nat)
(args:IX64.arg_list{List.Tot.length args = n})
(init_rsp:MS.nat64{init_rsp >= 4096}) : Lemma
(let mem = Map.const_on Set.empty 0 in
stack_args' max_arity n args init_rsp (IX64.stack_of_args max_arity n init_rsp args mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
let rec aux (args:IX64.arg_list) (accu:Map.t int Vale.Def.Words_s.nat8) : Lemma (ensures (
stack_args' max_arity (List.length args) args init_rsp
(IX64.stack_of_args max_arity (List.length args) init_rsp args accu)))
(decreases (List.length args))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128;
match args with
| [] -> ()
| hd::tl ->
aux tl accu;
let n = List.length args in
if n <= max_arity then ()
else (
let ptr = ((n - max_arity) - 1) * 8 // Arguments on the stack are pushed from right to left
+ (if IA.win then 32 else 0) // The shadow space on Windows comes next
+ 8 // The return address is then pushed on the stack
+ init_rsp // And we then have all the extra slots required for the Vale procedure
in
let accu' = IX64.stack_of_args max_arity (n-1) init_rsp tl accu in
let v = IX64.arg_as_nat64 hd in // We will store the arg hd
let h_final = BS.update_heap64 ptr v accu' in
stack_of_args_stack_args'_aux max_arity (n-1) (n-1) tl init_rsp accu' v;
Vale.Arch.MachineHeap.correct_update_get64 ptr v accu';
BS.update_heap64_reveal ()
)
in aux args (Map.const_on Set.empty 0)
#pop-options | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
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.stack_args max_arity (FStar.List.Tot.Base.length args) args va_s)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"Prims.unit",
"Vale.AsLowStar.Wrapper.stack_of_args_stack_args'",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.arg",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Vale.AsLowStar.Wrapper.stack_args'",
"Prims.squash",
"Vale.AsLowStar.LowStarSig.stack_args",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims.list",
"Prims.bool",
"Prims.l_True",
"Prims.eq2",
"Vale.Def.Words_s.nat64",
"Vale.Interop.X64.arg_as_nat64",
"Vale.AsLowStar.LowStarSig.arg_as_nat64",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal",
"Vale.Interop.Base.TD_ImmBuffer",
"Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal",
"Prims.dtuple2",
"Vale.Interop.Base.td",
"Vale.X64.Stack_i.lemma_valid_taint_stack64_reveal",
"Vale.Arch.HeapTypes_s.Public",
"Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint",
"Vale.AsLowStar.MemoryHelpers.mk_stack_reveal",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Vale.Interop.Assumptions.win",
"Vale.X64.Machine_Semantics_s.machine_stack",
"Vale.X64.Machine_Semantics_s.Machine_stack",
"FStar.Map.t",
"Vale.Def.Words_s.nat8",
"Vale.Interop.X64.stack_of_args",
"FStar.Map.const_on",
"FStar.Set.empty",
"Vale.Interop.Assumptions.init_regs",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Decls.vale_state_with_inv",
"Vale.AsLowStar.LowStarSig.create_initial_vale_state"
] | [] | false | false | true | false | false | let core_create_lemma_stack_args
(#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.stack_args max_arity (List.length args) args va_s)) =
| let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let init_rsp = IA.init_regs MS.rRsp in
let stack = Map.const_on Set.empty 0 in
let stack_map = IX64.stack_of_args max_arity (List.Tot.length args) init_rsp args stack in
let stack_f = BS.Machine_stack init_rsp stack_map in
let rec aux (accu: IX64.arg_list{List.length accu <= List.length args})
: Lemma (requires stack_args' max_arity (List.length accu) accu init_rsp stack_map)
(ensures LSig.stack_args max_arity (List.length accu) accu va_s)
(decreases (List.length accu)) =
match accu with
| [] -> ()
| hd :: tl ->
aux tl;
let i = List.length accu in
if i <= max_arity
then ()
else
(let ptr = ((i - max_arity) - 1) * 8 + (if IA.win then 32 else 0) + 8 + init_rsp in
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal stack_f;
SI.lemma_valid_taint_stack64_reveal ptr MS.Public va_s.VS.vs_stackTaint;
let aux2 () : Lemma (IX64.arg_as_nat64 hd == LSig.arg_as_nat64 hd va_s) =
match hd with
| (| TD_Buffer src bt _ , x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args h0
| (| TD_ImmBuffer src bt _ , x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args h0
| _ -> ()
in
aux2 ())
in
stack_of_args_stack_args' max_arity (List.length args) args init_rsp;
aux args | false |
Vale.X64.Memory.fst | Vale.X64.Memory.modifies_goal_directed | val modifies_goal_directed (s:loc) (h1 h2:vale_heap) : GTot prop0 | val modifies_goal_directed (s:loc) (h1 h2:vale_heap) : GTot prop0 | let modifies_goal_directed s h1 h2 = modifies s h1 h2 | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 198,
"start_col": 0,
"start_line": 198
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Vale.X64.Memory.loc -> h1: Vale.Arch.HeapImpl.vale_heap -> h2: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Vale.Def.Prop_s.prop0 | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.X64.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.X64.Memory.modifies",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | false | false | let modifies_goal_directed s h1 h2 =
| modifies s h1 h2 | false |
Vale.X64.Memory.fst | Vale.X64.Memory.v_of_typ | val v_of_typ (t: base_typ) (v: base_typ_as_vale_type t) : base_typ_as_type t | val v_of_typ (t: base_typ) (v: base_typ_as_vale_type t) : base_typ_as_type t | let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 42,
"start_col": 0,
"start_line": 36
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.Arch.HeapTypes_s.base_typ -> v: Vale.X64.Memory.base_typ_as_vale_type t
-> Vale.Interop.Types.base_typ_as_type t | Prims.Tot | [
"total"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.X64.Memory.base_typ_as_vale_type",
"FStar.UInt8.uint_to_t",
"FStar.UInt16.uint_to_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt64.uint_to_t",
"Vale.Interop.Types.base_typ_as_type"
] | [] | false | false | false | false | false | let v_of_typ (t: base_typ) (v: base_typ_as_vale_type t) : base_typ_as_type t =
| match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.frame_update_valid_heap | val frame_update_valid_heap (ptr: int) (v: MS.nat64) (mem: BS.machine_heap) (j: int)
: Lemma (requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem)) | val frame_update_valid_heap (ptr: int) (v: MS.nat64) (mem: BS.machine_heap) (j: int)
: Lemma (requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem)) | let frame_update_valid_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem))
=
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal () | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 346,
"start_col": 0,
"start_line": 341
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd)
let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal () | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
ptr: Prims.int ->
v: Vale.X64.Machine_s.nat64 ->
mem: Vale.Arch.MachineHeap_s.machine_heap ->
j: Prims.int
-> FStar.Pervasives.Lemma (requires ptr >= j + 8)
(ensures
Vale.Arch.MachineHeap_s.valid_addr64 j mem ==
Vale.Arch.MachineHeap_s.valid_addr64 j (Vale.Arch.MachineHeap_s.update_heap64 ptr v mem)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"Vale.X64.Machine_s.nat64",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap64_reveal",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"Prims.bool",
"Vale.Arch.MachineHeap_s.valid_addr64",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Addition",
"Prims.squash",
"Prims.eq2",
"Vale.Arch.MachineHeap_s.update_heap64",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let frame_update_valid_heap (ptr: int) (v: MS.nat64) (mem: BS.machine_heap) (j: int)
: Lemma (requires ptr >= j + 8)
(ensures BS.valid_addr64 j mem == BS.valid_addr64 j (BS.update_heap64 ptr v mem)) =
| reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal () | false |
Vale.X64.Memory.fst | Vale.X64.Memory.uint_view | val uint_view (t: base_typ)
: (v: UV.view UInt8.t (IB.base_typ_as_type t) {UV.View?.n v == view_n t}) | val uint_view (t: base_typ)
: (v: UV.view UInt8.t (IB.base_typ_as_type t) {UV.View?.n v == view_n t}) | let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 70,
"start_col": 0,
"start_line": 64
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.Arch.HeapTypes_s.base_typ
-> v:
LowStar.BufferView.Up.view FStar.UInt8.t (Vale.Interop.Types.base_typ_as_type t)
{View?.n v == Vale.Interop.Types.view_n t} | Prims.Tot | [
"total"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.X64.Memory.uint8_view",
"Vale.X64.Memory.uint16_view",
"Vale.X64.Memory.uint32_view",
"Vale.X64.Memory.uint64_view",
"Vale.X64.Memory.uint128_view",
"LowStar.BufferView.Up.view",
"FStar.UInt8.t",
"Vale.Interop.Types.base_typ_as_type",
"Prims.eq2",
"Prims.pos",
"LowStar.BufferView.Up.__proj__View__item__n",
"Vale.Interop.Types.view_n"
] | [] | false | false | false | false | false | let uint_view (t: base_typ)
: (v: UV.view UInt8.t (IB.base_typ_as_type t) {UV.View?.n v == view_n t}) =
| match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view | false |
Vale.X64.Memory.fst | Vale.X64.Memory.v_to_typ | val v_to_typ (t: base_typ) (v: base_typ_as_type t) : base_typ_as_vale_type t | val v_to_typ (t: base_typ) (v: base_typ_as_type t) : base_typ_as_vale_type t | let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 50,
"start_col": 0,
"start_line": 44
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.Arch.HeapTypes_s.base_typ -> v: Vale.Interop.Types.base_typ_as_type t
-> Vale.X64.Memory.base_typ_as_vale_type t | Prims.Tot | [
"total"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Types.base_typ_as_type",
"FStar.UInt8.v",
"FStar.UInt16.v",
"FStar.UInt32.v",
"FStar.UInt64.v",
"Vale.X64.Memory.base_typ_as_vale_type"
] | [] | false | false | false | false | false | let v_to_typ (t: base_typ) (v: base_typ_as_type t) : base_typ_as_vale_type t =
| match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v | false |
Vale.X64.Memory.fst | Vale.X64.Memory.buffer_length | val buffer_length (#t:base_typ) (b:buffer t) : GTot nat | val buffer_length (#t:base_typ) (b:buffer t) : GTot nat | let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 85,
"end_line": 78,
"start_col": 0,
"start_line": 78
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Vale.X64.Memory.buffer t -> Prims.GTot Prims.nat | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.X64.Memory.buffer",
"LowStar.BufferView.Up.length",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.BufferView.Up.mk_buffer",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.X64.Memory.uint_view",
"Prims.nat"
] | [] | false | false | false | false | false | let buffer_length #t b =
| UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) | false |
Vale.X64.Memory.fst | Vale.X64.Memory.buffer_as_seq | val buffer_as_seq (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot (Seq.seq (base_typ_as_vale_type t)) | val buffer_as_seq (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot (Seq.seq (base_typ_as_vale_type t)) | let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 74,
"start_col": 0,
"start_line": 72
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: Vale.Arch.HeapImpl.vale_heap -> b: Vale.X64.Memory.buffer t
-> Prims.GTot (FStar.Seq.Base.seq (Vale.X64.Memory.base_typ_as_vale_type t)) | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.X64.Memory.buffer",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Interop.Types.base_typ_as_type",
"Vale.X64.Memory.base_typ_as_vale_type",
"Vale.X64.Memory.v_to_typ",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Up.length",
"LowStar.BufferView.Up.mk_buffer",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.X64.Memory.uint_view",
"LowStar.BufferView.Up.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.Arch.HeapImpl._ih",
"FStar.Seq.Base.seq"
] | [] | false | false | false | false | false | let buffer_as_seq #t h b =
| let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s | false |
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.scalarmult | val scalarmult: (#s: field_spec) -> scalarmult_st s True | val scalarmult: (#s: field_spec) -> scalarmult_st s True | let scalarmult #s out priv pub =
push_frame ();
let init = create (2ul `FStar.UInt32.mul` ((nlimb s) <: FStar.UInt32.t)) (limb_zero s) in
decode_point #s init pub;
montgomery_ladder #s init priv init;
encode_point #s out init;
pop_frame() | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 481,
"start_col": 0,
"start_line": 475
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1)
let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1)
inline_for_extraction noextract
val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1)
[@ Meta.Attribute.specialize ]
let decode_point #s o i =
push_frame();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x : felem s = sub o 0ul (nlimb s) in
let z : felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame()
val encode_point:
#s:field_spec
-> o:lbuffer uint8 32ul
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 i /\ disjoint o i /\
state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
as_seq h1 o == S.encodePoint (fget_x h0 i, fget_z h0 i))
[@ Meta.Attribute.specialize ]
let encode_point #s o i =
push_frame();
let x : felem s = sub i 0ul (nlimb s) in
let z : felem s = sub i (nlimb s) (nlimb s) in
let tmp = create_felem s in
let u64s = create 4ul (u64 0) in
let tmp_w = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let h0 = ST.get () in
finv tmp z tmp_w;
fmul tmp tmp x tmp_w;
let h1 = ST.get () in
assert (feval h1 tmp == S.fmul (S.fpow (feval h0 z) (pow2 255 - 21)) (feval h0 x));
assert (feval h1 tmp == S.fmul (feval h0 x) (S.fpow (feval h0 z) (pow2 255 - 21)));
store_felem u64s tmp;
let h2 = ST.get () in
assert (as_seq h2 u64s == BSeq.nat_to_intseq_le 4 (feval h1 tmp));
uints_to_bytes_le #U64 4ul o u64s;
let h3 = ST.get () in
BSeq.uints_to_bytes_le_nat_lemma #U64 #SEC 4 (feval h1 tmp);
assert (as_seq h3 o == BSeq.nat_to_bytes_le 32 (feval h1 tmp));
pop_frame()
// TODO: why re-define the signature here?
val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2))
[@ Meta.Attribute.inline_ ]
let cswap2 #s bit p0 p1 =
C.cswap2 #s bit p0 p1
val ladder_step:
#s:field_spec
-> k:scalar
-> q:point s
-> i:size_t{v i < 251}
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) = S.ladder_step (as_seq h0 k) (fget_xz h0 q) (v i)
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\
b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
#push-options "--z3rlimit 200 --fuel 0 --ifuel 1"
[@ Meta.Attribute.inline_ ]
let ladder_step #s k q i p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let swap : lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let nq = sub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 = sub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
let h0 = ST.get () in
let bit = scalar_bit k (253ul -. i) in
assert (v bit == v (S.ith_bit (as_seq h0 k) (253 - v i)));
let sw = swap.(0ul) ^. bit in
logxor_lemma1 (LSeq.index (as_seq h0 swap) 0) bit;
cswap2 #s sw nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- bit
#pop-options
#push-options "--z3rlimit 300 --fuel 1 --ifuel 1"
val ladder_step_loop:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) =
Lib.LoopCombinators.repeati 251
(S.ladder_step (as_seq h0 k) (fget_xz h0 q))
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder_step_loop #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
[@ inline_let]
let spec_fh h0 =
S.ladder_step (as_seq h0 k) (fget_x h0 q, fget_z h0 q) in
[@ inline_let]
let acc h : GTot (tuple3 S.proj_point S.proj_point uint64) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
(fget_xz h nq, fget_xz h nq_p1, LSeq.index (as_seq h bit) 0) in
[@ inline_let]
let inv h (i:nat{i <= 251}) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h /\
v (LSeq.index (as_seq h bit) 0) <= 1 /\
state_inv_t h (get_x q) /\ state_inv_t h (get_z q) /\
state_inv_t h (get_x nq) /\ state_inv_t h (get_z nq) /\
state_inv_t h (get_x nq_p1) /\ state_inv_t h (get_z nq_p1) /\
acc h == Lib.LoopCombinators.repeati i (spec_fh h0) (acc h0) in
Lib.Loops.for 0ul 251ul inv
(fun i ->
Lib.LoopCombinators.unfold_repeati 251 (spec_fh h0) (acc h0) (v i);
ladder_step #s k q i p01_tmp1_swap tmp2)
#pop-options
#push-options "--z3refresh --fuel 0 --ifuel 1 --z3rlimit 800"
val ladder0_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq ==
M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)))
[@ Meta.Attribute.inline_ ]
let ladder0_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let swap:lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
// bit 255 is 0 and bit 254 is 1
cswap2 #s (u64 1) nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- u64 1;
//Got about 1K speedup by removing 4 iterations here.
//First iteration can be skipped because top bit of scalar is 0
ladder_step_loop #s k q p01_tmp1_swap tmp2;
let sw = swap.(0ul) in
cswap2 #s sw nq nq_p1
val ladder1_:
#s:field_spec
-> p01_tmp1:lbuffer (limb s) (8ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 p01_tmp1 /\ live h0 tmp2 /\ disjoint p01_tmp1 tmp2 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1 |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == M.montgomery_ladder1_1 (fget_xz h0 nq)))
[@ Meta.Attribute.inline_ ]
let ladder1_ #s p01_tmp1 tmp2 =
let nq : point s = sub p01_tmp1 0ul (2ul *! nlimb s) in
let tmp1 = sub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) in
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) == tmp1);
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2;
point_double nq tmp1 tmp2
val ladder2_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
(let nq' = M.montgomery_ladder1_0 (as_seq h0 k) (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1) in
fget_xz h1 nq == M.montgomery_ladder1_1 nq')))
[@ Meta.Attribute.inline_ ]
let ladder2_ #s k q p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let nq : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
ladder0_ #s k q p01_tmp1_swap tmp2;
ladder1_ #s p01_tmp1 tmp2
inline_for_extraction noextract
val ladder3_:
#s:field_spec
-> q:point s
-> p01:lbuffer (limb s) (4ul *! nlimb s)
-> Stack unit
(requires fun h0 ->
live h0 q /\ live h0 p01 /\ disjoint q p01 /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01) h0 h1 /\
(let nq = gsub p01 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\
(fget_xz h1 q, fget_xz h1 nq, fget_xz h1 nq_p1) == M.montgomery_ladder1_2 (fget_x h0 q)))
let ladder3_ #s q p01 =
let p0 : point s = sub p01 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01 (2ul *! nlimb s) (2ul *! nlimb s) in
copy p1 q;
let x0 : felem s = sub p0 0ul (nlimb s) in
let z0 : felem s = sub p0 (nlimb s) (nlimb s) in
set_one x0;
set_zero z0;
let h0 = ST.get () in
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
assert (gsub p0 0ul (nlimb s) == x0);
assert (gsub p0 (nlimb s) (nlimb s) == z0);
assert (fget_x h0 p1 == fget_x h0 q);
assert (fget_z h0 p1 == 1);
assert (fget_x h0 p0 == 1);
assert (fget_z h0 p0 == 0);
assert (
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x p0) /\ state_inv_t h0 (get_z p0) /\
state_inv_t h0 (get_x p1) /\ state_inv_t h0 (get_z p1))
val ladder4_:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
fget_z h0 q == 1 /\ state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == S.montgomery_ladder (fget_x h0 q) (as_seq h0 k)))
[@ Meta.Attribute.inline_ ]
let ladder4_ #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
let p01 = sub p01_tmp1_swap 0ul (4ul *! nlimb s) in
let p0 : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let p1 : point s = sub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (4ul *! nlimb s) == p01);
assert (gsub p01 0ul (2ul *! nlimb s) == p0);
assert (gsub p01 (2ul *! nlimb s) (2ul *! nlimb s) == p1);
ladder3_ #s q p01;
ladder2_ #s k q p01_tmp1_swap tmp2;
let h1 = ST.get () in
assert (fget_xz h1 p0 == M.montgomery_ladder1 (fget_x h0 q) (as_seq h0 k));
M.lemma_montgomery_ladder (fget_x h0 q) (as_seq h0 k)
val montgomery_ladder:
#s:field_spec
-> o:point s
-> k:scalar
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 k /\ live h0 i /\
(disjoint o i \/ o == i) /\ disjoint o k /\ disjoint k i /\
fget_z h0 i == 1 /\ state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 ->
modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_xz h1 o == S.montgomery_ladder (fget_x h0 i) (as_seq h0 k))
[@ Meta.Attribute.specialize ]
let montgomery_ladder #s out key init =
push_frame();
let h0 = ST.get () in
let tmp2 = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let p01_tmp1_swap = create (8ul *! nlimb s +! 1ul) (limb_zero s) in
let p0 : point s = sub p01_tmp1_swap 0ul (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == p0);
ladder4_ #s key init p01_tmp1_swap tmp2;
copy out p0;
pop_frame ()
#pop-options
#push-options "--fuel 0 --ifuel 1 --z3rlimit 400"
inline_for_extraction noextract
let g25519_t = x:glbuffer byte_t 32ul{witnessed x (Lib.Sequence.of_list S.basepoint_list) /\ recallable x}
/// Public API
/// ==========
val scalarmult: (#s: field_spec) -> scalarmult_st s True | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Impl.Curve25519.Generic.scalarmult_st s Prims.l_True | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Curve25519.Generic.encode_point",
"Hacl.Impl.Curve25519.Generic.montgomery_ladder",
"Hacl.Impl.Curve25519.Generic.decode_point",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Hacl.Impl.Curve25519.Fields.Core.limb_zero",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let scalarmult #s out priv pub =
| push_frame ();
let init = create (2ul `FStar.UInt32.mul` ((nlimb s) <: FStar.UInt32.t)) (limb_zero s) in
decode_point #s init pub;
montgomery_ladder #s init priv init;
encode_point #s out init;
pop_frame () | false |
Vale.X64.Memory.fst | Vale.X64.Memory.valid_offset | val valid_offset : t: Vale.Arch.HeapTypes_s.base_typ ->
n: Prims.nat ->
base: Prims.nat ->
addr: Prims.int ->
i: Prims.nat
-> Prims.logical | let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 81,
"end_line": 330,
"start_col": 0,
"start_line": 329
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Vale.Arch.HeapTypes_s.base_typ ->
n: Prims.nat ->
base: Prims.nat ->
addr: Prims.int ->
i: Prims.nat
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.nat",
"Prims.int",
"Prims.l_Exists",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.op_Addition",
"Vale.X64.Memory.scale_t",
"Prims.logical"
] | [] | false | false | false | true | true | let valid_offset (t: base_typ) (n base: nat) (addr: int) (i: nat) =
| exists j. {:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr | false |
|
Vale.X64.Memory.fst | Vale.X64.Memory.scale_t | val scale_t (t: base_typ) (index: int) : int | val scale_t (t: base_typ) (index: int) : int | let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 77,
"end_line": 310,
"start_col": 7,
"start_line": 310
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.Arch.HeapTypes_s.base_typ -> index: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.X64.Memory.scale_by",
"Vale.Interop.Types.view_n"
] | [] | false | false | false | true | false | let scale_t (t: base_typ) (index: int) : int =
| scale_by (view_n t) index | false |
Vale.X64.Memory.fst | Vale.X64.Memory.modifies | val modifies (s:loc) (h1 h2:vale_heap) : GTot prop0 | val modifies (s:loc) (h1 h2:vale_heap) : GTot prop0 | let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs | {
"file_name": "vale/code/arch/x64/Vale.X64.Memory.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 90,
"start_col": 0,
"start_line": 85
} | module Vale.X64.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.X64.Machine_Semantics_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Memory.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Vale.X64.Memory.loc -> h1: Vale.Arch.HeapImpl.vale_heap -> h2: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Vale.Def.Prop_s.prop0 | Prims.GTot | [
"sometrivial"
] | [] | [
"Vale.X64.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.heaplet_id",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__heapletId",
"Prims.list",
"Vale.Interop.Types.b8",
"Prims.l_or",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Interop.Types.addr_map",
"Vale.Interop.Heap_s.mk_addr_map",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"FStar.HyperStack.ST.equal_domains",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | false | false | let modifies s h h' =
| M.modifies s (_ih h).hs (_ih h').hs /\ h.heapletId == h'.heapletId /\ (_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\ HST.equal_domains (_ih h).hs (_ih h').hs | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.frame_update_get_heap | val frame_update_get_heap (ptr: int) (v: MS.nat64) (mem: BS.machine_heap) (j: int)
: Lemma (requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem)) | val frame_update_get_heap (ptr: int) (v: MS.nat64) (mem: BS.machine_heap) (j: int)
: Lemma (requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem)) | let frame_update_get_heap (ptr:int) (v:MS.nat64) (mem:BS.machine_heap) (j:int) : Lemma
(requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem))
=
BS.get_heap_val64_reveal ();
BS.update_heap64_reveal () | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 339,
"start_col": 0,
"start_line": 334
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs
let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0
let core_create_lemma_state
(#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
fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) == SL.state_to_S va_s))
= let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let tr_s = fst (IX64.create_initial_trusted_state max_arity arg_reg args h0) in
let sl_s = SL.state_to_S va_s in
assert (tr_s.BS.ms_stackTaint == va_s.VS.vs_stackTaint);
//SL.lemma_to_ok va_s;
let aux_flag (f:MS.flag) : Lemma (tr_s.BS.ms_flags f == sl_s.BS.ms_flags f)
= ()//SL.lemma_to_flags va_s f
in
Classical.forall_intro aux_flag;
assert (FunctionalExtensionality.feq tr_s.BS.ms_flags sl_s.BS.ms_flags);
//SL.lemma_to_mem va_s;
//SL.lemma_to_stack va_s;
let aux_reg (r:MS.reg) : Lemma (tr_s.BS.ms_regs r == sl_s.BS.ms_regs r)
= ()//SL.lemma_to_reg va_s r
in
Classical.forall_intro aux_reg;
assert (FunctionalExtensionality.feq tr_s.BS.ms_regs sl_s.BS.ms_regs);
// Vale.AsLowStar.MemoryHelpers.get_heap_mk_mem_reveal args h0;
Vale.AsLowStar.MemoryHelpers.mk_stack_reveal tr_s.BS.ms_stack
let rec stack_args' (max_arity:nat)
(n:nat)
(args:list arg{List.Tot.length args = n})
(rsp:int)
(stack:Map.t int Vale.Def.Words_s.nat8)
: prop =
match args with
| [] -> True
| hd::tl ->
stack_args' max_arity (n-1) tl rsp stack /\
(if n <= max_arity then True // This arg is passed in registers
else
let ptr = ((n - max_arity) - 1) * 8
+ (if IA.win then 32 else 0)
+ 8
+ rsp
in
BS.valid_addr64 ptr stack /\
BS.get_heap_val64 ptr stack == IX64.arg_as_nat64 hd) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
ptr: Prims.int ->
v: Vale.X64.Machine_s.nat64 ->
mem: Vale.Arch.MachineHeap_s.machine_heap ->
j: Prims.int
-> FStar.Pervasives.Lemma (requires ptr >= j + 8)
(ensures
Vale.Arch.MachineHeap_s.get_heap_val64 j mem ==
Vale.Arch.MachineHeap_s.get_heap_val64 j (Vale.Arch.MachineHeap_s.update_heap64 ptr v mem)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"Vale.X64.Machine_s.nat64",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.update_heap64_reveal",
"Prims.unit",
"Vale.Arch.MachineHeap_s.get_heap_val64_reveal",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Addition",
"Prims.squash",
"Prims.eq2",
"Vale.Def.Types_s.nat64",
"Vale.Arch.MachineHeap_s.get_heap_val64",
"Vale.Arch.MachineHeap_s.update_heap64",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let frame_update_get_heap (ptr: int) (v: MS.nat64) (mem: BS.machine_heap) (j: int)
: Lemma (requires ptr >= j + 8)
(ensures BS.get_heap_val64 j mem == BS.get_heap_val64 j (BS.update_heap64 ptr v mem)) =
| BS.get_heap_val64_reveal ();
BS.update_heap64_reveal () | false |
Vale.AsLowStar.Wrapper.fst | Vale.AsLowStar.Wrapper.core_create_lemma_register_args | val core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s)) | val core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s)) | let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args:IX64.arg_list)
(s:VS.vale_state)
(args':list arg)
(h0:HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args)
= let n = List.length args in
match args with
| [] -> ()
| hd::tl -> aux tl s args' h0;
let (| tag, x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0 | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.Wrapper.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 283,
"start_col": 0,
"start_line": 245
} | module Vale.AsLowStar.Wrapper
open Vale.Arch.HeapImpl
open Vale.X64.MemoryAdapters
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module I = Vale.Interop
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module SL = Vale.X64.StateLemmas
module VL = Vale.X64.Lemmas
module ST = FStar.HyperStack.ST
open FStar.Mul
open FStar.Calc
//let lemma_create_initial_vale_state_core
// (#max_arity:nat)
// (#reg_arg:IX64.arg_reg_relation max_arity)
// (args:IX64.arg_list)
// (h0:HS.mem{mem_roots_p h0 args})
// : Lemma
// (ensures (
// let s = LSig.create_initial_vale_state #max_arity #reg_arg args h0 in
// hs_of_mem (as_mem s.VS.vs_heap.vf_heap) == h0
// ))
// = ()
#reset-options "--initial_ifuel 2 --max_ifuel 2"
let rec core_create_lemma_disjointness
(args:list arg{disjoint_or_eq args})
: Lemma
(ensures VSig.disjoint_or_eq args)
= match args with
| [] -> ()
| hd::tl ->
disjoint_or_eq_cons hd tl;
BigOps.pairwise_and'_cons VSig.disjoint_or_eq_1 hd tl;
core_create_lemma_disjointness tl;
assert (VSig.disjoint_or_eq tl);
let rec aux (n:list arg)
: Lemma (requires (BigOps.big_and' (disjoint_or_eq_1 hd) n))
(ensures (BigOps.big_and' (VSig.disjoint_or_eq_1 hd) n)) =
match n with
| [] -> ()
| n::ns ->
BigOps.big_and'_cons (disjoint_or_eq_1 hd) n ns;
BigOps.big_and'_cons (VSig.disjoint_or_eq_1 hd) n ns;
aux ns
in
aux tl
#reset-options
#push-options "--z3rlimit 40 --fuel 1 --ifuel 2"
let rec args_b8_lemma (args:list arg) (x:arg)
: Lemma
(List.memP x args ==>
(match x with
| (| TD_Buffer src bt _, x |) -> List.memP (mut_to_b8 src x) (args_b8 args)
| (| TD_ImmBuffer src bt _, x |) -> List.memP (imm_to_b8 src x) (args_b8 args)
| _ -> True))
= match args with
| [] -> ()
| a::q ->
assert (List.memP x q ==> List.memP x args);
args_b8_lemma q x
#pop-options
let readable_cons (hd:arg) (tl:list arg) (s:ME.vale_heap)
: Lemma VSig.(readable (hd::tl) s <==> (readable_one s hd /\ readable tl s))
= BigOps.big_and'_cons VSig.(readable_one s) hd tl
let arg_is_registered_root (h:ME.vale_heap) (a:arg) =
match a with
| (| TD_Buffer src bt _, x |) ->
List.memP (mut_to_b8 src x) (ptrs_of_mem (as_mem h))
| (| TD_ImmBuffer src bt _, x |) ->
List.memP (imm_to_b8 src x) (ptrs_of_mem (as_mem h))
| _ -> true
#set-options "--z3rlimit 20"
let core_create_lemma_readable
(#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
VSig.readable args (ME.get_vale_heap va_s.VS.vs_heap)))
=
let readable_registered_one (a:arg) (h:ME.vale_heap)
: Lemma VSig.(arg_is_registered_root h a <==> readable_one h a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_readable #src #bt x h;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal src bt x
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.reveal_imm_readable #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
in
let rec readable_registered_all
(args:list arg)
(h:ME.vale_heap {forall x. List.memP x args ==> arg_is_registered_root h x})
: Lemma VSig.(readable args h)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
readable_registered_one hd h;
readable_registered_all tl h
in
let readable_mk_mem
(args:list arg)
(h:mem_roots args)
: Lemma
(let mem = mk_mem args h in
VSig.readable args (create_initial_vale_heap mem))
= let mem = mk_mem args h in
FStar.Classical.forall_intro (FStar.Classical.move_requires (args_b8_lemma args));
readable_registered_all args (create_initial_vale_heap mem)
in
readable_mk_mem args h0
let readable_live_one (h:ME.vale_heap) (a:arg)
: Lemma (VSig.readable_one h a ==>
live_arg (hs_of_mem (as_mem h)) a)
= match a with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_live #src #bt x h
| (| TD_ImmBuffer src bt ig, x |) ->
Vale.AsLowStar.MemoryHelpers.readable_imm_live #src #bt x h;
assert_norm (ME.buffer_readable h (as_vale_immbuffer #src #bt x) <==>
VSig.readable_one h (| TD_ImmBuffer src bt ig, x |))
| (| TD_Base _, _ |) -> ()
let rec readable_all_live (h:ME.vale_heap) (args:list arg)
: Lemma (VSig.readable args h ==>
all_live (hs_of_mem (as_mem h)) args)
= match args with
| [] -> ()
| hd::tl ->
readable_cons hd tl h;
all_live_cons hd tl (hs_of_mem (as_mem h));
readable_live_one h hd;
readable_all_live h tl
let core_create_lemma_mem_correspondance
(#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.mem_correspondence args h0 va_s))
=
let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let rec aux (accu:list arg) : Lemma
(requires (forall x. List.memP x accu ==> (live_arg h0 x)))
(ensures LSig.mem_correspondence accu h0 va_s) =
match accu with
| [] -> ()
| hd::tl -> aux tl;
match hd with
| (| TD_Buffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.buffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_ImmBuffer src bt _, x |) ->
Vale.AsLowStar.MemoryHelpers.immbuffer_as_seq_reveal src bt x args h0;
let db = get_downview x in
DV.length_eq db;
let ub = UV.mk_buffer db (LSig.view_of_base_typ bt) in
assert (Seq.equal (UV.as_seq h0 ub) (UV.as_seq h0 ub))
| (| TD_Base _, _ |) -> ()
in
BigOps.big_and'_forall (live_arg h0) args;
aux args
let rec register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs:IX64.registers)
: prop
= match args with
| [] -> True
| hd::tl ->
register_args' max_arity arg_reg (n - 1) tl regs /\
(if n > max_arity then True
else regs (arg_reg.IX64.of_arg (n - 1)) == IX64.arg_as_nat64 hd)
let rec lemma_register_args'_aux
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(n:nat)
(args:list arg{List.length args = n})
(regs1 regs2:IX64.registers)
: Lemma
(requires
register_args' max_arity arg_reg n args regs1 /\
(forall r. (forall (i:IX64.reg_nat max_arity{i >= n}). r <> (arg_reg.IX64.of_arg i)) /\
r <> MS.rRsp ==>
regs1 r == regs2 r))
(ensures register_args' max_arity arg_reg n args regs2)
= match args with
| [] -> ()
| hd::tl ->
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs1 regs2
let rec lemma_register_args'
(max_arity:nat)
(arg_reg:IX64.arg_reg_relation max_arity)
(args:IX64.arg_list)
(regs:IX64.registers)
: Lemma
(ensures
(let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
register_args' max_arity arg_reg (List.length args) args final_regs))
= let final_regs = IX64.register_of_args max_arity arg_reg (List.length args) args regs in
match args with
| [] -> ()
| hd::tl ->
let n = List.length args in
let regs' = (IX64.register_of_args max_arity arg_reg (n-1) tl regs) in
lemma_register_args' max_arity arg_reg tl regs;
lemma_register_args'_aux max_arity arg_reg (n-1) tl regs' final_regs | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Lemmas.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AsLowStar.Wrapper.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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",
"short_module": "I"
},
{
"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_i",
"short_module": "SI"
},
{
"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.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"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
}
] | {
"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"
} | false |
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.register_args max_arity
arg_reg
(FStar.List.Tot.Base.length args)
args
va_s)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Interop.X64.arg_reg_relation",
"Vale.Interop.X64.arg_list",
"FStar.Monotonic.HyperStack.mem",
"Vale.Interop.Base.mem_roots_p",
"Vale.X64.State.vale_state",
"Prims.list",
"Vale.Interop.Base.arg",
"Prims.unit",
"Prims.l_and",
"Prims.l_Forall",
"Vale.X64.Machine_s.reg_64",
"Prims.eq2",
"Vale.X64.Memory.nat64",
"Vale.X64.State.eval_reg_64",
"Vale.AsLowStar.Wrapper.register_args'",
"FStar.List.Tot.Base.length",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap",
"Vale.X64.State.__proj__Mkvale_state__item__vs_heap",
"Vale.X64.MemoryAdapters.create_initial_vale_heap",
"Vale.Interop.Base.mk_mem",
"Prims.squash",
"Vale.AsLowStar.LowStarSig.register_args",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Interop.Base.td",
"Vale.Interop.Base.td_as_type",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal",
"Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal",
"Vale.Interop.Base.valid_base_type",
"Prims._assert",
"Vale.AsLowStar.Wrapper.lemma_register_args'_aux",
"FStar.FunctionalExtensionality.restricted_t",
"Vale.Def.Words_s.nat64",
"FStar.FunctionalExtensionality.on",
"Vale.AsLowStar.Wrapper.lemma_register_args'",
"Vale.Interop.Assumptions.init_regs",
"Vale.Interop.X64.registers",
"Vale.Interop.X64.register_of_args",
"Vale.X64.Decls.vale_state_with_inv",
"Vale.AsLowStar.LowStarSig.create_initial_vale_state",
"Prims.l_True"
] | [] | false | false | true | false | false | let core_create_lemma_register_args
(#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.register_args max_arity arg_reg (List.length args) args va_s)) =
| let va_s = LSig.create_initial_vale_state #max_arity #arg_reg args h0 in
let regs' = IX64.register_of_args max_arity arg_reg (List.Tot.length args) args IA.init_regs in
lemma_register_args' max_arity arg_reg args IA.init_regs;
let open MS in
let regs = FunctionalExtensionality.on reg_64 regs' in
lemma_register_args'_aux max_arity arg_reg (List.length args) args regs' regs;
assert (register_args' max_arity arg_reg (List.length args) args regs);
let rec aux
(args: IX64.arg_list)
(s: VS.vale_state)
(args': list arg)
(h0: HS.mem{mem_roots_p h0 args'})
: Lemma
(requires
(forall r. VS.eval_reg_64 r s == regs r) /\
register_args' max_arity arg_reg (List.length args) args regs /\
s.VS.vs_heap.vf_heap == create_initial_vale_heap (mk_mem args' h0))
(ensures LSig.register_args max_arity arg_reg (List.length args) args s)
(decreases args) =
let n = List.length args in
match args with
| [] -> ()
| hd :: tl ->
aux tl s args' h0;
let (| tag , x |) = hd in
match tag with
| TD_Buffer src bt _ -> Vale.AsLowStar.MemoryHelpers.buffer_addr_reveal src bt x args' h0
| TD_ImmBuffer src bt _ -> Vale.AsLowStar.MemoryHelpers.immbuffer_addr_reveal src bt x args' h0
| TD_Base _ -> ()
in
aux args va_s args h0 | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.