effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"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.Arch.MachineHeap_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.PPC64LE.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.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet) | let valid_layout_data_buffer
(t: base_typ)
(b: buffer t)
(layout: vale_heap_layout_inner)
(hid: heaplet_id)
(write: bool)
= | false | null | false | exists (n: nat). {:pattern (Seq.index layout.vl_buffers n)}
n < Seq.length layout.vl_buffers /\
(let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\ b == bi.bi_buffer /\ (write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"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.MachineHeap_s.fst.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.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Vale.Arch.HeapImpl.vale_heap_layout_inner",
"Vale.Arch.HeapImpl.heaplet_id",
"Prims.bool",
"Prims.l_Exists",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Arch.HeapImpl.buffer_info",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_buffers",
"Prims.eq2",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_typ",
"Vale.Interop.Types.b8",
"Prims.l_or",
"Prims.int",
"Prims.op_Modulus",
"LowStar.BufferView.Down.length",
"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.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.Interop.Types.view_n",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_buffer",
"Prims.l_imp",
"Vale.Arch.HeapImpl.mutability",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_mutable",
"Vale.Arch.HeapImpl.Mutable",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_heaplet",
"FStar.Seq.Base.index",
"Prims.logical"
] | [] | module Vale.PPC64LE.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.Arch.MachineHeap_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
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
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b) | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_layout_data_buffer : t: Vale.Arch.HeapTypes_s.base_typ ->
b: Vale.PPC64LE.Memory.buffer t ->
layout: Vale.Arch.HeapImpl.vale_heap_layout_inner ->
hid: Vale.Arch.HeapImpl.heaplet_id ->
write: Prims.bool
-> Prims.logical | [] | Vale.PPC64LE.Memory.valid_layout_data_buffer | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
b: Vale.PPC64LE.Memory.buffer t ->
layout: Vale.Arch.HeapImpl.vale_heap_layout_inner ->
hid: Vale.Arch.HeapImpl.heaplet_id ->
write: Prims.bool
-> Prims.logical | {
"end_col": 25,
"end_line": 685,
"start_col": 2,
"start_line": 680
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let suffix (a: keccak_alg) = if is_shake a then byte 0x1f else byte 0x06 | let suffix (a: keccak_alg) = | false | null | false | if is_shake a then byte 0x1f else byte 0x06 | {
"checked_file": "Spec.SHA3.Incremental.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA3.Incremental.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.keccak_alg",
"Spec.Hash.Definitions.is_shake",
"Lib.IntTypes.byte",
"Prims.bool",
"Lib.IntTypes.byte_t",
"Prims.l_or",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.U8",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB"
] | [] | module Spec.SHA3.Incremental
module S = FStar.Seq
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.Hash
open FStar.Mul
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
open Lib.IntTypes
#set-options "--fuel 0 --ifuel 0 --z3rlimit 200"
let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a/8) inp s == update_multi a s () inp)
= let rateInBytes = rate a/8 in
let f = Spec.SHA3.absorb_inner rateInBytes in
let bs = block_length a in
let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in
assert (bs == rateInBytes);
calc (==) {
update_multi a s () inp;
(==) { }
Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s;
(==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s }
(let len = S.length inp in
let nb = len / bs in
Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s);
(==) {
Loops.unfold_repeati 1 f' s 0;
Loops.eq_repeati0 1 f' s }
f' 0 s;
(==) { assert (Seq.slice inp (0 * bs) (0 * bs + bs) `S.equal` inp) }
f inp s;
} | false | false | Spec.SHA3.Incremental.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val suffix : a: Spec.Hash.Definitions.keccak_alg
-> b: Lib.IntTypes.byte_t{Lib.IntTypes.v b == 0x1f \/ Lib.IntTypes.v b == 0x06} | [] | Spec.SHA3.Incremental.suffix | {
"file_name": "specs/lemmas/Spec.SHA3.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.keccak_alg
-> b: Lib.IntTypes.byte_t{Lib.IntTypes.v b == 0x1f \/ Lib.IntTypes.v b == 0x06} | {
"end_col": 72,
"end_line": 43,
"start_col": 29,
"start_line": 43
} |
|
FStar.Pervasives.Lemma | val update_is_update_multi
(a: keccak_alg)
(inp: bytes{S.length inp == block_length a})
(s: words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a / 8) inp s == update_multi a s () inp) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a/8) inp s == update_multi a s () inp)
= let rateInBytes = rate a/8 in
let f = Spec.SHA3.absorb_inner rateInBytes in
let bs = block_length a in
let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in
assert (bs == rateInBytes);
calc (==) {
update_multi a s () inp;
(==) { }
Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s;
(==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s }
(let len = S.length inp in
let nb = len / bs in
Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s);
(==) {
Loops.unfold_repeati 1 f' s 0;
Loops.eq_repeati0 1 f' s }
f' 0 s;
(==) { assert (Seq.slice inp (0 * bs) (0 * bs + bs) `S.equal` inp) }
f inp s;
} | val update_is_update_multi
(a: keccak_alg)
(inp: bytes{S.length inp == block_length a})
(s: words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a / 8) inp s == update_multi a s () inp)
let update_is_update_multi
(a: keccak_alg)
(inp: bytes{S.length inp == block_length a})
(s: words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a / 8) inp s == update_multi a s () inp) = | false | null | true | let rateInBytes = rate a / 8 in
let f = Spec.SHA3.absorb_inner rateInBytes in
let bs = block_length a in
let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in
assert (bs == rateInBytes);
calc ( == ) {
update_multi a s () inp;
( == ) { () }
Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s;
( == ) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s }
(let len = S.length inp in
let nb = len / bs in
Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s);
( == ) { (Loops.unfold_repeati 1 f' s 0;
Loops.eq_repeati0 1 f' s) }
f' 0 s;
( == ) { assert ((Seq.slice inp (0 * bs) (0 * bs + bs)) `S.equal` inp) }
f inp s;
} | {
"checked_file": "Spec.SHA3.Incremental.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA3.Incremental.fst"
} | [
"lemma"
] | [
"Spec.Hash.Definitions.keccak_alg",
"Spec.Hash.Definitions.bytes",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.block_length",
"Spec.Hash.Definitions.words_state",
"FStar.Calc.calc_finish",
"Spec.Agile.Hash.update_multi",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Lib.LoopCombinators.repeati",
"Lib.Sequence.repeat_blocks_f",
"Spec.SHA3.state",
"Prims.op_Division",
"Prims.nat",
"Lib.Sequence.repeat_blocks_multi",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Lib.Sequence.lemma_repeat_blocks_multi",
"Lib.LoopCombinators.eq_repeati0",
"Lib.LoopCombinators.unfold_repeati",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.slice",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.nonzero",
"Lib.IntTypes.U8",
"Spec.SHA3.absorb_inner",
"Spec.Hash.Definitions.rate",
"Prims.l_True",
"Lib.Sequence.seq",
"Lib.IntTypes.uint64",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.state_word_length",
"FStar.Pervasives.pattern"
] | [] | module Spec.SHA3.Incremental
module S = FStar.Seq
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.Hash
open FStar.Mul
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
open Lib.IntTypes
#set-options "--fuel 0 --ifuel 0 --z3rlimit 200"
let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a) | false | false | Spec.SHA3.Incremental.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_is_update_multi
(a: keccak_alg)
(inp: bytes{S.length inp == block_length a})
(s: words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a / 8) inp s == update_multi a s () inp) | [] | Spec.SHA3.Incremental.update_is_update_multi | {
"file_name": "specs/lemmas/Spec.SHA3.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.keccak_alg ->
inp:
Spec.Hash.Definitions.bytes{FStar.Seq.Base.length inp == Spec.Hash.Definitions.block_length a} ->
s: Spec.Hash.Definitions.words_state a
-> FStar.Pervasives.Lemma
(ensures
Spec.SHA3.absorb_inner (Spec.Hash.Definitions.rate a / 8) inp s ==
Spec.Agile.Hash.update_multi a s () inp) | {
"end_col": 5,
"end_line": 41,
"start_col": 3,
"start_line": 22
} |
FStar.Pervasives.Lemma | val sha3_is_incremental
(a: keccak_alg)
(input: bytes)
(l: output_length a): Lemma (hash_incremental a input l `S.equal` hash' a input l) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha3_is_incremental
(a: keccak_alg)
(input: bytes) (out_length: output_length a):
Lemma (hash_incremental a input out_length `S.equal` hash' a input out_length)
=
calc (S.equal) {
hash_incremental a input out_length;
(S.equal) { sha3_is_incremental1 a input out_length } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length);
(S.equal) { sha3_is_incremental2 a input out_length }
hash' a input out_length;
} | val sha3_is_incremental
(a: keccak_alg)
(input: bytes)
(l: output_length a): Lemma (hash_incremental a input l `S.equal` hash' a input l)
let sha3_is_incremental (a: keccak_alg) (input: bytes) (out_length: output_length a)
: Lemma ((hash_incremental a input out_length) `S.equal` (hash' a input out_length)) = | false | null | true | calc (S.equal) {
hash_incremental a input out_length;
(S.equal) { sha3_is_incremental1 a input out_length }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length);
(S.equal) { sha3_is_incremental2 a input out_length }
hash' a input out_length;
} | {
"checked_file": "Spec.SHA3.Incremental.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA3.Incremental.fst"
} | [
"lemma"
] | [
"Spec.Hash.Definitions.keccak_alg",
"Spec.Hash.Definitions.bytes",
"Spec.Hash.Definitions.output_length",
"FStar.Calc.calc_finish",
"FStar.Seq.Base.seq",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.Seq.Base.equal",
"Spec.Hash.Incremental.Definitions.hash_incremental",
"Spec.Agile.Hash.hash'",
"Prims.Cons",
"FStar.Preorder.relation",
"Lib.IntTypes.uint8",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Lib.UpdateMulti.uint8",
"Spec.Agile.Hash.finish",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Spec.SHA3.absorb_last",
"FStar.Seq.Base.length",
"Spec.Hash.Definitions.words_state",
"Spec.Agile.Hash.update_multi",
"FStar.Pervasives.Native.tuple2",
"Lib.UpdateMulti.split_at_last",
"Lib.IntTypes.PUB",
"Prims.l_or",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Spec.SHA3.Incremental.suffix",
"Prims.op_Division",
"Spec.Hash.Definitions.rate",
"Spec.Hash.Definitions.word",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Lib.Sequence.index",
"Lib.Sequence.create",
"Lib.IntTypes.u64",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Spec.SHA3.Incremental.sha3_is_incremental1",
"Prims.squash",
"Spec.SHA3.Incremental.sha3_is_incremental2",
"Prims.l_True",
"FStar.Pervasives.pattern"
] | [] | module Spec.SHA3.Incremental
module S = FStar.Seq
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.Hash
open FStar.Mul
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
open Lib.IntTypes
#set-options "--fuel 0 --ifuel 0 --z3rlimit 200"
let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a/8) inp s == update_multi a s () inp)
= let rateInBytes = rate a/8 in
let f = Spec.SHA3.absorb_inner rateInBytes in
let bs = block_length a in
let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in
assert (bs == rateInBytes);
calc (==) {
update_multi a s () inp;
(==) { }
Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s;
(==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s }
(let len = S.length inp in
let nb = len / bs in
Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s);
(==) {
Loops.unfold_repeati 1 f' s 0;
Loops.eq_repeati0 1 f' s }
f' 0 s;
(==) { assert (Seq.slice inp (0 * bs) (0 * bs + bs) `S.equal` inp) }
f inp s;
}
let suffix (a: keccak_alg) = if is_shake a then byte 0x1f else byte 0x06
val sha3_is_incremental1
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length))
let sha3_is_incremental1 a input out_length =
calc (==) {
hash_incremental a input out_length;
(==) { }
(let s = init a in
let bs, l = split_blocks a input in
let s = update_multi a s () bs in
let s = update_last a s () l in
finish a s out_length);
(==) { }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a/8 in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
let s = update_multi a s () bs in
let s = update_last a s () l in
finish a s out_length);
(==) { } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_inner rateInBytes l s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(==) { (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
update_is_update_multi a l s
else ()
) } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
let s = update_multi a s () l in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(==) { (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
Lib.Sequence.Lemmas.repeat_blocks_multi_split (block_length a) (S.length bs) (bs `S.append` l) (Spec.SHA3.absorb_inner rateInBytes) s
else () ) } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () (bs `S.append` l) in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
};
calc (S.equal) {
(
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () (bs `S.append` l) in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(S.equal) {
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
let s = update_multi a s () bs in
if S.length l = rateInBytes then begin
let bs', l' = UpdateMulti.split_at_last rateInBytes input in
// TODO: strengthen this... NL arith!
assert (bs' `S.equal` (bs `S.append` l));
assert (l' `S.equal` S.empty)
end else
()
} (
let s = Lib.Sequence.create 25 (u64 0) in
// Also the block size
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
}
let sha3_is_incremental2
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash' a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length))
= let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let nb = S.length input / block_length a in
let s = Lib.Sequence.create 25 (u64 0) in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
assert (S.length bs / block_length a == nb);
let f = Spec.SHA3.absorb_inner rateInBytes in
calc (==) {
hash' a input out_length;
(==) { } (
let s = Spec.SHA3.absorb s rateInBytes (S.length input) input delimitedSuffix in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)
);
(==) { Lib.Sequence.lemma_repeat_blocks (block_length a) input f (Spec.SHA3.absorb_last delimitedSuffix rateInBytes) s } (
let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
(==) {
Lib.Sequence.Lemmas.repeati_extensionality #(words_state a) nb
(Lib.Sequence.repeat_blocks_f (block_length a) input f nb)
(Lib.Sequence.repeat_blocks_f (block_length a) bs f nb)
s
} (
let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
(==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s } (
let s = Lib.Sequence.repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
}
let sha3_is_incremental
(a: keccak_alg)
(input: bytes) (out_length: output_length a):
Lemma (hash_incremental a input out_length `S.equal` hash' a input out_length) | false | false | Spec.SHA3.Incremental.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha3_is_incremental
(a: keccak_alg)
(input: bytes)
(l: output_length a): Lemma (hash_incremental a input l `S.equal` hash' a input l) | [] | Spec.SHA3.Incremental.sha3_is_incremental | {
"file_name": "specs/lemmas/Spec.SHA3.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.keccak_alg ->
input: Spec.Hash.Definitions.bytes ->
l: Spec.Hash.Definitions.output_length a
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (Spec.Hash.Incremental.Definitions.hash_incremental a input l)
(Spec.Agile.Hash.hash' a input l)) | {
"end_col": 3,
"end_line": 232,
"start_col": 2,
"start_line": 220
} |
FStar.Pervasives.Lemma | val sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a)
: Lemma
((hash' a input out_length)
`S.equal`
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length)) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha3_is_incremental2
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash' a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length))
= let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let nb = S.length input / block_length a in
let s = Lib.Sequence.create 25 (u64 0) in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
assert (S.length bs / block_length a == nb);
let f = Spec.SHA3.absorb_inner rateInBytes in
calc (==) {
hash' a input out_length;
(==) { } (
let s = Spec.SHA3.absorb s rateInBytes (S.length input) input delimitedSuffix in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)
);
(==) { Lib.Sequence.lemma_repeat_blocks (block_length a) input f (Spec.SHA3.absorb_last delimitedSuffix rateInBytes) s } (
let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
(==) {
Lib.Sequence.Lemmas.repeati_extensionality #(words_state a) nb
(Lib.Sequence.repeat_blocks_f (block_length a) input f nb)
(Lib.Sequence.repeat_blocks_f (block_length a) bs f nb)
s
} (
let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
(==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s } (
let s = Lib.Sequence.repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
} | val sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a)
: Lemma
((hash' a input out_length)
`S.equal`
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length))
let sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a)
: Lemma
((hash' a input out_length)
`S.equal`
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length)) = | false | null | true | let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let nb = S.length input / block_length a in
let s = Lib.Sequence.create 25 (u64 0) in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
assert (S.length bs / block_length a == nb);
let f = Spec.SHA3.absorb_inner rateInBytes in
calc ( == ) {
hash' a input out_length;
( == ) { () }
(let s = Spec.SHA3.absorb s rateInBytes (S.length input) input delimitedSuffix in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
( == ) { Lib.Sequence.lemma_repeat_blocks (block_length a)
input
f
(Spec.SHA3.absorb_last delimitedSuffix rateInBytes)
s }
(let s =
Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) s
in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
( == ) { Lib.Sequence.Lemmas.repeati_extensionality #(words_state a)
nb
(Lib.Sequence.repeat_blocks_f (block_length a) input f nb)
(Lib.Sequence.repeat_blocks_f (block_length a) bs f nb)
s }
(let s =
Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s
in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
( == ) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s }
(let s = Lib.Sequence.repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length));
} | {
"checked_file": "Spec.SHA3.Incremental.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA3.Incremental.fst"
} | [
"lemma"
] | [
"Spec.Hash.Definitions.keccak_alg",
"Spec.Hash.Definitions.bytes",
"Spec.Hash.Definitions.output_length",
"FStar.Seq.Base.seq",
"Lib.UpdateMulti.uint8",
"FStar.Calc.calc_finish",
"Lib.ByteSequence.lbytes",
"Spec.Hash.Definitions.hash_length'",
"Prims.eq2",
"Spec.Agile.Hash.hash'",
"Spec.SHA3.squeeze",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.SHA3.absorb_last",
"FStar.Seq.Base.length",
"Spec.Hash.Definitions.words_state",
"Lib.Sequence.repeat_blocks_multi",
"Spec.Hash.Definitions.block_length",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Lib.LoopCombinators.repeati",
"Lib.Sequence.repeat_blocks_f",
"Spec.SHA3.state",
"Lib.IntTypes.uint8",
"Spec.SHA3.absorb",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Lib.Sequence.lemma_repeat_blocks",
"Lib.Sequence.Lemmas.repeati_extensionality",
"Lib.Sequence.lemma_repeat_blocks_multi",
"Lib.IntTypes.U8",
"Spec.SHA3.absorb_inner",
"Prims._assert",
"Prims.int",
"Prims.op_Division",
"FStar.Pervasives.Native.tuple2",
"Lib.UpdateMulti.split_at_last",
"Spec.Hash.Definitions.word",
"Prims.l_and",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.index",
"Lib.Sequence.create",
"Lib.IntTypes.u64",
"Lib.IntTypes.PUB",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v",
"Spec.SHA3.Incremental.suffix",
"Spec.Hash.Definitions.rate",
"Prims.l_True",
"FStar.Seq.Base.equal",
"Lib.IntTypes.uint_t",
"Spec.Agile.Hash.finish",
"Spec.Agile.Hash.update_multi",
"FStar.Pervasives.pattern"
] | [] | module Spec.SHA3.Incremental
module S = FStar.Seq
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.Hash
open FStar.Mul
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
open Lib.IntTypes
#set-options "--fuel 0 --ifuel 0 --z3rlimit 200"
let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a/8) inp s == update_multi a s () inp)
= let rateInBytes = rate a/8 in
let f = Spec.SHA3.absorb_inner rateInBytes in
let bs = block_length a in
let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in
assert (bs == rateInBytes);
calc (==) {
update_multi a s () inp;
(==) { }
Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s;
(==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s }
(let len = S.length inp in
let nb = len / bs in
Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s);
(==) {
Loops.unfold_repeati 1 f' s 0;
Loops.eq_repeati0 1 f' s }
f' 0 s;
(==) { assert (Seq.slice inp (0 * bs) (0 * bs + bs) `S.equal` inp) }
f inp s;
}
let suffix (a: keccak_alg) = if is_shake a then byte 0x1f else byte 0x06
val sha3_is_incremental1
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length))
let sha3_is_incremental1 a input out_length =
calc (==) {
hash_incremental a input out_length;
(==) { }
(let s = init a in
let bs, l = split_blocks a input in
let s = update_multi a s () bs in
let s = update_last a s () l in
finish a s out_length);
(==) { }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a/8 in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
let s = update_multi a s () bs in
let s = update_last a s () l in
finish a s out_length);
(==) { } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_inner rateInBytes l s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(==) { (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
update_is_update_multi a l s
else ()
) } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
let s = update_multi a s () l in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(==) { (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
Lib.Sequence.Lemmas.repeat_blocks_multi_split (block_length a) (S.length bs) (bs `S.append` l) (Spec.SHA3.absorb_inner rateInBytes) s
else () ) } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () (bs `S.append` l) in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
};
calc (S.equal) {
(
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () (bs `S.append` l) in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(S.equal) {
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
let s = update_multi a s () bs in
if S.length l = rateInBytes then begin
let bs', l' = UpdateMulti.split_at_last rateInBytes input in
// TODO: strengthen this... NL arith!
assert (bs' `S.equal` (bs `S.append` l));
assert (l' `S.equal` S.empty)
end else
()
} (
let s = Lib.Sequence.create 25 (u64 0) in
// Also the block size
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
}
let sha3_is_incremental2
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash' a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in | false | false | Spec.SHA3.Incremental.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a)
: Lemma
((hash' a input out_length)
`S.equal`
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length)) | [] | Spec.SHA3.Incremental.sha3_is_incremental2 | {
"file_name": "specs/lemmas/Spec.SHA3.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.keccak_alg ->
input: Spec.Hash.Definitions.bytes ->
out_length: Spec.Hash.Definitions.output_length a
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (Spec.Agile.Hash.hash' a input out_length)
(let s = Lib.Sequence.create 25 (Lib.IntTypes.u64 0) in
let rateInBytes = Spec.Hash.Definitions.rate a / 8 in
let delimitedSuffix = Spec.SHA3.Incremental.suffix a in
let _ = Lib.UpdateMulti.split_at_last rateInBytes input in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ bs l = _ in
let s = Spec.Agile.Hash.update_multi a s () bs in
let s =
Spec.SHA3.absorb_last delimitedSuffix rateInBytes (FStar.Seq.Base.length l) l s
in
Spec.Agile.Hash.finish a s out_length)
<:
FStar.Seq.Base.seq (Lib.IntTypes.uint_t Lib.IntTypes.U8 Lib.IntTypes.SEC))) | {
"end_col": 5,
"end_line": 213,
"start_col": 1,
"start_line": 183
} |
FStar.Pervasives.Lemma | val sha3_is_incremental1
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length)) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha3_is_incremental1 a input out_length =
calc (==) {
hash_incremental a input out_length;
(==) { }
(let s = init a in
let bs, l = split_blocks a input in
let s = update_multi a s () bs in
let s = update_last a s () l in
finish a s out_length);
(==) { }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a/8 in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
let s = update_multi a s () bs in
let s = update_last a s () l in
finish a s out_length);
(==) { } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_inner rateInBytes l s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(==) { (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
update_is_update_multi a l s
else ()
) } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () bs in
let s = update_multi a s () l in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(==) { (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
Lib.Sequence.Lemmas.repeat_blocks_multi_split (block_length a) (S.length bs) (bs `S.append` l) (Spec.SHA3.absorb_inner rateInBytes) s
else () ) } (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () (bs `S.append` l) in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
};
calc (S.equal) {
(
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes then
let s = update_multi a s () (bs `S.append` l) in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
(S.equal) {
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
let s = update_multi a s () bs in
if S.length l = rateInBytes then begin
let bs', l' = UpdateMulti.split_at_last rateInBytes input in
// TODO: strengthen this... NL arith!
assert (bs' `S.equal` (bs `S.append` l));
assert (l' `S.equal` S.empty)
end else
()
} (
let s = Lib.Sequence.create 25 (u64 0) in
// Also the block size
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length
);
} | val sha3_is_incremental1
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length))
let sha3_is_incremental1 a input out_length = | false | null | true | calc ( == ) {
hash_incremental a input out_length;
( == ) { () }
(let s = init a in
let bs, l = split_blocks a input in
let s = update_multi a s () bs in
let s = update_last a s () l in
finish a s out_length);
( == ) { () }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
let s = update_multi a s () bs in
let s = update_last a s () l in
finish a s out_length);
( == ) { () }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes
then
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_inner rateInBytes l s in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length);
( == ) { (let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes
then
let s = update_multi a s () bs in
update_is_update_multi a l s) }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes
then
let s = update_multi a s () bs in
let s = update_multi a s () l in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length);
( == ) { (let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes
then
Lib.Sequence.Lemmas.repeat_blocks_multi_split (block_length a)
(S.length bs)
(bs `S.append` l)
(Spec.SHA3.absorb_inner rateInBytes)
s) }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes
then
let s = update_multi a s () (bs `S.append` l) in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length);
};
calc (S.equal) {
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
if S.length l = rateInBytes
then
let s = update_multi a s () (bs `S.append` l) in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in
finish a s out_length
else
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length);
(S.equal) { let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in
let s = update_multi a s () bs in
if S.length l = rateInBytes
then
let bs', l' = UpdateMulti.split_at_last rateInBytes input in
assert (bs' `S.equal` (bs `S.append` l));
assert (l' `S.equal` S.empty) }
(let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length);
} | {
"checked_file": "Spec.SHA3.Incremental.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA3.Incremental.fst"
} | [
"lemma"
] | [
"Spec.Hash.Definitions.keccak_alg",
"Spec.Hash.Definitions.bytes",
"Spec.Hash.Definitions.output_length",
"FStar.Calc.calc_finish",
"FStar.Seq.Base.seq",
"Lib.IntTypes.uint8",
"FStar.Seq.Base.equal",
"Lib.UpdateMulti.uint8",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Spec.Agile.Hash.finish",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.SHA3.absorb_last",
"FStar.Seq.Base.empty",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Spec.Hash.Definitions.words_state",
"Spec.Agile.Hash.update_multi",
"FStar.Seq.Base.append",
"Prims.bool",
"FStar.Pervasives.Native.tuple2",
"Lib.UpdateMulti.split_at_last_lazy",
"Lib.IntTypes.PUB",
"Prims.l_or",
"Prims.eq2",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Spec.SHA3.Incremental.suffix",
"Prims.op_Division",
"Spec.Hash.Definitions.rate",
"Spec.Hash.Definitions.word",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Lib.Sequence.index",
"Lib.Sequence.create",
"Lib.IntTypes.u64",
"Lib.UpdateMulti.split_at_last",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims._assert",
"Prims.squash",
"Lib.ByteSequence.bytes",
"Spec.Hash.Definitions.hash_length'",
"Spec.Hash.Incremental.Definitions.hash_incremental",
"Spec.SHA3.absorb_inner",
"Spec.Hash.Incremental.Definitions.update_last",
"Lib.Sequence.seq",
"Spec.Hash.Incremental.Definitions.split_blocks",
"Spec.Hash.Definitions.init_t",
"Spec.Agile.Hash.init",
"Spec.SHA3.Incremental.update_is_update_multi",
"Lib.Sequence.Lemmas.repeat_blocks_multi_split",
"Spec.SHA3.state",
"Spec.Hash.Definitions.block_length",
"Lib.IntTypes.uint64"
] | [] | module Spec.SHA3.Incremental
module S = FStar.Seq
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.Hash
open FStar.Mul
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
open Lib.IntTypes
#set-options "--fuel 0 --ifuel 0 --z3rlimit 200"
let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a)
: Lemma (Spec.SHA3.absorb_inner (rate a/8) inp s == update_multi a s () inp)
= let rateInBytes = rate a/8 in
let f = Spec.SHA3.absorb_inner rateInBytes in
let bs = block_length a in
let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in
assert (bs == rateInBytes);
calc (==) {
update_multi a s () inp;
(==) { }
Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s;
(==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s }
(let len = S.length inp in
let nb = len / bs in
Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s);
(==) {
Loops.unfold_repeati 1 f' s 0;
Loops.eq_repeati0 1 f' s }
f' 0 s;
(==) { assert (Seq.slice inp (0 * bs) (0 * bs + bs) `S.equal` inp) }
f inp s;
}
let suffix (a: keccak_alg) = if is_shake a then byte 0x1f else byte 0x06
val sha3_is_incremental1
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length)) | false | false | Spec.SHA3.Incremental.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sha3_is_incremental1
(a: keccak_alg)
(input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` (
let s = Lib.Sequence.create 25 (u64 0) in
let rateInBytes = rate a / 8 in
let delimitedSuffix = suffix a in
let bs, l = UpdateMulti.split_at_last rateInBytes input in
let s = update_multi a s () bs in
let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in
finish a s out_length)) | [] | Spec.SHA3.Incremental.sha3_is_incremental1 | {
"file_name": "specs/lemmas/Spec.SHA3.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.keccak_alg ->
input: Spec.Hash.Definitions.bytes ->
out_length: Spec.Hash.Definitions.output_length a
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (Spec.Hash.Incremental.Definitions.hash_incremental a input out_length)
(let s = Lib.Sequence.create 25 (Lib.IntTypes.u64 0) in
let rateInBytes = Spec.Hash.Definitions.rate a / 8 in
let delimitedSuffix = Spec.SHA3.Incremental.suffix a in
let _ = Lib.UpdateMulti.split_at_last rateInBytes input in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ bs l = _ in
let s = Spec.Agile.Hash.update_multi a s () bs in
let s =
Spec.SHA3.absorb_last delimitedSuffix rateInBytes (FStar.Seq.Base.length l) l s
in
Spec.Agile.Hash.finish a s out_length)
<:
FStar.Seq.Base.seq (Lib.IntTypes.uint_t Lib.IntTypes.U8 Lib.IntTypes.SEC))) | {
"end_col": 3,
"end_line": 171,
"start_col": 2,
"start_line": 57
} |
Prims.Tot | val va_wp_Pclmulqdq
(dst src: va_operand_xmm)
(dstHi srcHi: bool)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) | val va_wp_Pclmulqdq
(dst src: va_operand_xmm)
(dstHi srcHi: bool)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_Pclmulqdq
(dst src: va_operand_xmm)
(dstHi srcHi: bool)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t).
let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in
va_get_ok va_sM /\
va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if
dstHi
(fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst))
(fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi
(fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src))
(fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Prims.bool",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Vale.X64.Flags.t",
"Prims.l_imp",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Vale.Math.Poly2_s.mul",
"Vale.Math.Poly2.Bits_s.of_double32",
"Vale.X64.Decls.va_if",
"Vale.Def.Types_s.double32",
"Vale.Arch.Types.quad32_double_hi",
"Prims.l_not",
"Vale.Arch.Types.quad32_double_lo",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) | false | true | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_Pclmulqdq
(dst src: va_operand_xmm)
(dstHi srcHi: bool)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.X64.InsAes.va_wp_Pclmulqdq | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
dstHi: Prims.bool ->
srcHi: Prims.bool ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 86,
"end_line": 44,
"start_col": 2,
"start_line": 37
} |
Prims.Tot | val va_wp_AESNI_enc (dst src: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(()))) | val va_wp_AESNI_enc (dst src: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_AESNI_enc (dst src: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t).
let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in
va_get_ok va_sM /\
va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.aesni_enabled",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Vale.X64.Flags.t",
"Prims.l_imp",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_s.mix_columns_LE",
"Vale.AES.AES_common_s.sub_bytes",
"Vale.AES.AES_s.shift_rows_LE",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> | false | true | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_AESNI_enc (dst src: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.X64.InsAes.va_wp_AESNI_enc | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 10,
"end_line": 131,
"start_col": 2,
"start_line": 126
} |
Prims.Tot | val va_wp_AESNI_enc_last
(dst src: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) | val va_wp_AESNI_enc_last
(dst src: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_AESNI_enc_last
(dst src: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t).
let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in
va_get_ok va_sM /\
va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm
va_s0
dst)))
(va_eval_xmm va_s0 src) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.aesni_enabled",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Vale.X64.Flags.t",
"Prims.l_imp",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_common_s.sub_bytes",
"Vale.AES.AES_s.shift_rows_LE",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src))
//--
//-- VAESNI_enc
val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot
va_code
val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc
dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2))
//--
//-- AESNI_enc_last
val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq
va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state | false | true | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_AESNI_enc_last
(dst src: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.X64.InsAes.va_wp_AESNI_enc_last | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 75,
"end_line": 208,
"start_col": 2,
"start_line": 204
} |
Prims.Tot | val va_wp_VPclmulqdq
(dst src1 src2: va_operand_xmm)
(src1Hi src2Hi: bool)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (()))) | val va_wp_VPclmulqdq
(dst src1 src2: va_operand_xmm)
(src1Hi src2Hi: bool)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_VPclmulqdq
(dst src1 src2: va_operand_xmm)
(src1Hi src2Hi: bool)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(pclmulqdq_enabled /\ avx_enabled) /\
(forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t).
let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in
va_get_ok va_sM /\
va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if
src1Hi
(fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1))
(fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi
(fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2))
(fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Prims.bool",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"Vale.X64.CPU_Features_s.avx_enabled",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Vale.X64.Flags.t",
"Prims.l_imp",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Vale.Math.Poly2_s.mul",
"Vale.Math.Poly2.Bits_s.of_double32",
"Vale.X64.Decls.va_if",
"Vale.Def.Types_s.double32",
"Vale.Arch.Types.quad32_double_hi",
"Prims.l_not",
"Vale.Arch.Types.quad32_double_lo",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) | false | true | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_VPclmulqdq
(dst src1 src2: va_operand_xmm)
(src1Hi src2Hi: bool)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.X64.InsAes.va_wp_VPclmulqdq | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src1: Vale.X64.Decls.va_operand_xmm ->
src2: Vale.X64.Decls.va_operand_xmm ->
src1Hi: Prims.bool ->
src2Hi: Prims.bool ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 35,
"end_line": 92,
"start_col": 2,
"start_line": 83
} |
Prims.Tot | val va_wp_VAESNI_enc
(dst src1 src2: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) | val va_wp_VAESNI_enc
(dst src1 src2: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_VAESNI_enc
(dst src1 src2: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled) /\
(forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t).
let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in
va_get_ok va_sM /\
va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.aesni_enabled",
"Vale.X64.CPU_Features_s.avx_enabled",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Vale.X64.Flags.t",
"Prims.l_imp",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_s.mix_columns_LE",
"Vale.AES.AES_common_s.sub_bytes",
"Vale.AES.AES_s.shift_rows_LE",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src))
//--
//-- VAESNI_enc
val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot
va_code
val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) | false | true | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_VAESNI_enc
(dst src1 src2: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.X64.InsAes.va_wp_VAESNI_enc | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src1: Vale.X64.Decls.va_operand_xmm ->
src2: Vale.X64.Decls.va_operand_xmm ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 78,
"end_line": 172,
"start_col": 2,
"start_line": 167
} |
Prims.Tot | val va_wp_VAESNI_enc_last
(dst src1 src2: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))
(va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) | val va_wp_VAESNI_enc_last
(dst src1 src2: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_VAESNI_enc_last
(dst src1 src2: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled) /\
(forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t).
let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in
va_get_ok va_sM /\
va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm
va_s0
src1)))
(va_eval_xmm va_s0 src2) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.aesni_enabled",
"Vale.X64.CPU_Features_s.avx_enabled",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Vale.X64.Flags.t",
"Prims.l_imp",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_common_s.sub_bytes",
"Vale.AES.AES_s.shift_rows_LE",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src))
//--
//-- VAESNI_enc
val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot
va_code
val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc
dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2))
//--
//-- AESNI_enc_last
val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq
va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (())))
val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc_last dst src)) =
(va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last
dst src) (va_wpProof_AESNI_enc_last dst src))
//--
//-- VAESNI_enc_last
val va_code_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
Tot va_code
val va_codegen_success_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc_last dst src1 src2) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) | false | true | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_VAESNI_enc_last
(dst src1 src2: va_operand_xmm)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.X64.InsAes.va_wp_VAESNI_enc_last | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src1: Vale.X64.Decls.va_operand_xmm ->
src2: Vale.X64.Decls.va_operand_xmm ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 50,
"end_line": 249,
"start_col": 2,
"start_line": 244
} |
Prims.Tot | val va_quick_Pclmulqdq (dst src: va_operand_xmm) (dstHi srcHi: bool)
: (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) | val va_quick_Pclmulqdq (dst src: va_operand_xmm) (dstHi srcHi: bool)
: (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi))
let va_quick_Pclmulqdq (dst src: va_operand_xmm) (dstHi srcHi: bool)
: (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = | false | null | false | (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi)
(va_wpProof_Pclmulqdq dst src dstHi srcHi)) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Prims.bool",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsAes.va_code_Pclmulqdq",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsAes.va_wp_Pclmulqdq",
"Vale.X64.InsAes.va_wpProof_Pclmulqdq",
"Vale.X64.QuickCode.va_quickCode"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : | false | false | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_quick_Pclmulqdq (dst src: va_operand_xmm) (dstHi srcHi: bool)
: (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) | [] | Vale.X64.InsAes.va_quick_Pclmulqdq | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
dstHi: Prims.bool ->
srcHi: Prims.bool
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.X64.InsAes.va_code_Pclmulqdq dst src dstHi srcHi) | {
"end_col": 85,
"end_line": 56,
"start_col": 2,
"start_line": 55
} |
Prims.Tot | val va_quick_VPclmulqdq (dst src1 src2: va_operand_xmm) (src1Hi src2Hi: bool)
: (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) | val va_quick_VPclmulqdq (dst src1 src2: va_operand_xmm) (src1Hi src2Hi: bool)
: (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi))
let va_quick_VPclmulqdq (dst src1 src2: va_operand_xmm) (src1Hi src2Hi: bool)
: (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = | false | null | false | (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)
([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi)
(va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi)) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Prims.bool",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsAes.va_code_VPclmulqdq",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsAes.va_wp_VPclmulqdq",
"Vale.X64.InsAes.va_wpProof_VPclmulqdq",
"Vale.X64.QuickCode.va_quickCode"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi | false | false | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_quick_VPclmulqdq (dst src1 src2: va_operand_xmm) (src1Hi src2Hi: bool)
: (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) | [] | Vale.X64.InsAes.va_quick_VPclmulqdq | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src1: Vale.X64.Decls.va_operand_xmm ->
src2: Vale.X64.Decls.va_operand_xmm ->
src1Hi: Prims.bool ->
src2Hi: Prims.bool
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.X64.InsAes.va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) | {
"end_col": 12,
"end_line": 106,
"start_col": 2,
"start_line": 104
} |
Prims.Tot | val va_quick_AESNI_enc (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src)) | val va_quick_AESNI_enc (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src))
let va_quick_AESNI_enc (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) = | false | null | false | (va_QProc (va_code_AESNI_enc dst src)
([va_Mod_flags; va_mod_xmm dst])
(va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src)) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsAes.va_code_AESNI_enc",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsAes.va_wp_AESNI_enc",
"Vale.X64.InsAes.va_wpProof_AESNI_enc",
"Vale.X64.QuickCode.va_quickCode"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit | false | false | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_quick_AESNI_enc (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) | [] | Vale.X64.InsAes.va_quick_AESNI_enc | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm
-> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_AESNI_enc dst src) | {
"end_col": 35,
"end_line": 143,
"start_col": 2,
"start_line": 142
} |
Prims.Tot | val va_quick_VAESNI_enc (dst src1 src2: va_operand_xmm)
: (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc
dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2)) | val va_quick_VAESNI_enc (dst src1 src2: va_operand_xmm)
: (va_quickCode unit (va_code_VAESNI_enc dst src1 src2))
let va_quick_VAESNI_enc (dst src1 src2: va_operand_xmm)
: (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) = | false | null | false | (va_QProc (va_code_VAESNI_enc dst src1 src2)
([va_Mod_flags; va_mod_xmm dst])
(va_wp_VAESNI_enc dst src1 src2)
(va_wpProof_VAESNI_enc dst src1 src2)) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsAes.va_code_VAESNI_enc",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsAes.va_wp_VAESNI_enc",
"Vale.X64.InsAes.va_wpProof_VAESNI_enc",
"Vale.X64.QuickCode.va_quickCode"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src))
//--
//-- VAESNI_enc
val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot
va_code
val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : | false | false | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_quick_VAESNI_enc (dst src1 src2: va_operand_xmm)
: (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) | [] | Vale.X64.InsAes.va_quick_VAESNI_enc | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src1: Vale.X64.Decls.va_operand_xmm ->
src2: Vale.X64.Decls.va_operand_xmm
-> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_VAESNI_enc dst src1 src2) | {
"end_col": 57,
"end_line": 184,
"start_col": 2,
"start_line": 183
} |
Prims.Tot | val va_quick_AESNI_enc_last (dst src: va_operand_xmm)
: (va_quickCode unit (va_code_AESNI_enc_last dst src)) | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc_last dst src)) =
(va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last
dst src) (va_wpProof_AESNI_enc_last dst src)) | val va_quick_AESNI_enc_last (dst src: va_operand_xmm)
: (va_quickCode unit (va_code_AESNI_enc_last dst src))
let va_quick_AESNI_enc_last (dst src: va_operand_xmm)
: (va_quickCode unit (va_code_AESNI_enc_last dst src)) = | false | null | false | (va_QProc (va_code_AESNI_enc_last dst src)
([va_Mod_flags; va_mod_xmm dst])
(va_wp_AESNI_enc_last dst src)
(va_wpProof_AESNI_enc_last dst src)) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsAes.va_code_AESNI_enc_last",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsAes.va_wp_AESNI_enc_last",
"Vale.X64.InsAes.va_wpProof_AESNI_enc_last",
"Vale.X64.QuickCode.va_quickCode"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src))
//--
//-- VAESNI_enc
val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot
va_code
val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc
dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2))
//--
//-- AESNI_enc_last
val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq
va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (())))
val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit | false | false | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_quick_AESNI_enc_last (dst src: va_operand_xmm)
: (va_quickCode unit (va_code_AESNI_enc_last dst src)) | [] | Vale.X64.InsAes.va_quick_AESNI_enc_last | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm
-> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_AESNI_enc_last dst src) | {
"end_col": 49,
"end_line": 220,
"start_col": 2,
"start_line": 219
} |
Prims.Tot | val va_quick_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8)
: (va_quickCode unit (va_code_AESNI_keygen_assist dst src imm)) | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_AESNI_keygen_assist (dst:va_operand_xmm) (src:va_operand_xmm) (imm:nat8) :
(va_quickCode unit (va_code_AESNI_keygen_assist dst src imm)) =
(va_QProc (va_code_AESNI_keygen_assist dst src imm) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_AESNI_keygen_assist dst src imm) (va_wpProof_AESNI_keygen_assist dst src imm)) | val va_quick_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8)
: (va_quickCode unit (va_code_AESNI_keygen_assist dst src imm))
let va_quick_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8)
: (va_quickCode unit (va_code_AESNI_keygen_assist dst src imm)) = | false | null | false | (va_QProc (va_code_AESNI_keygen_assist dst src imm)
([va_Mod_flags; va_mod_xmm dst])
(va_wp_AESNI_keygen_assist dst src imm)
(va_wpProof_AESNI_keygen_assist dst src imm)) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.Def.Types_s.nat8",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsAes.va_code_AESNI_keygen_assist",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsAes.va_wp_AESNI_keygen_assist",
"Vale.X64.InsAes.va_wpProof_AESNI_keygen_assist",
"Vale.X64.QuickCode.va_quickCode"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src))
//--
//-- VAESNI_enc
val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot
va_code
val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc
dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2))
//--
//-- AESNI_enc_last
val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq
va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (())))
val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc_last dst src)) =
(va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last
dst src) (va_wpProof_AESNI_enc_last dst src))
//--
//-- VAESNI_enc_last
val va_code_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
Tot va_code
val va_codegen_success_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc_last dst src1 src2) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))
(va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc_last dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc_last dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VAESNI_enc_last dst src1 src2) (va_wpProof_VAESNI_enc_last dst src1 src2))
//--
//-- AESNI_keygen_assist
val va_code_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> Tot
va_code
val va_codegen_success_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8
-> Tot va_pbool
val va_lemma_AESNI_keygen_assist : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> imm:nat8
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_keygen_assist dst src imm) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32
(Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0
src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm)
(Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0
src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) /\ va_state_eq
va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_keygen_assist (dst:va_operand_xmm) (src:va_operand_xmm) (imm:nat8) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32
(Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm)
(Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0
src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) ==> va_k va_sM
(())))
val va_wpProof_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_keygen_assist dst src imm va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_keygen_assist dst src imm)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_keygen_assist (dst:va_operand_xmm) (src:va_operand_xmm) (imm:nat8) : | false | false | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_quick_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8)
: (va_quickCode unit (va_code_AESNI_keygen_assist dst src imm)) | [] | Vale.X64.InsAes.va_quick_AESNI_keygen_assist | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
imm: Vale.Def.Types_s.nat8
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.X64.InsAes.va_code_AESNI_keygen_assist dst src imm) | {
"end_col": 89,
"end_line": 310,
"start_col": 2,
"start_line": 309
} |
Prims.Tot | val va_quick_VAESNI_enc_last (dst src1 src2: va_operand_xmm)
: (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VAESNI_enc_last dst src1 src2) (va_wpProof_VAESNI_enc_last dst src1 src2)) | val va_quick_VAESNI_enc_last (dst src1 src2: va_operand_xmm)
: (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2))
let va_quick_VAESNI_enc_last (dst src1 src2: va_operand_xmm)
: (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) = | false | null | false | (va_QProc (va_code_VAESNI_enc_last dst src1 src2)
([va_Mod_flags; va_mod_xmm dst])
(va_wp_VAESNI_enc_last dst src1 src2)
(va_wpProof_VAESNI_enc_last dst src1 src2)) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsAes.va_code_VAESNI_enc_last",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsAes.va_wp_VAESNI_enc_last",
"Vale.X64.InsAes.va_wpProof_VAESNI_enc_last",
"Vale.X64.QuickCode.va_quickCode"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src))
//--
//-- VAESNI_enc
val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot
va_code
val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc
dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2))
//--
//-- AESNI_enc_last
val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq
va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (())))
val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc_last dst src)) =
(va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last
dst src) (va_wpProof_AESNI_enc_last dst src))
//--
//-- VAESNI_enc_last
val va_code_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
Tot va_code
val va_codegen_success_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc_last dst src1 src2) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))
(va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc_last dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc_last dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : | false | false | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_quick_VAESNI_enc_last (dst src1 src2: va_operand_xmm)
: (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) | [] | Vale.X64.InsAes.va_quick_VAESNI_enc_last | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src1: Vale.X64.Decls.va_operand_xmm ->
src2: Vale.X64.Decls.va_operand_xmm
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.X64.InsAes.va_code_VAESNI_enc_last dst src1 src2) | {
"end_col": 85,
"end_line": 261,
"start_col": 2,
"start_line": 260
} |
Prims.Tot | val va_wp_AESNI_keygen_assist
(dst src: va_operand_xmm)
(imm: nat8)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_AESNI_keygen_assist (dst:va_operand_xmm) (src:va_operand_xmm) (imm:nat8) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32
(Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm)
(Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0
src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) ==> va_k va_sM
(()))) | val va_wp_AESNI_keygen_assist
(dst src: va_operand_xmm)
(imm: nat8)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_AESNI_keygen_assist
(dst src: va_operand_xmm)
(imm: nat8)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t).
let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in
va_get_ok va_sM /\
va_eval_xmm va_sM dst ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32
(Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0
src)))
(Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1
(va_eval_xmm va_s0 src))))
imm)
(Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0
src)))
(Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3
(va_eval_xmm va_s0 src))))
imm) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.X64.InsAes.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsAes.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.Def.Types_s.nat8",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.aesni_enabled",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Vale.X64.Flags.t",
"Prims.l_imp",
"Prims.eq2",
"Vale.Def.Words_s.four",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.Def.Words_s.Mkfour",
"Vale.AES.AES_common_s.sub_word",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Arch.Types.ixor32",
"Vale.AES.AES_s.rot_word_LE",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | module Vale.X64.InsAes
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.AES_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.CPU_Features_s
//-- Pclmulqdq
val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot
va_code
val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool ->
srcHi:bool -> Tot va_pbool
val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> dstHi:bool -> srcHi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))
(Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32
(va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32
(va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (())))
val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) :
(va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
//--
//-- VPclmulqdq
val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> Tot va_code
val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool
val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul
(Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))
(Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool)
(src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32
(Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ ->
Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ ->
Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))))
(Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi
(va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0
src2))))) ==> va_k va_sM (())))
val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi
src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi
src2Hi))
//--
//-- AESNI_enc
val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\
va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))))
(va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state ->
unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM
(())))
val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags;
va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src)
(va_wpProof_AESNI_enc dst src))
//--
//-- VAESNI_enc
val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot
va_code
val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))))
(va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc
dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2))
//--
//-- AESNI_enc_last
val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst
va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq
va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\
(forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst ==
Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
(va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (())))
val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit
(va_code_AESNI_enc_last dst src)) =
(va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last
dst src) (va_wpProof_AESNI_enc_last dst src))
//--
//-- VAESNI_enc_last
val va_code_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm ->
Tot va_code
val va_codegen_success_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm ->
src2:va_operand_xmm -> Tot va_pbool
val va_lemma_VAESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src1:va_operand_xmm -> src2:va_operand_xmm
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_VAESNI_enc_last dst src1 src2) va_s0 /\ va_is_dst_xmm
dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\
(aesni_enabled /\ avx_enabled)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes
(Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM
va_s0)))))
[@ va_qattr]
let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok
va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst
va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor
(Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))
(va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
val va_wpProof_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_VAESNI_enc_last dst src1 src2 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc_last dst src1 src2)
([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) :
(va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst])
(va_wp_VAESNI_enc_last dst src1 src2) (va_wpProof_VAESNI_enc_last dst src1 src2))
//--
//-- AESNI_keygen_assist
val va_code_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> Tot
va_code
val va_codegen_success_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8
-> Tot va_pbool
val va_lemma_AESNI_keygen_assist : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> imm:nat8
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESNI_keygen_assist dst src imm) va_s0 /\
va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32
(Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0
src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm)
(Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0
src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word
(Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) /\ va_state_eq
va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
[@ va_qattr]
let va_wp_AESNI_keygen_assist (dst:va_operand_xmm) (src:va_operand_xmm) (imm:nat8) (va_s0:va_state) | false | true | Vale.X64.InsAes.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_AESNI_keygen_assist
(dst src: va_operand_xmm)
(imm: nat8)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.X64.InsAes.va_wp_AESNI_keygen_assist | {
"file_name": "obj/Vale.X64.InsAes.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
imm: Vale.Def.Types_s.nat8 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 10,
"end_line": 298,
"start_col": 2,
"start_line": 288
} |
Prims.Tot | val jump_bounded_integer (i: integer_size) : Tot (jumper (parse_bounded_integer i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () | val jump_bounded_integer (i: integer_size) : Tot (jumper (parse_bounded_integer i))
let jump_bounded_integer (i: integer_size) : Tot (jumper (parse_bounded_integer i)) = | false | null | false | jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.Base.jump_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"FStar.UInt32.uint_to_t",
"LowParse.Low.Base.jumper"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_bounded_integer (i: integer_size) : Tot (jumper (parse_bounded_integer i)) | [] | LowParse.Low.BoundedInt.jump_bounded_integer | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_integer i) | {
"end_col": 67,
"end_line": 91,
"start_col": 2,
"start_line": 91
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () | let write_bounded_integer_1 () = | false | null | false | leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.leaf_writer_strong_of_serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Low.BoundedInt.serialize32_bounded_integer_1",
"LowParse.Low.Base.leaf_writer_strong"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_1 : _: Prims.unit
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 1) | [] | LowParse.Low.BoundedInt.write_bounded_integer_1 | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 1) | {
"end_col": 105,
"end_line": 119,
"start_col": 33,
"start_line": 119
} |
|
Prims.Tot | val write_bounded_integer_3_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 3)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () | val write_bounded_integer_3_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 3))
let write_bounded_integer_3_weak (_: unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = | false | null | false | leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.leaf_writer_weak_of_strong_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Low.BoundedInt.write_bounded_integer_3",
"FStar.UInt32.__uint_to_t",
"LowParse.Low.Base.leaf_writer_weak"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_3_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 3)) | [] | LowParse.Low.BoundedInt.write_bounded_integer_3_weak | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer 3) | {
"end_col": 78,
"end_line": 166,
"start_col": 2,
"start_line": 166
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () | let write_bounded_integer_3 () = | false | null | false | leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.leaf_writer_strong_of_serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Low.BoundedInt.serialize32_bounded_integer_3",
"LowParse.Low.Base.leaf_writer_strong"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_3 : _: Prims.unit
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 3) | [] | LowParse.Low.BoundedInt.write_bounded_integer_3 | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 3) | {
"end_col": 105,
"end_line": 125,
"start_col": 33,
"start_line": 125
} |
|
Prims.Tot | val validate_bounded_integer (i: integer_size) : Tot (validator (parse_bounded_integer i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () | val validate_bounded_integer (i: integer_size) : Tot (validator (parse_bounded_integer i))
let validate_bounded_integer (i: integer_size) : Tot (validator (parse_bounded_integer i)) = | false | null | false | validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.Base.validate_total_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"FStar.UInt64.uint_to_t",
"LowParse.Low.Base.validator"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_bounded_integer (i: integer_size) : Tot (validator (parse_bounded_integer i)) | [] | LowParse.Low.BoundedInt.validate_bounded_integer | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_integer i) | {
"end_col": 77,
"end_line": 71,
"start_col": 2,
"start_line": 71
} |
Prims.Tot | val write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 () | val write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i))
let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = | false | null | false | [@@ inline_let ]let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.BoundedInt.write_bounded_integer_1",
"LowParse.Low.BoundedInt.write_bounded_integer_2",
"LowParse.Low.BoundedInt.write_bounded_integer_3",
"LowParse.Low.BoundedInt.write_bounded_integer_4",
"LowParse.Low.Base.leaf_writer_strong",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"Prims.unit",
"LowParse.Spec.BoundedInt.integer_size_values"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) | [] | LowParse.Low.BoundedInt.write_bounded_integer | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer i) | {
"end_col": 35,
"end_line": 141,
"start_col": 2,
"start_line": 135
} |
Prims.Tot | val read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 () | val read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i))
let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = | false | null | false | [@@ inline_let ]let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.BoundedInt.read_bounded_integer_1",
"LowParse.Low.BoundedInt.read_bounded_integer_2",
"LowParse.Low.BoundedInt.read_bounded_integer_3",
"LowParse.Low.BoundedInt.read_bounded_integer_4",
"LowParse.Low.Base.leaf_reader",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"Prims.unit",
"LowParse.Spec.BoundedInt.integer_size_values"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) | [] | LowParse.Low.BoundedInt.read_bounded_integer | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_integer i) | {
"end_col": 34,
"end_line": 35,
"start_col": 2,
"start_line": 29
} |
Prims.Tot | val validate_bounded_integer_le (i: integer_size) : Tot (validator (parse_bounded_integer_le i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () | val validate_bounded_integer_le (i: integer_size) : Tot (validator (parse_bounded_integer_le i))
let validate_bounded_integer_le (i: integer_size) : Tot (validator (parse_bounded_integer_le i)) = | false | null | false | validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.Base.validate_total_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"FStar.UInt64.uint_to_t",
"LowParse.Low.Base.validator"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_bounded_integer_le (i: integer_size) : Tot (validator (parse_bounded_integer_le i)) | [] | LowParse.Low.BoundedInt.validate_bounded_integer_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_integer_le i) | {
"end_col": 80,
"end_line": 84,
"start_col": 2,
"start_line": 84
} |
Prims.Tot | val write_bounded_integer_2_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 2)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () | val write_bounded_integer_2_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 2))
let write_bounded_integer_2_weak (_: unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = | false | null | false | leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.leaf_writer_weak_of_strong_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Low.BoundedInt.write_bounded_integer_2",
"FStar.UInt32.__uint_to_t",
"LowParse.Low.Base.leaf_writer_weak"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_2_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 2)) | [] | LowParse.Low.BoundedInt.write_bounded_integer_2_weak | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer 2) | {
"end_col": 78,
"end_line": 162,
"start_col": 2,
"start_line": 162
} |
Prims.Tot | val jump_bounded_integer_le (i: integer_size) : Tot (jumper (parse_bounded_integer_le i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () | val jump_bounded_integer_le (i: integer_size) : Tot (jumper (parse_bounded_integer_le i))
let jump_bounded_integer_le (i: integer_size) : Tot (jumper (parse_bounded_integer_le i)) = | false | null | false | jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.Base.jump_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"FStar.UInt32.uint_to_t",
"LowParse.Low.Base.jumper"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_bounded_integer_le (i: integer_size) : Tot (jumper (parse_bounded_integer_le i)) | [] | LowParse.Low.BoundedInt.jump_bounded_integer_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_integer_le i) | {
"end_col": 70,
"end_line": 104,
"start_col": 2,
"start_line": 104
} |
Prims.Tot | val jump_u16_le:jumper parse_u16_le | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul () | val jump_u16_le:jumper parse_u16_le
let jump_u16_le:jumper parse_u16_le = | false | null | false | jump_constant_size parse_u16_le 2ul () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Low.Base.jump_constant_size",
"LowParse.Spec.Int.parse_u16_kind",
"FStar.UInt16.t",
"LowParse.Spec.BoundedInt.parse_u16_le",
"FStar.UInt32.__uint_to_t"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction | false | true | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_u16_le:jumper parse_u16_le | [] | LowParse.Low.BoundedInt.jump_u16_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.jumper LowParse.Spec.BoundedInt.parse_u16_le | {
"end_col": 40,
"end_line": 343,
"start_col": 2,
"start_line": 343
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () | let write_bounded_integer_2 () = | false | null | false | leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.leaf_writer_strong_of_serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Low.BoundedInt.serialize32_bounded_integer_2",
"LowParse.Low.Base.leaf_writer_strong"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_2 : _: Prims.unit
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 2) | [] | LowParse.Low.BoundedInt.write_bounded_integer_2 | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 2) | {
"end_col": 105,
"end_line": 122,
"start_col": 33,
"start_line": 122
} |
|
Prims.Tot | val validate_u32_le: Prims.unit -> validator parse_u32_le | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL () | val validate_u32_le: Prims.unit -> validator parse_u32_le
let validate_u32_le () : validator parse_u32_le = | false | null | false | validate_total_constant_size parse_u32_le 4uL () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.validate_total_constant_size",
"LowParse.Spec.Int.parse_u32_kind",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_u32_le",
"FStar.UInt64.__uint_to_t",
"LowParse.Low.Base.validator"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction | false | true | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_u32_le: Prims.unit -> validator parse_u32_le | [] | LowParse.Low.BoundedInt.validate_u32_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> LowParse.Low.Base.validator LowParse.Spec.BoundedInt.parse_u32_le | {
"end_col": 50,
"end_line": 335,
"start_col": 2,
"start_line": 335
} |
Prims.Tot | val validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c | val validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = | false | null | false | validate_total_constant_size_with_error_code parse_u32_le 4uL c | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Low.ErrorCode.error_code",
"LowParse.Low.Base.validate_total_constant_size_with_error_code",
"LowParse.Spec.Int.parse_u32_kind",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_u32_le",
"FStar.UInt64.__uint_to_t",
"LowParse.Low.Base.validator"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction | false | true | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le | [] | LowParse.Low.BoundedInt.validate_u32_le_with_error_code | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | c: LowParse.Low.ErrorCode.error_code
-> LowParse.Low.Base.validator LowParse.Spec.BoundedInt.parse_u32_le | {
"end_col": 65,
"end_line": 339,
"start_col": 2,
"start_line": 339
} |
Prims.Tot | val jump_u32_le:jumper parse_u32_le | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_u32_le : jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul () | val jump_u32_le:jumper parse_u32_le
let jump_u32_le:jumper parse_u32_le = | false | null | false | jump_constant_size parse_u32_le 4ul () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Low.Base.jump_constant_size",
"LowParse.Spec.Int.parse_u32_kind",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_u32_le",
"FStar.UInt32.__uint_to_t"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction
let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
inline_for_extraction | false | true | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_u32_le:jumper parse_u32_le | [] | LowParse.Low.BoundedInt.jump_u32_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.jumper LowParse.Spec.BoundedInt.parse_u32_le | {
"end_col": 40,
"end_line": 347,
"start_col": 2,
"start_line": 347
} |
Prims.Tot | val validate_u16_le: Prims.unit -> validator parse_u16_le | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL () | val validate_u16_le: Prims.unit -> validator parse_u16_le
let validate_u16_le () : validator parse_u16_le = | false | null | false | validate_total_constant_size parse_u16_le 2uL () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.validate_total_constant_size",
"LowParse.Spec.Int.parse_u16_kind",
"FStar.UInt16.t",
"LowParse.Spec.BoundedInt.parse_u16_le",
"FStar.UInt64.__uint_to_t",
"LowParse.Low.Base.validator"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction | false | true | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_u16_le: Prims.unit -> validator parse_u16_le | [] | LowParse.Low.BoundedInt.validate_u16_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> LowParse.Low.Base.validator LowParse.Spec.BoundedInt.parse_u16_le | {
"end_col": 50,
"end_line": 327,
"start_col": 2,
"start_line": 327
} |
Prims.Tot | val read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_bounded_integer_le
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_le_1
| 2 -> read_bounded_integer_le_2
| 3 -> read_bounded_integer_le_3
| 4 -> read_bounded_integer_le_4 | val read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i))
let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) = | false | null | false | [@@ inline_let ]let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_le_1
| 2 -> read_bounded_integer_le_2
| 3 -> read_bounded_integer_le_3
| 4 -> read_bounded_integer_le_4 | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.BoundedInt.read_bounded_integer_le_1",
"LowParse.Low.BoundedInt.read_bounded_integer_le_2",
"LowParse.Low.BoundedInt.read_bounded_integer_le_3",
"LowParse.Low.BoundedInt.read_bounded_integer_le_4",
"LowParse.Low.Base.leaf_reader",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"Prims.unit",
"LowParse.Spec.BoundedInt.integer_size_values"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction
let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
inline_for_extraction
let jump_u32_le : jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul ()
inline_for_extraction
val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1)
inline_for_extraction
val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2)
inline_for_extraction
val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3)
inline_for_extraction
val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4)
inline_for_extraction
noextract
let read_bounded_integer_le
(i: integer_size) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) | [] | LowParse.Low.BoundedInt.read_bounded_integer_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_integer_le i) | {
"end_col": 34,
"end_line": 372,
"start_col": 2,
"start_line": 366
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () | let write_bounded_integer_4 () = | false | null | false | leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.leaf_writer_strong_of_serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Low.BoundedInt.serialize32_bounded_integer_4",
"LowParse.Low.Base.leaf_writer_strong"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_4 : _: Prims.unit
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 4) | [] | LowParse.Low.BoundedInt.write_bounded_integer_4 | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 4) | {
"end_col": 105,
"end_line": 128,
"start_col": 33,
"start_line": 128
} |
|
Prims.Tot | val validate_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (validator (parse_bounded_integer (U32.v i))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () | val validate_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (validator (parse_bounded_integer (U32.v i)))
let validate_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (validator (parse_bounded_integer (U32.v i))) = | false | null | false | validate_total_constant_size (parse_bounded_integer (U32.v i))
(FStar.Int.Cast.uint32_to_uint64 i)
() | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Low.Base.validate_total_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"FStar.Int.Cast.uint32_to_uint64",
"LowParse.Low.Base.validator"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (validator (parse_bounded_integer (U32.v i))) | [] | LowParse.Low.BoundedInt.validate_bounded_integer' | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4}
-> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_integer (FStar.UInt32.v i)) | {
"end_col": 103,
"end_line": 77,
"start_col": 2,
"start_line": 77
} |
Prims.Tot | val write_bounded_integer_4_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 4)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () | val write_bounded_integer_4_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 4))
let write_bounded_integer_4_weak (_: unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = | false | null | false | leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.leaf_writer_weak_of_strong_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Low.BoundedInt.write_bounded_integer_4",
"FStar.UInt32.__uint_to_t",
"LowParse.Low.Base.leaf_writer_weak"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_4_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 4)) | [] | LowParse.Low.BoundedInt.write_bounded_integer_4_weak | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer 4) | {
"end_col": 78,
"end_line": 170,
"start_col": 2,
"start_line": 170
} |
Prims.Tot | val write_bounded_integer_weak (i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak () | val write_bounded_integer_weak (i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
let write_bounded_integer_weak (i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i)) = | false | null | false | [@@ inline_let ]let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.BoundedInt.write_bounded_integer_1_weak",
"LowParse.Low.BoundedInt.write_bounded_integer_2_weak",
"LowParse.Low.BoundedInt.write_bounded_integer_3_weak",
"LowParse.Low.BoundedInt.write_bounded_integer_4_weak",
"LowParse.Low.Base.leaf_writer_weak",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"Prims.unit",
"LowParse.Spec.BoundedInt.integer_size_values"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_weak (i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i)) | [] | LowParse.Low.BoundedInt.write_bounded_integer_weak | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer i) | {
"end_col": 40,
"end_line": 183,
"start_col": 2,
"start_line": 177
} |
Prims.Tot | val write_bounded_integer_1_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 1)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () | val write_bounded_integer_1_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 1))
let write_bounded_integer_1_weak (_: unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = | false | null | false | leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Low.Base.leaf_writer_weak_of_strong_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Low.BoundedInt.write_bounded_integer_1",
"FStar.UInt32.__uint_to_t",
"LowParse.Low.Base.leaf_writer_weak"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_1_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 1)) | [] | LowParse.Low.BoundedInt.write_bounded_integer_1_weak | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit
-> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer 1) | {
"end_col": 78,
"end_line": 158,
"start_col": 2,
"start_line": 158
} |
Prims.Tot | val validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c | val validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = | false | null | false | validate_total_constant_size_with_error_code parse_u16_le 2uL c | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Low.ErrorCode.error_code",
"LowParse.Low.Base.validate_total_constant_size_with_error_code",
"LowParse.Spec.Int.parse_u16_kind",
"FStar.UInt16.t",
"LowParse.Spec.BoundedInt.parse_u16_le",
"FStar.UInt64.__uint_to_t",
"LowParse.Low.Base.validator"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction | false | true | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le | [] | LowParse.Low.BoundedInt.validate_u16_le_with_error_code | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | c: LowParse.Low.ErrorCode.error_code
-> LowParse.Low.Base.validator LowParse.Spec.BoundedInt.parse_u16_le | {
"end_col": 65,
"end_line": 331,
"start_col": 2,
"start_line": 331
} |
Prims.Tot | val write_bounded_integer_le (i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer_le
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_le_1
| 2 -> write_bounded_integer_le_2
| 3 -> write_bounded_integer_le_3
| 4 -> write_bounded_integer_le_4 | val write_bounded_integer_le (i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i))
let write_bounded_integer_le (i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i)) = | false | null | false | [@@ inline_let ]let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_le_1
| 2 -> write_bounded_integer_le_2
| 3 -> write_bounded_integer_le_3
| 4 -> write_bounded_integer_le_4 | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Low.BoundedInt.write_bounded_integer_le_1",
"LowParse.Low.BoundedInt.write_bounded_integer_le_2",
"LowParse.Low.BoundedInt.write_bounded_integer_le_3",
"LowParse.Low.BoundedInt.write_bounded_integer_le_4",
"LowParse.Low.Base.leaf_writer_strong",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le",
"Prims.unit",
"LowParse.Spec.BoundedInt.integer_size_values"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction
let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
inline_for_extraction
let jump_u32_le : jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul ()
inline_for_extraction
val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1)
inline_for_extraction
val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2)
inline_for_extraction
val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3)
inline_for_extraction
val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4)
inline_for_extraction
noextract
let read_bounded_integer_le
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_le_1
| 2 -> read_bounded_integer_le_2
| 3 -> read_bounded_integer_le_3
| 4 -> read_bounded_integer_le_4
inline_for_extraction
val read_u16_le : leaf_reader parse_u16_le
inline_for_extraction
val read_u32_le : leaf_reader parse_u32_le
inline_for_extraction
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1)
inline_for_extraction
val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1)
inline_for_extraction
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2)
inline_for_extraction
val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2)
inline_for_extraction
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3)
inline_for_extraction
val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3)
inline_for_extraction
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4)
inline_for_extraction
val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4)
inline_for_extraction
noextract
let write_bounded_integer_le
(i: integer_size) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer_le (i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i)) | [] | LowParse.Low.BoundedInt.write_bounded_integer_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer_le i) | {
"end_col": 35,
"end_line": 415,
"start_col": 2,
"start_line": 409
} |
Prims.Tot | val jump_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (jumper (parse_bounded_integer (U32.v i))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) () | val jump_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (jumper (parse_bounded_integer (U32.v i)))
let jump_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (jumper (parse_bounded_integer (U32.v i))) = | false | null | false | jump_constant_size (parse_bounded_integer (U32.v i)) (i) () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Low.Base.jump_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Low.Base.jumper"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (jumper (parse_bounded_integer (U32.v i))) | [] | LowParse.Low.BoundedInt.jump_bounded_integer' | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4}
-> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_integer (FStar.UInt32.v i)) | {
"end_col": 61,
"end_line": 97,
"start_col": 2,
"start_line": 97
} |
Prims.Tot | val read_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (leaf_reader (parse_bounded_integer (U32.v i))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos | val read_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
let read_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (leaf_reader (parse_bounded_integer (U32.v i))) = | false | null | false | fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else
if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"Prims.op_Equality",
"FStar.UInt32.__uint_to_t",
"LowParse.Low.BoundedInt.read_bounded_integer_1",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.bool",
"LowParse.Low.BoundedInt.read_bounded_integer_2",
"LowParse.Low.BoundedInt.read_bounded_integer_3",
"LowParse.Low.BoundedInt.read_bounded_integer_4",
"LowParse.Low.Base.leaf_reader",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (leaf_reader (parse_bounded_integer (U32.v i))) | [] | LowParse.Low.BoundedInt.read_bounded_integer' | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4}
-> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_integer (FStar.UInt32.v i
)) | {
"end_col": 39,
"end_line": 47,
"start_col": 2,
"start_line": 40
} |
Prims.Tot | val write_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
) | val write_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
let write_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = | false | null | false | fun input #rrel #rel out pos ->
(if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else
if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else
if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos) | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.BoundedInt.write_bounded_int32_1",
"Prims.bool",
"LowParse.Low.BoundedInt.write_bounded_int32_2",
"LowParse.Low.BoundedInt.write_bounded_int32_3",
"LowParse.Low.BoundedInt.write_bounded_int32_4",
"LowParse.Low.Base.leaf_writer_strong",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.parse_bounded_int32",
"LowParse.Spec.BoundedInt.serialize_bounded_int32"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.write_bounded_int32 | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v
min32)
(FStar.UInt32.v max32)) | {
"end_col": 3,
"end_line": 218,
"start_col": 2,
"start_line": 210
} |
Prims.Tot | val jump_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32})
: Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_bounded_int32_le_fixed_size
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 })
: Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
= jump_constant_size (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)) 4ul () | val jump_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32})
: Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
let jump_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32})
: Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32))) = | false | null | false | jump_constant_size (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)) 4ul () | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Low.Base.jump_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size",
"FStar.UInt32.__uint_to_t",
"LowParse.Low.Base.jumper"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction
let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
inline_for_extraction
let jump_u32_le : jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul ()
inline_for_extraction
val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1)
inline_for_extraction
val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2)
inline_for_extraction
val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3)
inline_for_extraction
val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4)
inline_for_extraction
noextract
let read_bounded_integer_le
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_le_1
| 2 -> read_bounded_integer_le_2
| 3 -> read_bounded_integer_le_3
| 4 -> read_bounded_integer_le_4
inline_for_extraction
val read_u16_le : leaf_reader parse_u16_le
inline_for_extraction
val read_u32_le : leaf_reader parse_u32_le
inline_for_extraction
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1)
inline_for_extraction
val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1)
inline_for_extraction
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2)
inline_for_extraction
val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2)
inline_for_extraction
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3)
inline_for_extraction
val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3)
inline_for_extraction
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4)
inline_for_extraction
val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4)
inline_for_extraction
noextract
let write_bounded_integer_le
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_le_1
| 2 -> write_bounded_integer_le_2
| 3 -> write_bounded_integer_le_3
| 4 -> write_bounded_integer_le_4
inline_for_extraction
val write_u16_le : leaf_writer_strong serialize_u16_le
inline_for_extraction
val write_u32_le : leaf_writer_strong serialize_u32_le
val validate_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_le_3 min32 max32 sl pos
else validate_bounded_int32_le_4 min32 max32 sl pos
)
val jump_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_le_3 min32 max32 sl pos
else jump_bounded_int32_le_4 min32 max32 sl pos
)
val write_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_le_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_le_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_le_3 min32 max32 input out pos
else write_bounded_int32_le_4 min32 max32 input out pos
)
val read_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val read_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val read_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val read_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_le_3 min32 max32 sl pos
else read_bounded_int32_le_4 min32 max32 sl pos
)
val validate_bounded_int32_le_fixed_size
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 })
: Tot (validator (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32_le_fixed_size
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32})
: Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.jump_bounded_int32_le_fixed_size | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | min32: FStar.UInt32.t -> max32: FStar.UInt32.t{FStar.UInt32.v min32 <= FStar.UInt32.v max32}
-> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size (FStar.UInt32.v
min32)
(FStar.UInt32.v max32)) | {
"end_col": 91,
"end_line": 574,
"start_col": 2,
"start_line": 574
} |
Prims.Tot | val validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_le_3 min32 max32 sl pos
else validate_bounded_int32_le_4 min32 max32 sl pos
) | val validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
let validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = | false | null | false | fun #rrel #rel sl pos ->
(if (U32.v max32) < 256
then validate_bounded_int32_le_1 min32 max32 sl pos
else
if (U32.v max32) < 65536
then validate_bounded_int32_le_2 min32 max32 sl pos
else
if (U32.v max32) < 16777216
then validate_bounded_int32_le_3 min32 max32 sl pos
else validate_bounded_int32_le_4 min32 max32 sl pos) | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt64.t",
"LowParse.Low.BoundedInt.validate_bounded_int32_le_1",
"Prims.bool",
"LowParse.Low.BoundedInt.validate_bounded_int32_le_2",
"LowParse.Low.BoundedInt.validate_bounded_int32_le_3",
"LowParse.Low.BoundedInt.validate_bounded_int32_le_4",
"LowParse.Low.Base.validator",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction
let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
inline_for_extraction
let jump_u32_le : jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul ()
inline_for_extraction
val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1)
inline_for_extraction
val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2)
inline_for_extraction
val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3)
inline_for_extraction
val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4)
inline_for_extraction
noextract
let read_bounded_integer_le
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_le_1
| 2 -> read_bounded_integer_le_2
| 3 -> read_bounded_integer_le_3
| 4 -> read_bounded_integer_le_4
inline_for_extraction
val read_u16_le : leaf_reader parse_u16_le
inline_for_extraction
val read_u32_le : leaf_reader parse_u32_le
inline_for_extraction
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1)
inline_for_extraction
val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1)
inline_for_extraction
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2)
inline_for_extraction
val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2)
inline_for_extraction
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3)
inline_for_extraction
val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3)
inline_for_extraction
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4)
inline_for_extraction
val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4)
inline_for_extraction
noextract
let write_bounded_integer_le
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_le_1
| 2 -> write_bounded_integer_le_2
| 3 -> write_bounded_integer_le_3
| 4 -> write_bounded_integer_le_4
inline_for_extraction
val write_u16_le : leaf_writer_strong serialize_u16_le
inline_for_extraction
val write_u32_le : leaf_writer_strong serialize_u32_le
val validate_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.validate_bounded_int32_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | {
"end_col": 3,
"end_line": 457,
"start_col": 2,
"start_line": 449
} |
Prims.Tot | val jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_le_3 min32 max32 sl pos
else jump_bounded_int32_le_4 min32 max32 sl pos
) | val jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
let jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = | false | null | false | fun #rrel #rel sl pos ->
(if (U32.v max32) < 256
then jump_bounded_int32_le_1 min32 max32 sl pos
else
if (U32.v max32) < 65536
then jump_bounded_int32_le_2 min32 max32 sl pos
else
if (U32.v max32) < 16777216
then jump_bounded_int32_le_3 min32 max32 sl pos
else jump_bounded_int32_le_4 min32 max32 sl pos) | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.BoundedInt.jump_bounded_int32_le_1",
"Prims.bool",
"LowParse.Low.BoundedInt.jump_bounded_int32_le_2",
"LowParse.Low.BoundedInt.jump_bounded_int32_le_3",
"LowParse.Low.BoundedInt.jump_bounded_int32_le_4",
"LowParse.Low.Base.jumper",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction
let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
inline_for_extraction
let jump_u32_le : jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul ()
inline_for_extraction
val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1)
inline_for_extraction
val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2)
inline_for_extraction
val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3)
inline_for_extraction
val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4)
inline_for_extraction
noextract
let read_bounded_integer_le
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_le_1
| 2 -> read_bounded_integer_le_2
| 3 -> read_bounded_integer_le_3
| 4 -> read_bounded_integer_le_4
inline_for_extraction
val read_u16_le : leaf_reader parse_u16_le
inline_for_extraction
val read_u32_le : leaf_reader parse_u32_le
inline_for_extraction
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1)
inline_for_extraction
val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1)
inline_for_extraction
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2)
inline_for_extraction
val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2)
inline_for_extraction
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3)
inline_for_extraction
val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3)
inline_for_extraction
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4)
inline_for_extraction
val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4)
inline_for_extraction
noextract
let write_bounded_integer_le
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_le_1
| 2 -> write_bounded_integer_le_2
| 3 -> write_bounded_integer_le_3
| 4 -> write_bounded_integer_le_4
inline_for_extraction
val write_u16_le : leaf_writer_strong serialize_u16_le
inline_for_extraction
val write_u32_le : leaf_writer_strong serialize_u32_le
val validate_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_le_3 min32 max32 sl pos
else validate_bounded_int32_le_4 min32 max32 sl pos
)
val jump_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.jump_bounded_int32_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | {
"end_col": 3,
"end_line": 492,
"start_col": 2,
"start_line": 484
} |
Prims.Tot | val write_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos | val write_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
let write_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = | false | null | false | fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else
if i = 2ul
then write_bounded_integer_2 () v sl pos
else
if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"Prims.op_Equality",
"FStar.UInt32.__uint_to_t",
"LowParse.Low.BoundedInt.write_bounded_integer_1",
"Prims.bool",
"LowParse.Low.BoundedInt.write_bounded_integer_2",
"LowParse.Low.BoundedInt.write_bounded_integer_3",
"LowParse.Low.BoundedInt.write_bounded_integer_4",
"LowParse.Low.Base.leaf_writer_strong",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4})
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) | [] | LowParse.Low.BoundedInt.write_bounded_integer' | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4}
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer (FStar.UInt32.v
i)) | {
"end_col": 42,
"end_line": 154,
"start_col": 2,
"start_line": 147
} |
Prims.Tot | val jump_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
) | val jump_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = | false | null | false | fun #rrel #rel sl pos ->
(if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else
if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else
if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos) | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.BoundedInt.jump_bounded_int32_1",
"Prims.bool",
"LowParse.Low.BoundedInt.jump_bounded_int32_2",
"LowParse.Low.BoundedInt.jump_bounded_int32_3",
"LowParse.Low.BoundedInt.jump_bounded_int32_4",
"LowParse.Low.Base.jumper",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.jump_bounded_int32 | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32)
(FStar.UInt32.v max32)) | {
"end_col": 3,
"end_line": 323,
"start_col": 2,
"start_line": 315
} |
Prims.Tot | val read_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
) | val read_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
let read_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = | false | null | false | fun #rrel #rel sl pos ->
(if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else
if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else
if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos) | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.BoundedInt.read_bounded_int32_1",
"LowParse.Spec.BoundedInt.bounded_int32",
"Prims.bool",
"LowParse.Low.BoundedInt.read_bounded_int32_2",
"LowParse.Low.BoundedInt.read_bounded_int32_3",
"LowParse.Low.BoundedInt.read_bounded_int32_4",
"LowParse.Low.Base.leaf_reader",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.parse_bounded_int32"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.read_bounded_int32 | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | {
"end_col": 3,
"end_line": 253,
"start_col": 2,
"start_line": 245
} |
Prims.Tot | val write_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_le_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_le_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_le_3 min32 max32 input out pos
else write_bounded_int32_le_4 min32 max32 input out pos
) | val write_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
let write_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = | false | null | false | fun input #rrel #rel out pos ->
(if (U32.v max32) < 256
then write_bounded_int32_le_1 min32 max32 input out pos
else
if (U32.v max32) < 65536
then write_bounded_int32_le_2 min32 max32 input out pos
else
if (U32.v max32) < 16777216
then write_bounded_int32_le_3 min32 max32 input out pos
else write_bounded_int32_le_4 min32 max32 input out pos) | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.BoundedInt.write_bounded_int32_le_1",
"Prims.bool",
"LowParse.Low.BoundedInt.write_bounded_int32_le_2",
"LowParse.Low.BoundedInt.write_bounded_int32_le_3",
"LowParse.Low.BoundedInt.write_bounded_int32_le_4",
"LowParse.Low.Base.leaf_writer_strong",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le",
"LowParse.Spec.BoundedInt.serialize_bounded_int32_le"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction
let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
inline_for_extraction
let jump_u32_le : jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul ()
inline_for_extraction
val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1)
inline_for_extraction
val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2)
inline_for_extraction
val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3)
inline_for_extraction
val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4)
inline_for_extraction
noextract
let read_bounded_integer_le
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_le_1
| 2 -> read_bounded_integer_le_2
| 3 -> read_bounded_integer_le_3
| 4 -> read_bounded_integer_le_4
inline_for_extraction
val read_u16_le : leaf_reader parse_u16_le
inline_for_extraction
val read_u32_le : leaf_reader parse_u32_le
inline_for_extraction
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1)
inline_for_extraction
val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1)
inline_for_extraction
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2)
inline_for_extraction
val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2)
inline_for_extraction
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3)
inline_for_extraction
val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3)
inline_for_extraction
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4)
inline_for_extraction
val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4)
inline_for_extraction
noextract
let write_bounded_integer_le
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_le_1
| 2 -> write_bounded_integer_le_2
| 3 -> write_bounded_integer_le_3
| 4 -> write_bounded_integer_le_4
inline_for_extraction
val write_u16_le : leaf_writer_strong serialize_u16_le
inline_for_extraction
val write_u32_le : leaf_writer_strong serialize_u32_le
val validate_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_le_3 min32 max32 sl pos
else validate_bounded_int32_le_4 min32 max32 sl pos
)
val jump_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_le_3 min32 max32 sl pos
else jump_bounded_int32_le_4 min32 max32 sl pos
)
val write_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.write_bounded_int32_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v
min32)
(FStar.UInt32.v max32)) | {
"end_col": 3,
"end_line": 527,
"start_col": 2,
"start_line": 519
} |
Prims.Tot | val validate_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
) | val validate_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = | false | null | false | fun #rrel #rel sl pos ->
(if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else
if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else
if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos) | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt64.t",
"LowParse.Low.BoundedInt.validate_bounded_int32_1",
"Prims.bool",
"LowParse.Low.BoundedInt.validate_bounded_int32_2",
"LowParse.Low.BoundedInt.validate_bounded_int32_3",
"LowParse.Low.BoundedInt.validate_bounded_int32_4",
"LowParse.Low.Base.validator",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_bounded_int32
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.validate_bounded_int32 | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | {
"end_col": 3,
"end_line": 288,
"start_col": 2,
"start_line": 280
} |
Prims.Tot | val read_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness.BitFields",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_le_3 min32 max32 sl pos
else read_bounded_int32_le_4 min32 max32 sl pos
) | val read_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
let read_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = | false | null | false | fun #rrel #rel sl pos ->
(if (U32.v max32) < 256
then read_bounded_int32_le_1 min32 max32 sl pos
else
if (U32.v max32) < 65536
then read_bounded_int32_le_2 min32 max32 sl pos
else
if (U32.v max32) < 16777216
then read_bounded_int32_le_3 min32 max32 sl pos
else read_bounded_int32_le_4 min32 max32 sl pos) | {
"checked_file": "LowParse.Low.BoundedInt.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BoundedInt.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.BoundedInt.read_bounded_int32_le_1",
"LowParse.Spec.BoundedInt.bounded_int32",
"Prims.bool",
"LowParse.Low.BoundedInt.read_bounded_int32_le_2",
"LowParse.Low.BoundedInt.read_bounded_int32_le_3",
"LowParse.Low.BoundedInt.read_bounded_int32_le_4",
"LowParse.Low.Base.leaf_reader",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le"
] | [] | module LowParse.Low.BoundedInt
include LowParse.Spec.BoundedInt
include LowParse.Low.Base
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module U64 = FStar.UInt64
(* bounded integers *)
inline_for_extraction
val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1))
inline_for_extraction
val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2))
inline_for_extraction
val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3))
inline_for_extraction
val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4))
inline_for_extraction
noextract
let read_bounded_integer
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_1 ()
| 2 -> read_bounded_integer_2 ()
| 3 -> read_bounded_integer_3 ()
| 4 -> read_bounded_integer_4 ()
let read_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_reader (parse_bounded_integer (U32.v i)))
= fun #rrel #rel sl pos ->
if i = 1ul
then read_bounded_integer_1 () sl pos
else if i = 2ul
then read_bounded_integer_2 () sl pos
else if i = 3ul
then read_bounded_integer_3 () sl pos
else read_bounded_integer_4 () sl pos
inline_for_extraction
val read_bounded_integer_ct
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
(#rrel: _)
(#rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: HST.Stack (bounded_integer (U32.v i))
(requires (fun h ->
live_slice h sl /\
U32.v pos + 4 <= U32.v sl.len
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid_content (parse_bounded_integer (U32.v i)) h sl pos res
))
inline_for_extraction
noextract
let validate_bounded_integer
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer i))
= validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
inline_for_extraction
let validate_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (validator (parse_bounded_integer (U32.v i)))
= validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
inline_for_extraction
noextract
let validate_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (validator (parse_bounded_integer_le i))
= validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
inline_for_extraction
noextract
let jump_bounded_integer
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer i))
= jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
inline_for_extraction
let jump_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (jumper (parse_bounded_integer (U32.v i)))
= jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
inline_for_extraction
noextract
let jump_bounded_integer_le
(i: integer_size) // must be a constant
: Tot (jumper (parse_bounded_integer_le i))
= jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
inline_for_extraction
val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1))
inline_for_extraction
val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2))
inline_for_extraction
val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3))
inline_for_extraction
val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
inline_for_extraction
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
inline_for_extraction
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
inline_for_extraction
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
inline_for_extraction
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
inline_for_extraction
noextract
let write_bounded_integer
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1 ()
| 2 -> write_bounded_integer_2 ()
| 3 -> write_bounded_integer_3 ()
| 4 -> write_bounded_integer_4 ()
inline_for_extraction
let write_bounded_integer'
(i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 })
: Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
= fun v #rrel #rel sl pos ->
if i = 1ul
then write_bounded_integer_1 () v sl pos
else if i = 2ul
then write_bounded_integer_2 () v sl pos
else if i = 3ul
then write_bounded_integer_3 () v sl pos
else write_bounded_integer_4 () v sl pos
inline_for_extraction
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
inline_for_extraction
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
inline_for_extraction
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
inline_for_extraction
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
inline_for_extraction
noextract
let write_bounded_integer_weak
(i: integer_size)
: Tot (leaf_writer_weak (serialize_bounded_integer i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_1_weak ()
| 2 -> write_bounded_integer_2_weak ()
| 3 -> write_bounded_integer_3_weak ()
| 4 -> write_bounded_integer_4_weak ()
val write_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_3 min32 max32 input out pos
else write_bounded_int32_4 min32 max32 input out pos
)
val read_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then read_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then read_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then read_bounded_int32_3 min32 max32 sl pos
else read_bounded_int32_4 min32 max32 sl pos
)
val validate_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_3 min32 max32 sl pos
else validate_bounded_int32_4 min32 max32 sl pos
)
val jump_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_3 min32 max32 sl pos
else jump_bounded_int32_4 min32 max32 sl pos
)
inline_for_extraction
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
inline_for_extraction
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
inline_for_extraction
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
inline_for_extraction
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
inline_for_extraction
let jump_u16_le : jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
inline_for_extraction
let jump_u32_le : jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul ()
inline_for_extraction
val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1)
inline_for_extraction
val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2)
inline_for_extraction
val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3)
inline_for_extraction
val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4)
inline_for_extraction
noextract
let read_bounded_integer_le
(i: integer_size)
: Tot (leaf_reader (parse_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> read_bounded_integer_le_1
| 2 -> read_bounded_integer_le_2
| 3 -> read_bounded_integer_le_3
| 4 -> read_bounded_integer_le_4
inline_for_extraction
val read_u16_le : leaf_reader parse_u16_le
inline_for_extraction
val read_u32_le : leaf_reader parse_u32_le
inline_for_extraction
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1)
inline_for_extraction
val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1)
inline_for_extraction
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2)
inline_for_extraction
val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2)
inline_for_extraction
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3)
inline_for_extraction
val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3)
inline_for_extraction
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4)
inline_for_extraction
val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4)
inline_for_extraction
noextract
let write_bounded_integer_le
(i: integer_size)
: Tot (leaf_writer_strong (serialize_bounded_integer_le i))
= [@inline_let]
let _ = integer_size_values i in
match i with
| 1 -> write_bounded_integer_le_1
| 2 -> write_bounded_integer_le_2
| 3 -> write_bounded_integer_le_3
| 4 -> write_bounded_integer_le_4
inline_for_extraction
val write_u16_le : leaf_writer_strong serialize_u16_le
inline_for_extraction
val write_u32_le : leaf_writer_strong serialize_u32_le
val validate_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let validate_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then validate_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then validate_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then validate_bounded_int32_le_3 min32 max32 sl pos
else validate_bounded_int32_le_4 min32 max32 sl pos
)
val jump_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let jump_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun #rrel #rel sl pos -> (
if (U32.v max32) < 256
then jump_bounded_int32_le_1 min32 max32 sl pos
else if (U32.v max32) < 65536
then jump_bounded_int32_le_2 min32 max32 sl pos
else if (U32.v max32) < 16777216
then jump_bounded_int32_le_3 min32 max32 sl pos
else jump_bounded_int32_le_4 min32 max32 sl pos
)
val write_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let write_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
= fun input #rrel #rel out pos -> (
if (U32.v max32) < 256
then write_bounded_int32_le_1 min32 max32 input out pos
else if (U32.v max32) < 65536
then write_bounded_int32_le_2 min32 max32 input out pos
else if (U32.v max32) < 16777216
then write_bounded_int32_le_3 min32 max32 input out pos
else write_bounded_int32_le_4 min32 max32 input out pos
)
val read_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val read_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val read_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val read_bounded_int32_le_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
inline_for_extraction
let read_bounded_int32_le
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) | false | false | LowParse.Low.BoundedInt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_bounded_int32_le
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
: Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BoundedInt.read_bounded_int32_le | {
"file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | {
"end_col": 3,
"end_line": 562,
"start_col": 2,
"start_line": 554
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_mul_def a p = SE.pow S.mk_k256_concrete_ops p a | let point_mul_def a p = | false | null | false | SE.pow S.mk_k256_concrete_ops p a | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"total"
] | [
"Prims.nat",
"Spec.K256.PointOps.proj_point",
"Spec.Exponentiation.pow",
"Spec.K256.mk_k256_concrete_ops"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
}
//--------------------------------------------
(**
Fast computation of [k]P in affine coordinates
*)
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in
calc (==) {
aff_point_mul k p;
(==) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
(==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
(==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
(==) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
(==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
}
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
let lemma_aff_point_mul_endo_split k p =
let r10, r20 = scalar_split_lambda k in
let lambda_p = aff_point_mul_lambda p in
let r1, p1 = aff_negate_point_and_scalar_cond r10 p in
let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in
assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else begin
if is_high1 && not is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
lemma_aff_point_mul_split_lambda k p end
else begin
if not is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else lemma_aff_point_mul_split_lambda k p
end
end
//---------------------------------
val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
let lemma_ecmult_endo_split_to_aff k p =
let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
assert (r1 == ar1 /\ r2 == ar2);
let r10, r20 = scalar_split_lambda k in
let p_aff = S.to_aff_point p in
let lambda_p = point_mul_lambda p in
let lambda_p_aff = aff_point_mul_lambda p_aff in
lemma_glv p; lemma_glv_aff p_aff;
assert (S.to_aff_point lambda_p == lambda_p_aff);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if not is_high1 && not is_high2 then ()
else begin
if not is_high1 && is_high2 then
LS.to_aff_point_negate_lemma lambda_p
else begin
if is_high1 && not is_high2 then
LS.to_aff_point_negate_lemma p
else begin
LS.to_aff_point_negate_lemma p;
LS.to_aff_point_negate_lemma lambda_p
end
end
end
(**
Fast computation of [k1]P1 + [k2]P2 in projective coordinates
*)
// [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2
// = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2)
// = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y)
let aff_proj_point_mul_double_split_lambda
(k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then
LE.exp_four_fw S.mk_k256_comm_monoid
(S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12
(S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5
else
S.to_aff_point (S.point_mul_double k1 p1 k2 p2)
val lemma_aff_proj_point_mul_double_split_lambda:
k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point ->
Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 ==
S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2)))
let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then begin
let p1_aff = S.to_aff_point p1 in
let p2_aff = S.to_aff_point p2 in
let p11_aff = S.to_aff_point p11 in
let p12_aff = S.to_aff_point p12 in
let p21_aff = S.to_aff_point p21 in
let p22_aff = S.to_aff_point p22 in
calc (==) {
aff_proj_point_mul_double_split_lambda k1 p1 k2 p2;
(==) {
LE.exp_four_fw_lemma S.mk_k256_comm_monoid
p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 }
S.aff_point_add
(S.aff_point_add
(S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff))
(aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
(==) { lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1 }
S.aff_point_add
(S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
(==) { LS.aff_point_add_assoc_lemma
(aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) }
S.aff_point_add (aff_point_mul k1 p1_aff)
(S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff));
(==) { lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2 }
S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff);
} end
else begin
SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5;
LE.exp_double_fw_lemma S.mk_k256_comm_monoid
(S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 end
//----------------------------------- | false | true | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_mul_def : a: Prims.nat -> p: Spec.K256.PointOps.proj_point -> Spec.K256.PointOps.proj_point | [] | Hacl.Spec.K256.GLV.Lemmas.point_mul_def | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.nat -> p: Spec.K256.PointOps.proj_point -> Spec.K256.PointOps.proj_point | {
"end_col": 57,
"end_line": 236,
"start_col": 24,
"start_line": 236
} |
|
Prims.Tot | val aff_proj_point_mul_double_split_lambda
(k1: S.qelem)
(p1: S.proj_point)
(k2: S.qelem)
(p2: S.proj_point)
: S.aff_point | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_proj_point_mul_double_split_lambda
(k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then
LE.exp_four_fw S.mk_k256_comm_monoid
(S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12
(S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5
else
S.to_aff_point (S.point_mul_double k1 p1 k2 p2) | val aff_proj_point_mul_double_split_lambda
(k1: S.qelem)
(p1: S.proj_point)
(k2: S.qelem)
(p2: S.proj_point)
: S.aff_point
let aff_proj_point_mul_double_split_lambda
(k1: S.qelem)
(p1: S.proj_point)
(k2: S.qelem)
(p2: S.proj_point)
: S.aff_point = | false | null | false | let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128
then
LE.exp_four_fw S.mk_k256_comm_monoid (S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12
(S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5
else S.to_aff_point (S.point_mul_double k1 p1 k2 p2) | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.qelem",
"Spec.K256.PointOps.proj_point",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"Prims.pow2",
"Lib.Exponentiation.exp_four_fw",
"Spec.K256.PointOps.aff_point",
"Spec.K256.mk_k256_comm_monoid",
"Spec.K256.PointOps.to_aff_point",
"Prims.bool",
"Spec.K256.point_mul_double",
"FStar.Pervasives.Native.tuple4",
"Hacl.Spec.K256.GLV.ecmult_endo_split"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
}
//--------------------------------------------
(**
Fast computation of [k]P in affine coordinates
*)
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in
calc (==) {
aff_point_mul k p;
(==) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
(==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
(==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
(==) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
(==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
}
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
let lemma_aff_point_mul_endo_split k p =
let r10, r20 = scalar_split_lambda k in
let lambda_p = aff_point_mul_lambda p in
let r1, p1 = aff_negate_point_and_scalar_cond r10 p in
let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in
assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else begin
if is_high1 && not is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
lemma_aff_point_mul_split_lambda k p end
else begin
if not is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else lemma_aff_point_mul_split_lambda k p
end
end
//---------------------------------
val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
let lemma_ecmult_endo_split_to_aff k p =
let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
assert (r1 == ar1 /\ r2 == ar2);
let r10, r20 = scalar_split_lambda k in
let p_aff = S.to_aff_point p in
let lambda_p = point_mul_lambda p in
let lambda_p_aff = aff_point_mul_lambda p_aff in
lemma_glv p; lemma_glv_aff p_aff;
assert (S.to_aff_point lambda_p == lambda_p_aff);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if not is_high1 && not is_high2 then ()
else begin
if not is_high1 && is_high2 then
LS.to_aff_point_negate_lemma lambda_p
else begin
if is_high1 && not is_high2 then
LS.to_aff_point_negate_lemma p
else begin
LS.to_aff_point_negate_lemma p;
LS.to_aff_point_negate_lemma lambda_p
end
end
end
(**
Fast computation of [k1]P1 + [k2]P2 in projective coordinates
*)
// [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2
// = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2)
// = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y) | false | true | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_proj_point_mul_double_split_lambda
(k1: S.qelem)
(p1: S.proj_point)
(k2: S.qelem)
(p2: S.proj_point)
: S.aff_point | [] | Hacl.Spec.K256.GLV.Lemmas.aff_proj_point_mul_double_split_lambda | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
k1: Spec.K256.PointOps.qelem ->
p1: Spec.K256.PointOps.proj_point ->
k2: Spec.K256.PointOps.qelem ->
p2: Spec.K256.PointOps.proj_point
-> Spec.K256.PointOps.aff_point | {
"end_col": 51,
"end_line": 187,
"start_col": 79,
"start_line": 179
} |
FStar.Pervasives.Lemma | val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) | val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p = | false | null | true | let pX, pY, pZ = p in
let px, py = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let qx, qy = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let rX, rY, rZ = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let rx, ry = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"lemma"
] | [
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.felem",
"Prims._assert",
"Prims.b2t",
"Prims.op_Equality",
"Spec.K256.PointOps.op_Star_Percent",
"Hacl.Spec.K256.GLV.beta",
"Spec.K256.PointOps.finv",
"Prims.unit",
"Lib.NatMod.lemma_mul_mod_assoc",
"Spec.K256.PointOps.prime",
"Spec.K256.PointOps.op_Slash_Percent",
"Prims.l_and",
"Spec.K256.PointOps.aff_point",
"Spec.K256.PointOps.to_aff_point",
"FStar.Pervasives.Native.Mktuple3",
"Hacl.Spec.K256.GLV.point_mul_lambda",
"Hacl.Spec.K256.GLV.Lemmas.lemma_glv_aff",
"FStar.Pervasives.Native.Mktuple2",
"Hacl.Spec.K256.GLV.aff_point_mul",
"Hacl.Spec.K256.GLV.lambda"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) | false | false | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) | [] | Hacl.Spec.K256.GLV.Lemmas.lemma_glv | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.proj_point
-> FStar.Pervasives.Lemma
(ensures
Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.point_mul_lambda p) ==
Hacl.Spec.K256.GLV.aff_point_mul Hacl.Spec.K256.GLV.lambda (Spec.K256.PointOps.to_aff_point p)
) | {
"end_col": 70,
"end_line": 43,
"start_col": 17,
"start_line": 24
} |
FStar.Pervasives.Lemma | val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate ==
aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate))) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_negate_cond_pow_lemma is_negate p k =
let p_aff = S.to_aff_point p in
if is_negate then
calc (==) {
S.aff_point_negate (S.to_aff_point (point_mul_def k p));
(==) { SE.pow_lemma S.mk_k256_concrete_ops p k }
S.aff_point_negate (aff_point_mul k p_aff);
(==) { SM.aff_point_mul_neg_lemma k p_aff }
aff_point_mul k (S.aff_point_negate p_aff);
(==) { LS.to_aff_point_negate_lemma p }
aff_point_mul k (S.to_aff_point (S.point_negate p));
}
else
SE.pow_lemma S.mk_k256_concrete_ops p k | val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate ==
aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate)))
let aff_point_negate_cond_pow_lemma is_negate p k = | false | null | true | let p_aff = S.to_aff_point p in
if is_negate
then
calc ( == ) {
S.aff_point_negate (S.to_aff_point (point_mul_def k p));
( == ) { SE.pow_lemma S.mk_k256_concrete_ops p k }
S.aff_point_negate (aff_point_mul k p_aff);
( == ) { SM.aff_point_mul_neg_lemma k p_aff }
aff_point_mul k (S.aff_point_negate p_aff);
( == ) { LS.to_aff_point_negate_lemma p }
aff_point_mul k (S.to_aff_point (S.point_negate p));
}
else SE.pow_lemma S.mk_k256_concrete_ops p k | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.bool",
"Spec.K256.PointOps.proj_point",
"Prims.nat",
"FStar.Calc.calc_finish",
"Spec.K256.PointOps.aff_point",
"Prims.eq2",
"Spec.K256.PointOps.aff_point_negate",
"Spec.K256.PointOps.to_aff_point",
"Hacl.Spec.K256.GLV.Lemmas.point_mul_def",
"Hacl.Spec.K256.GLV.aff_point_mul",
"Spec.K256.PointOps.point_negate",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Spec.Exponentiation.pow_lemma",
"Spec.K256.mk_k256_concrete_ops",
"Prims.squash",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg_lemma",
"Spec.K256.Lemmas.to_aff_point_negate_lemma"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
}
//--------------------------------------------
(**
Fast computation of [k]P in affine coordinates
*)
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in
calc (==) {
aff_point_mul k p;
(==) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
(==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
(==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
(==) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
(==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
}
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
let lemma_aff_point_mul_endo_split k p =
let r10, r20 = scalar_split_lambda k in
let lambda_p = aff_point_mul_lambda p in
let r1, p1 = aff_negate_point_and_scalar_cond r10 p in
let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in
assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else begin
if is_high1 && not is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
lemma_aff_point_mul_split_lambda k p end
else begin
if not is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else lemma_aff_point_mul_split_lambda k p
end
end
//---------------------------------
val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
let lemma_ecmult_endo_split_to_aff k p =
let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
assert (r1 == ar1 /\ r2 == ar2);
let r10, r20 = scalar_split_lambda k in
let p_aff = S.to_aff_point p in
let lambda_p = point_mul_lambda p in
let lambda_p_aff = aff_point_mul_lambda p_aff in
lemma_glv p; lemma_glv_aff p_aff;
assert (S.to_aff_point lambda_p == lambda_p_aff);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if not is_high1 && not is_high2 then ()
else begin
if not is_high1 && is_high2 then
LS.to_aff_point_negate_lemma lambda_p
else begin
if is_high1 && not is_high2 then
LS.to_aff_point_negate_lemma p
else begin
LS.to_aff_point_negate_lemma p;
LS.to_aff_point_negate_lemma lambda_p
end
end
end
(**
Fast computation of [k1]P1 + [k2]P2 in projective coordinates
*)
// [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2
// = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2)
// = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y)
let aff_proj_point_mul_double_split_lambda
(k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then
LE.exp_four_fw S.mk_k256_comm_monoid
(S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12
(S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5
else
S.to_aff_point (S.point_mul_double k1 p1 k2 p2)
val lemma_aff_proj_point_mul_double_split_lambda:
k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point ->
Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 ==
S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2)))
let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then begin
let p1_aff = S.to_aff_point p1 in
let p2_aff = S.to_aff_point p2 in
let p11_aff = S.to_aff_point p11 in
let p12_aff = S.to_aff_point p12 in
let p21_aff = S.to_aff_point p21 in
let p22_aff = S.to_aff_point p22 in
calc (==) {
aff_proj_point_mul_double_split_lambda k1 p1 k2 p2;
(==) {
LE.exp_four_fw_lemma S.mk_k256_comm_monoid
p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 }
S.aff_point_add
(S.aff_point_add
(S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff))
(aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
(==) { lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1 }
S.aff_point_add
(S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
(==) { LS.aff_point_add_assoc_lemma
(aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) }
S.aff_point_add (aff_point_mul k1 p1_aff)
(S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff));
(==) { lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2 }
S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff);
} end
else begin
SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5;
LE.exp_double_fw_lemma S.mk_k256_comm_monoid
(S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 end
//-----------------------------------
// [a]P in projective coordinates for a >= 0
let point_mul_def a p = SE.pow S.mk_k256_concrete_ops p a
// [k]P or -[k]P = [k](-P)
val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate ==
aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate))) | false | false | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate ==
aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate))) | [] | Hacl.Spec.K256.GLV.Lemmas.aff_point_negate_cond_pow_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | is_negate: Prims.bool -> p: Spec.K256.PointOps.proj_point -> k: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.GLV.aff_point_negate_cond (Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.Lemmas.point_mul_def
k
p))
is_negate ==
Hacl.Spec.K256.GLV.aff_point_mul k
(Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.point_negate_cond p is_negate))) | {
"end_col": 43,
"end_line": 256,
"start_col": 51,
"start_line": 243
} |
FStar.Pervasives.Lemma | val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_point_mul_endo_split k p =
let r10, r20 = scalar_split_lambda k in
let lambda_p = aff_point_mul_lambda p in
let r1, p1 = aff_negate_point_and_scalar_cond r10 p in
let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in
assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else begin
if is_high1 && not is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
lemma_aff_point_mul_split_lambda k p end
else begin
if not is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else lemma_aff_point_mul_split_lambda k p
end
end | val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
let lemma_aff_point_mul_endo_split k p = | false | null | true | let r10, r20 = scalar_split_lambda k in
let lambda_p = aff_point_mul_lambda p in
let r1, p1 = aff_negate_point_and_scalar_cond r10 p in
let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in
assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if is_high1 && is_high2
then
(SM.lemma_aff_point_mul_neg r10 p;
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p)
else
if is_high1 && not is_high2
then
(SM.lemma_aff_point_mul_neg r10 p;
lemma_aff_point_mul_split_lambda k p)
else
if not is_high1 && is_high2
then
(SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p)
else lemma_aff_point_mul_split_lambda k p | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"lemma"
] | [
"Spec.K256.PointOps.qelem",
"Spec.K256.PointOps.aff_point",
"Prims.op_AmpAmp",
"Hacl.Spec.K256.GLV.Lemmas.lemma_aff_point_mul_split_lambda",
"Prims.unit",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg",
"Prims.bool",
"Prims.op_Negation",
"Spec.K256.PointOps.scalar_is_high",
"Prims._assert",
"Prims.eq2",
"FStar.Pervasives.Native.tuple4",
"FStar.Pervasives.Native.Mktuple4",
"Hacl.Spec.K256.GLV.aff_ecmult_endo_split",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.K256.GLV.aff_negate_point_and_scalar_cond",
"Hacl.Spec.K256.GLV.aff_point_mul_lambda",
"Hacl.Spec.K256.GLV.scalar_split_lambda"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
}
//--------------------------------------------
(**
Fast computation of [k]P in affine coordinates
*)
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in
calc (==) {
aff_point_mul k p;
(==) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
(==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
(==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
(==) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
(==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
}
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) | false | false | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) | [] | Hacl.Spec.K256.GLV.Lemmas.lemma_aff_point_mul_endo_split | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Spec.K256.PointOps.qelem -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures Hacl.Spec.K256.GLV.aff_point_mul_endo_split k p == Hacl.Spec.K256.GLV.aff_point_mul k p
) | {
"end_col": 5,
"end_line": 132,
"start_col": 40,
"start_line": 109
} |
FStar.Pervasives.Lemma | val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_ecmult_endo_split_to_aff k p =
let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
assert (r1 == ar1 /\ r2 == ar2);
let r10, r20 = scalar_split_lambda k in
let p_aff = S.to_aff_point p in
let lambda_p = point_mul_lambda p in
let lambda_p_aff = aff_point_mul_lambda p_aff in
lemma_glv p; lemma_glv_aff p_aff;
assert (S.to_aff_point lambda_p == lambda_p_aff);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if not is_high1 && not is_high2 then ()
else begin
if not is_high1 && is_high2 then
LS.to_aff_point_negate_lemma lambda_p
else begin
if is_high1 && not is_high2 then
LS.to_aff_point_negate_lemma p
else begin
LS.to_aff_point_negate_lemma p;
LS.to_aff_point_negate_lemma lambda_p
end
end
end | val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
let lemma_ecmult_endo_split_to_aff k p = | false | null | true | let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
assert (r1 == ar1 /\ r2 == ar2);
let r10, r20 = scalar_split_lambda k in
let p_aff = S.to_aff_point p in
let lambda_p = point_mul_lambda p in
let lambda_p_aff = aff_point_mul_lambda p_aff in
lemma_glv p;
lemma_glv_aff p_aff;
assert (S.to_aff_point lambda_p == lambda_p_aff);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if not is_high1 && not is_high2
then ()
else
if not is_high1 && is_high2
then LS.to_aff_point_negate_lemma lambda_p
else
if is_high1 && not is_high2
then LS.to_aff_point_negate_lemma p
else
(LS.to_aff_point_negate_lemma p;
LS.to_aff_point_negate_lemma lambda_p) | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"lemma"
] | [
"Spec.K256.PointOps.qelem",
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.aff_point",
"Prims.op_AmpAmp",
"Prims.op_Negation",
"Prims.bool",
"Spec.K256.Lemmas.to_aff_point_negate_lemma",
"Prims.unit",
"Spec.K256.PointOps.scalar_is_high",
"Prims._assert",
"Prims.eq2",
"Spec.K256.PointOps.to_aff_point",
"Hacl.Spec.K256.GLV.Lemmas.lemma_glv_aff",
"Hacl.Spec.K256.GLV.Lemmas.lemma_glv",
"Hacl.Spec.K256.GLV.aff_point_mul_lambda",
"Hacl.Spec.K256.GLV.point_mul_lambda",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.K256.GLV.scalar_split_lambda",
"Prims.l_and",
"FStar.Pervasives.Native.tuple4",
"Hacl.Spec.K256.GLV.aff_ecmult_endo_split",
"Hacl.Spec.K256.GLV.ecmult_endo_split"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
}
//--------------------------------------------
(**
Fast computation of [k]P in affine coordinates
*)
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in
calc (==) {
aff_point_mul k p;
(==) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
(==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
(==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
(==) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
(==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
}
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
let lemma_aff_point_mul_endo_split k p =
let r10, r20 = scalar_split_lambda k in
let lambda_p = aff_point_mul_lambda p in
let r1, p1 = aff_negate_point_and_scalar_cond r10 p in
let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in
assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else begin
if is_high1 && not is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
lemma_aff_point_mul_split_lambda k p end
else begin
if not is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else lemma_aff_point_mul_split_lambda k p
end
end
//---------------------------------
val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2) | false | false | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2) | [] | Hacl.Spec.K256.GLV.Lemmas.lemma_ecmult_endo_split_to_aff | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Spec.K256.PointOps.qelem -> p: Spec.K256.PointOps.proj_point
-> FStar.Pervasives.Lemma
(ensures
(let _ = Hacl.Spec.K256.GLV.ecmult_endo_split k p in
(let FStar.Pervasives.Native.Mktuple4 #_ #_ #_ #_ r1 p1 r2 p2 = _ in
let _ = Hacl.Spec.K256.GLV.aff_ecmult_endo_split k (Spec.K256.PointOps.to_aff_point p) in
(let FStar.Pervasives.Native.Mktuple4 #_ #_ #_ #_ ar1 ap1 ar2 ap2 = _ in
r1 == ar1 /\ Spec.K256.PointOps.to_aff_point p1 == ap1 /\ r2 == ar2 /\
Spec.K256.PointOps.to_aff_point p2 == ap2)
<:
Type0)
<:
Type0)) | {
"end_col": 5,
"end_line": 168,
"start_col": 40,
"start_line": 141
} |
FStar.Pervasives.Lemma | val aff_point_negate_cond_lambda_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_mul lambda (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate) ==
aff_point_mul k (S.to_aff_point (point_negate_cond (point_mul_lambda p) is_negate))) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_negate_cond_lambda_pow_lemma is_negate p k =
let p_aff = S.to_aff_point p in
let p_lambda = point_mul_lambda p in
if is_negate then
calc (==) {
aff_point_mul lambda (S.aff_point_negate (S.to_aff_point (point_mul_def k p)));
(==) { SE.pow_lemma S.mk_k256_concrete_ops p k }
aff_point_mul lambda (S.aff_point_negate (aff_point_mul k p_aff));
(==) { SM.aff_point_mul_mul_neg_lemma lambda k p_aff }
aff_point_mul k (S.aff_point_negate (aff_point_mul lambda p_aff));
(==) { lemma_glv p }
aff_point_mul k (S.aff_point_negate (S.to_aff_point p_lambda));
(==) { LS.to_aff_point_negate_lemma p_lambda }
aff_point_mul k (S.to_aff_point (S.point_negate p_lambda));
}
else
calc (==) {
aff_point_mul lambda (S.to_aff_point (point_mul_def k p));
(==) { SE.pow_lemma S.mk_k256_concrete_ops p k }
aff_point_mul lambda (aff_point_mul k p_aff);
(==) { SM.aff_point_mul_mul_lemma lambda k p_aff }
aff_point_mul k (aff_point_mul lambda p_aff);
(==) { lemma_glv p }
aff_point_mul k (S.to_aff_point p_lambda);
} | val aff_point_negate_cond_lambda_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_mul lambda (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate) ==
aff_point_mul k (S.to_aff_point (point_negate_cond (point_mul_lambda p) is_negate)))
let aff_point_negate_cond_lambda_pow_lemma is_negate p k = | false | null | true | let p_aff = S.to_aff_point p in
let p_lambda = point_mul_lambda p in
if is_negate
then
calc ( == ) {
aff_point_mul lambda (S.aff_point_negate (S.to_aff_point (point_mul_def k p)));
( == ) { SE.pow_lemma S.mk_k256_concrete_ops p k }
aff_point_mul lambda (S.aff_point_negate (aff_point_mul k p_aff));
( == ) { SM.aff_point_mul_mul_neg_lemma lambda k p_aff }
aff_point_mul k (S.aff_point_negate (aff_point_mul lambda p_aff));
( == ) { lemma_glv p }
aff_point_mul k (S.aff_point_negate (S.to_aff_point p_lambda));
( == ) { LS.to_aff_point_negate_lemma p_lambda }
aff_point_mul k (S.to_aff_point (S.point_negate p_lambda));
}
else
calc ( == ) {
aff_point_mul lambda (S.to_aff_point (point_mul_def k p));
( == ) { SE.pow_lemma S.mk_k256_concrete_ops p k }
aff_point_mul lambda (aff_point_mul k p_aff);
( == ) { SM.aff_point_mul_mul_lemma lambda k p_aff }
aff_point_mul k (aff_point_mul lambda p_aff);
( == ) { lemma_glv p }
aff_point_mul k (S.to_aff_point p_lambda);
} | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.bool",
"Spec.K256.PointOps.proj_point",
"Prims.nat",
"FStar.Calc.calc_finish",
"Spec.K256.PointOps.aff_point",
"Prims.eq2",
"Hacl.Spec.K256.GLV.aff_point_mul",
"Hacl.Spec.K256.GLV.lambda",
"Spec.K256.PointOps.aff_point_negate",
"Spec.K256.PointOps.to_aff_point",
"Hacl.Spec.K256.GLV.Lemmas.point_mul_def",
"Spec.K256.PointOps.point_negate",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Spec.Exponentiation.pow_lemma",
"Spec.K256.mk_k256_concrete_ops",
"Prims.squash",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_mul_neg_lemma",
"Hacl.Spec.K256.GLV.Lemmas.lemma_glv",
"Spec.K256.Lemmas.to_aff_point_negate_lemma",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_mul_lemma",
"Hacl.Spec.K256.GLV.point_mul_lambda"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
}
//--------------------------------------------
(**
Fast computation of [k]P in affine coordinates
*)
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in
calc (==) {
aff_point_mul k p;
(==) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
(==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
(==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
(==) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
(==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
}
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
let lemma_aff_point_mul_endo_split k p =
let r10, r20 = scalar_split_lambda k in
let lambda_p = aff_point_mul_lambda p in
let r1, p1 = aff_negate_point_and_scalar_cond r10 p in
let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in
assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else begin
if is_high1 && not is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
lemma_aff_point_mul_split_lambda k p end
else begin
if not is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else lemma_aff_point_mul_split_lambda k p
end
end
//---------------------------------
val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
let lemma_ecmult_endo_split_to_aff k p =
let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
assert (r1 == ar1 /\ r2 == ar2);
let r10, r20 = scalar_split_lambda k in
let p_aff = S.to_aff_point p in
let lambda_p = point_mul_lambda p in
let lambda_p_aff = aff_point_mul_lambda p_aff in
lemma_glv p; lemma_glv_aff p_aff;
assert (S.to_aff_point lambda_p == lambda_p_aff);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if not is_high1 && not is_high2 then ()
else begin
if not is_high1 && is_high2 then
LS.to_aff_point_negate_lemma lambda_p
else begin
if is_high1 && not is_high2 then
LS.to_aff_point_negate_lemma p
else begin
LS.to_aff_point_negate_lemma p;
LS.to_aff_point_negate_lemma lambda_p
end
end
end
(**
Fast computation of [k1]P1 + [k2]P2 in projective coordinates
*)
// [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2
// = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2)
// = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y)
let aff_proj_point_mul_double_split_lambda
(k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then
LE.exp_four_fw S.mk_k256_comm_monoid
(S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12
(S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5
else
S.to_aff_point (S.point_mul_double k1 p1 k2 p2)
val lemma_aff_proj_point_mul_double_split_lambda:
k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point ->
Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 ==
S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2)))
let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then begin
let p1_aff = S.to_aff_point p1 in
let p2_aff = S.to_aff_point p2 in
let p11_aff = S.to_aff_point p11 in
let p12_aff = S.to_aff_point p12 in
let p21_aff = S.to_aff_point p21 in
let p22_aff = S.to_aff_point p22 in
calc (==) {
aff_proj_point_mul_double_split_lambda k1 p1 k2 p2;
(==) {
LE.exp_four_fw_lemma S.mk_k256_comm_monoid
p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 }
S.aff_point_add
(S.aff_point_add
(S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff))
(aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
(==) { lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1 }
S.aff_point_add
(S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
(==) { LS.aff_point_add_assoc_lemma
(aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) }
S.aff_point_add (aff_point_mul k1 p1_aff)
(S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff));
(==) { lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2 }
S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff);
} end
else begin
SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5;
LE.exp_double_fw_lemma S.mk_k256_comm_monoid
(S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 end
//-----------------------------------
// [a]P in projective coordinates for a >= 0
let point_mul_def a p = SE.pow S.mk_k256_concrete_ops p a
// [k]P or -[k]P = [k](-P)
val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate ==
aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate)))
let aff_point_negate_cond_pow_lemma is_negate p k =
let p_aff = S.to_aff_point p in
if is_negate then
calc (==) {
S.aff_point_negate (S.to_aff_point (point_mul_def k p));
(==) { SE.pow_lemma S.mk_k256_concrete_ops p k }
S.aff_point_negate (aff_point_mul k p_aff);
(==) { SM.aff_point_mul_neg_lemma k p_aff }
aff_point_mul k (S.aff_point_negate p_aff);
(==) { LS.to_aff_point_negate_lemma p }
aff_point_mul k (S.to_aff_point (S.point_negate p));
}
else
SE.pow_lemma S.mk_k256_concrete_ops p k
// [k]([lambda]P) = [lambda]([k]P) or [k](-[lambda]P) = [lambda](-[k]P)
val aff_point_negate_cond_lambda_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_mul lambda (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate) ==
aff_point_mul k (S.to_aff_point (point_negate_cond (point_mul_lambda p) is_negate))) | false | false | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_negate_cond_lambda_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma
(aff_point_mul lambda (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate) ==
aff_point_mul k (S.to_aff_point (point_negate_cond (point_mul_lambda p) is_negate))) | [] | Hacl.Spec.K256.GLV.Lemmas.aff_point_negate_cond_lambda_pow_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | is_negate: Prims.bool -> p: Spec.K256.PointOps.proj_point -> k: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.GLV.aff_point_mul Hacl.Spec.K256.GLV.lambda
(Hacl.Spec.K256.GLV.aff_point_negate_cond (Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.Lemmas.point_mul_def
k
p))
is_negate) ==
Hacl.Spec.K256.GLV.aff_point_mul k
(Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.point_negate_cond (Hacl.Spec.K256.GLV.point_mul_lambda
p)
is_negate))) | {
"end_col": 5,
"end_line": 289,
"start_col": 58,
"start_line": 264
} |
FStar.Pervasives.Lemma | val lemma_aff_proj_point_mul_double_split_lambda:
k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point ->
Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 ==
S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2))) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then begin
let p1_aff = S.to_aff_point p1 in
let p2_aff = S.to_aff_point p2 in
let p11_aff = S.to_aff_point p11 in
let p12_aff = S.to_aff_point p12 in
let p21_aff = S.to_aff_point p21 in
let p22_aff = S.to_aff_point p22 in
calc (==) {
aff_proj_point_mul_double_split_lambda k1 p1 k2 p2;
(==) {
LE.exp_four_fw_lemma S.mk_k256_comm_monoid
p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 }
S.aff_point_add
(S.aff_point_add
(S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff))
(aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
(==) { lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1 }
S.aff_point_add
(S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
(==) { LS.aff_point_add_assoc_lemma
(aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) }
S.aff_point_add (aff_point_mul k1 p1_aff)
(S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff));
(==) { lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2 }
S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff);
} end
else begin
SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5;
LE.exp_double_fw_lemma S.mk_k256_comm_monoid
(S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 end | val lemma_aff_proj_point_mul_double_split_lambda:
k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point ->
Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 ==
S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2)))
let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 = | false | null | true | let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128
then
let p1_aff = S.to_aff_point p1 in
let p2_aff = S.to_aff_point p2 in
let p11_aff = S.to_aff_point p11 in
let p12_aff = S.to_aff_point p12 in
let p21_aff = S.to_aff_point p21 in
let p22_aff = S.to_aff_point p22 in
calc ( == ) {
aff_proj_point_mul_double_split_lambda k1 p1 k2 p2;
( == ) { LE.exp_four_fw_lemma S.mk_k256_comm_monoid p11_aff 128 r11 p12_aff r12 p21_aff r21
p22_aff r22 5 }
S.aff_point_add (S.aff_point_add (S.aff_point_add (aff_point_mul r11 p11_aff)
(aff_point_mul r12 p12_aff))
(aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
( == ) { (lemma_aff_point_mul_endo_split k1 p1_aff;
lemma_ecmult_endo_split_to_aff k1 p1) }
S.aff_point_add (S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff))
(aff_point_mul r22 p22_aff);
( == ) { LS.aff_point_add_assoc_lemma (aff_point_mul k1 p1_aff)
(aff_point_mul r21 p21_aff)
(aff_point_mul r22 p22_aff) }
S.aff_point_add (aff_point_mul k1 p1_aff)
(S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff));
( == ) { (lemma_aff_point_mul_endo_split k2 p2_aff;
lemma_ecmult_endo_split_to_aff k2 p2) }
S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff);
}
else
(SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5;
LE.exp_double_fw_lemma S.mk_k256_comm_monoid (S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5
) | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"lemma"
] | [
"Spec.K256.PointOps.qelem",
"Spec.K256.PointOps.proj_point",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Calc.calc_finish",
"Spec.K256.PointOps.aff_point",
"Prims.eq2",
"Hacl.Spec.K256.GLV.Lemmas.aff_proj_point_mul_double_split_lambda",
"Spec.K256.PointOps.aff_point_add",
"Hacl.Spec.K256.GLV.aff_point_mul",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Lib.Exponentiation.exp_four_fw_lemma",
"Spec.K256.mk_k256_comm_monoid",
"Prims.squash",
"Hacl.Spec.K256.GLV.Lemmas.lemma_ecmult_endo_split_to_aff",
"Hacl.Spec.K256.GLV.Lemmas.lemma_aff_point_mul_endo_split",
"Spec.K256.Lemmas.aff_point_add_assoc_lemma",
"Spec.K256.PointOps.to_aff_point",
"Prims.bool",
"Lib.Exponentiation.exp_double_fw_lemma",
"Spec.Exponentiation.exp_double_fw_lemma",
"Spec.K256.mk_k256_concrete_ops",
"FStar.Pervasives.Native.tuple4",
"Hacl.Spec.K256.GLV.ecmult_endo_split"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
}
//--------------------------------------------
(**
Fast computation of [k]P in affine coordinates
*)
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in
calc (==) {
aff_point_mul k p;
(==) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
(==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
(==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
(==) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
(==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
}
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
let lemma_aff_point_mul_endo_split k p =
let r10, r20 = scalar_split_lambda k in
let lambda_p = aff_point_mul_lambda p in
let r1, p1 = aff_negate_point_and_scalar_cond r10 p in
let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in
assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else begin
if is_high1 && not is_high2 then begin
SM.lemma_aff_point_mul_neg r10 p;
lemma_aff_point_mul_split_lambda k p end
else begin
if not is_high1 && is_high2 then begin
SM.lemma_aff_point_mul_neg r20 lambda_p;
lemma_aff_point_mul_split_lambda k p end
else lemma_aff_point_mul_split_lambda k p
end
end
//---------------------------------
val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma
(let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
let lemma_ecmult_endo_split_to_aff k p =
let r1, p1, r2, p2 = ecmult_endo_split k p in
let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in
assert (r1 == ar1 /\ r2 == ar2);
let r10, r20 = scalar_split_lambda k in
let p_aff = S.to_aff_point p in
let lambda_p = point_mul_lambda p in
let lambda_p_aff = aff_point_mul_lambda p_aff in
lemma_glv p; lemma_glv_aff p_aff;
assert (S.to_aff_point lambda_p == lambda_p_aff);
let is_high1 = S.scalar_is_high r10 in
let is_high2 = S.scalar_is_high r20 in
if not is_high1 && not is_high2 then ()
else begin
if not is_high1 && is_high2 then
LS.to_aff_point_negate_lemma lambda_p
else begin
if is_high1 && not is_high2 then
LS.to_aff_point_negate_lemma p
else begin
LS.to_aff_point_negate_lemma p;
LS.to_aff_point_negate_lemma lambda_p
end
end
end
(**
Fast computation of [k1]P1 + [k2]P2 in projective coordinates
*)
// [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2
// = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2)
// = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y)
let aff_proj_point_mul_double_split_lambda
(k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in
let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in
if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then
LE.exp_four_fw S.mk_k256_comm_monoid
(S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12
(S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5
else
S.to_aff_point (S.point_mul_double k1 p1 k2 p2)
val lemma_aff_proj_point_mul_double_split_lambda:
k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point ->
Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 ==
S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2))) | false | false | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_proj_point_mul_double_split_lambda:
k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point ->
Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 ==
S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2))) | [] | Hacl.Spec.K256.GLV.Lemmas.lemma_aff_proj_point_mul_double_split_lambda | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
k1: Spec.K256.PointOps.qelem ->
p1: Spec.K256.PointOps.proj_point ->
k2: Spec.K256.PointOps.qelem ->
p2: Spec.K256.PointOps.proj_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.GLV.Lemmas.aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 ==
Spec.K256.PointOps.aff_point_add (Hacl.Spec.K256.GLV.aff_point_mul k1
(Spec.K256.PointOps.to_aff_point p1))
(Hacl.Spec.K256.GLV.aff_point_mul k2 (Spec.K256.PointOps.to_aff_point p2))) | {
"end_col": 61,
"end_line": 231,
"start_col": 62,
"start_line": 195
} |
FStar.Pervasives.Lemma | val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
} | val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k = | false | null | true | assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc ( == ) {
(r1 + (r2 * lambda % S.q)) % S.q;
( == ) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
( == ) { () }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
( == ) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
( == ) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
( == ) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
( == ) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
( == ) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
( == ) { () }
k % S.q;
( == ) { Math.Lemmas.small_mod k S.q }
k;
} | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"lemma"
] | [
"Spec.K256.PointOps.qelem",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Modulus",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Hacl.Spec.K256.GLV.lambda",
"Spec.K256.PointOps.q",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Hacl.Spec.K256.GLV.minus_lambda",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_plus_distr_l",
"FStar.Math.Lemmas.distributivity_add_right",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"FStar.Math.Lemmas.small_mod",
"Prims._assert",
"Prims.b2t",
"Prims.op_Equality",
"Spec.K256.PointOps.op_Plus_Hat",
"Spec.K256.PointOps.op_Star_Hat",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.K256.GLV.scalar_split_lambda",
"FStar.Pervasives.assert_norm"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) | false | false | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) | [] | Hacl.Spec.K256.GLV.Lemmas.lemma_scalar_split_lambda_eval | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Spec.K256.PointOps.qelem
-> FStar.Pervasives.Lemma
(ensures
(let _ = Hacl.Spec.K256.GLV.scalar_split_lambda k in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ r1 r2 = _ in
k == r1 +^ r2 *^ Hacl.Spec.K256.GLV.lambda)
<:
Type0)) | {
"end_col": 3,
"end_line": 75,
"start_col": 2,
"start_line": 51
} |
FStar.Pervasives.Lemma | val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.ECSM.Lemmas",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in
calc (==) {
aff_point_mul k p;
(==) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
(==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
(==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
(==) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
(==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
} | val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p = | false | null | true | let r1, r2 = scalar_split_lambda k in
calc ( == ) {
aff_point_mul k p;
( == ) { lemma_scalar_split_lambda_eval k }
aff_point_mul S.(r1 +^ r2 *^ lambda) p;
( == ) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
aff_point_mul ((r1 + r2 * lambda) % S.q) p;
( == ) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p }
aff_point_mul (r1 + r2 * lambda) p;
( == ) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p);
( == ) { lemma_glv_aff p }
S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p);
( == ) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p))
(aff_point_mul r1 p) }
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p));
} | {
"checked_file": "Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.GLV.Lemmas.fst"
} | [
"lemma"
] | [
"Spec.K256.PointOps.qelem",
"Spec.K256.PointOps.aff_point",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Hacl.Spec.K256.GLV.aff_point_mul",
"Spec.K256.PointOps.aff_point_add",
"Hacl.Spec.K256.GLV.aff_point_mul_lambda",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Hacl.Spec.K256.GLV.lambda",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Modulus",
"Spec.K256.PointOps.q",
"Spec.K256.PointOps.op_Plus_Hat",
"Spec.K256.PointOps.op_Star_Hat",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.K256.GLV.Lemmas.lemma_scalar_split_lambda_eval",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_modq",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_mul_add",
"Hacl.Spec.K256.GLV.Lemmas.lemma_glv_aff",
"Spec.K256.Lemmas.aff_point_add_comm_lemma",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.K256.GLV.scalar_split_lambda"
] | [] | module Hacl.Spec.K256.GLV.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
module SM = Hacl.Spec.K256.ECSM.Lemmas
open Hacl.Spec.K256.GLV
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [lambda](px, py) = (beta * px, py)
assume
val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p)
val lemma_glv : p:S.proj_point ->
Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p =
let (pX, pY, pZ) = p in
let (px, py) = S.to_aff_point p in
assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ));
let (qx, qy) = aff_point_mul lambda (px, py) in
lemma_glv_aff (px, py);
assert (qx = S.(beta *% px) /\ qy = py);
assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ));
let (rX, rY, rZ) = point_mul_lambda p in
assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ);
let (rx, ry) = S.to_aff_point (rX, rY, rZ) in
assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ));
assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ));
assert (qy = ry);
// S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ))
assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ));
assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ)));
M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ);
assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
//--------------------------------------------
val lemma_scalar_split_lambda_eval (k:S.qelem) :
Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0);
let r1, r2 = scalar_split_lambda k in
assert (r1 = S.(k +^ r2 *^ minus_lambda));
calc (==) {
(r1 + (r2 * lambda % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q }
(r1 + r2 * lambda) % S.q;
(==) { }
((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q }
((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q }
(k + r2 * minus_lambda + r2 * lambda) % S.q;
(==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda }
(k + r2 * (minus_lambda + lambda)) % S.q;
(==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q }
(k + (r2 * (minus_lambda + lambda) % S.q)) % S.q;
(==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q }
(k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q;
(==) { }
k % S.q;
(==) { Math.Lemmas.small_mod k S.q }
k;
}
//--------------------------------------------
(**
Fast computation of [k]P in affine coordinates
*)
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) | false | false | Hacl.Spec.K256.GLV.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point ->
Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p ==
S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) | [] | Hacl.Spec.K256.GLV.Lemmas.lemma_aff_point_mul_split_lambda | {
"file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Spec.K256.PointOps.qelem -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
(let _ = Hacl.Spec.K256.GLV.scalar_split_lambda k in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ r1 r2 = _ in
Hacl.Spec.K256.GLV.aff_point_mul k p ==
Spec.K256.PointOps.aff_point_add (Hacl.Spec.K256.GLV.aff_point_mul r1 p)
(Hacl.Spec.K256.GLV.aff_point_mul r2 (Hacl.Spec.K256.GLV.aff_point_mul_lambda p)))
<:
Type0)) | {
"end_col": 3,
"end_line": 103,
"start_col": 42,
"start_line": 87
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v) | let pts_to (#a: Type0) (r: ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a) = | false | null | false | to_vprop (pts_to_sl r p v) | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ref",
"Steel.FractionalPermission.perm",
"Steel.Effect.Common.to_vprop",
"Steel.Reference.pts_to_sl",
"Steel.Effect.Common.vprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__] | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pts_to : r: Steel.Reference.ref a -> p: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Common.vprop | [] | Steel.Reference.pts_to | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref a -> p: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Common.vprop | {
"end_col": 30,
"end_line": 61,
"start_col": 4,
"start_line": 61
} |
|
Prims.Tot | val ptr_sel (#a: Type0) (r: ref a) : selector a (ptr r) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm | val ptr_sel (#a: Type0) (r: ref a) : selector a (ptr r)
let ptr_sel (#a: Type0) (r: ref a) : selector a (ptr r) = | false | null | false | ptrp_sel r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ref",
"Steel.Reference.ptrp_sel",
"Steel.FractionalPermission.full_perm",
"Steel.Effect.Common.selector",
"Steel.Reference.ptr"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__] | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ptr_sel (#a: Type0) (r: ref a) : selector a (ptr r) | [] | Steel.Reference.ptr_sel | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref a -> Steel.Effect.Common.selector a (Steel.Reference.ptr r) | {
"end_col": 76,
"end_line": 198,
"start_col": 56,
"start_line": 198
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) | let vptrp (#a: Type) (r: ref a) ([@@@ smt_fallback]p: perm) = | false | null | false | VUnit (vptr' r p) | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ref",
"Steel.FractionalPermission.perm",
"Steel.Effect.Common.VUnit",
"Steel.Reference.vptr'",
"Steel.Effect.Common.vprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__] | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vptrp : r: Steel.Reference.ref a -> p: Steel.FractionalPermission.perm -> Steel.Effect.Common.vprop | [] | Steel.Reference.vptrp | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref a -> p: Steel.FractionalPermission.perm -> Steel.Effect.Common.vprop | {
"end_col": 79,
"end_line": 229,
"start_col": 62,
"start_line": 229
} |
|
Prims.Tot | val ghost_ptr_sel (#a: Type0) (r: ghost_ref a) : selector a (ghost_ptr r) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r)
= ghost_ptrp_sel r full_perm | val ghost_ptr_sel (#a: Type0) (r: ghost_ref a) : selector a (ghost_ptr r)
let ghost_ptr_sel (#a: Type0) (r: ghost_ref a) : selector a (ghost_ptr r) = | false | null | false | ghost_ptrp_sel r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ghost_ref",
"Steel.Reference.ghost_ptrp_sel",
"Steel.FractionalPermission.full_perm",
"Steel.Effect.Common.selector",
"Steel.Reference.ghost_ptr"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v)
val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm)
: Lemma (is_witness_invariant (ghost_pts_to_sl r p))
val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a)
: SteelGhostT (ghost_ref a) u
emp
(fun r -> ghost_pts_to r full_perm x)
val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a)
: SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp)
val ghost_share_pt (#a:Type) (#u:_)
(#p:perm)
(#x:erased a)
(r:ghost_ref a)
: SteelGhostT unit u
(ghost_pts_to r p x)
(fun _ -> ghost_pts_to r (half_perm p) x `star`
ghost_pts_to r (half_perm p) x)
val ghost_gather_pt (#a:Type) (#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p0 x0 `star`
ghost_pts_to r p1 x1)
(fun _ -> ghost_pts_to r (sum_perm p0 p1) x0)
(requires fun _ -> true)
(ensures fun _ _ _ -> x0 == x1)
val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a)
: SteelGhost unit u
(ghost_pts_to r p v0 `star` ghost_pts_to r q v1)
(fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// A permission is always no greater than one
val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p v)
(fun _ -> ghost_pts_to r p v)
(fun _ -> True)
(fun _ _ _ -> p `lesser_equal_perm` full_perm)
val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a)
: SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == v)
val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a)
: SteelGhostT unit u
(ghost_pts_to r full_perm v)
(fun _ -> ghost_pts_to r full_perm x)
(* Selector version of ghost references *)
val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
= ghost_ptrp r full_perm
val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p)
[@@ __steel_reduce__; __reduce__] | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_ptr_sel (#a: Type0) (r: ghost_ref a) : selector a (ghost_ptr r) | [] | Steel.Reference.ghost_ptr_sel | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ghost_ref a -> Steel.Effect.Common.selector a (Steel.Reference.ghost_ptr r) | {
"end_col": 28,
"end_line": 434,
"start_col": 2,
"start_line": 434
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_vptr r = ghost_vptrp r full_perm | let ghost_vptr r = | false | null | false | ghost_vptrp r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ghost_ref",
"Steel.Reference.ghost_vptrp",
"Steel.FractionalPermission.full_perm",
"Steel.Effect.Common.vprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v)
val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm)
: Lemma (is_witness_invariant (ghost_pts_to_sl r p))
val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a)
: SteelGhostT (ghost_ref a) u
emp
(fun r -> ghost_pts_to r full_perm x)
val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a)
: SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp)
val ghost_share_pt (#a:Type) (#u:_)
(#p:perm)
(#x:erased a)
(r:ghost_ref a)
: SteelGhostT unit u
(ghost_pts_to r p x)
(fun _ -> ghost_pts_to r (half_perm p) x `star`
ghost_pts_to r (half_perm p) x)
val ghost_gather_pt (#a:Type) (#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p0 x0 `star`
ghost_pts_to r p1 x1)
(fun _ -> ghost_pts_to r (sum_perm p0 p1) x0)
(requires fun _ -> true)
(ensures fun _ _ _ -> x0 == x1)
val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a)
: SteelGhost unit u
(ghost_pts_to r p v0 `star` ghost_pts_to r q v1)
(fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// A permission is always no greater than one
val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p v)
(fun _ -> ghost_pts_to r p v)
(fun _ -> True)
(fun _ _ _ -> p `lesser_equal_perm` full_perm)
val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a)
: SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == v)
val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a)
: SteelGhostT unit u
(ghost_pts_to r full_perm v)
(fun _ -> ghost_pts_to r full_perm x)
(* Selector version of ghost references *)
val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
= ghost_ptrp r full_perm
val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p)
[@@ __steel_reduce__; __reduce__]
let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r)
= ghost_ptrp_sel r full_perm
val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma
(requires interp (ghost_ptrp r p) m)
(ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m)
let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma
(requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
= ghost_ptrp_sel_interp r full_perm m
[@@ __steel_reduce__]
let ghost_vptr' #a r p : vprop' =
{hp = ghost_ptrp r p;
t = a;
sel = ghost_ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@smt_fallback] p: perm) = VUnit (ghost_vptr' r p)
[@@ __steel_reduce__; __reduce__] | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_vptr : r: Steel.Reference.ghost_ref _ -> Steel.Effect.Common.vprop | [] | Steel.Reference.ghost_vptr | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ghost_ref _ -> Steel.Effect.Common.vprop | {
"end_col": 42,
"end_line": 457,
"start_col": 19,
"start_line": 457
} |
|
Prims.Tot | val ptr (#a: Type0) (r: ref a) : slprop u#1 | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm | val ptr (#a: Type0) (r: ref a) : slprop u#1
let ptr (#a: Type0) (r: ref a) : slprop u#1 = | false | null | false | ptrp r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ref",
"Steel.Reference.ptrp",
"Steel.FractionalPermission.full_perm",
"Steel.Memory.slprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__] | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ptr (#a: Type0) (r: ref a) : slprop u#1 | [] | Steel.Reference.ptr | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref a -> Steel.Memory.slprop | {
"end_col": 60,
"end_line": 190,
"start_col": 44,
"start_line": 190
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vptr r = vptrp r full_perm | let vptr r = | false | null | false | vptrp r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ref",
"Steel.Reference.vptrp",
"Steel.FractionalPermission.full_perm",
"Steel.Effect.Common.vprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__] | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vptr : r: Steel.Reference.ref _ -> Steel.Effect.Common.vprop | [] | Steel.Reference.vptr | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref _ -> Steel.Effect.Common.vprop | {
"end_col": 30,
"end_line": 233,
"start_col": 13,
"start_line": 233
} |
|
FStar.Pervasives.Lemma | val intro_ptr_interp (#a: Type0) (r: ref a) (v: erased a) (m: mem)
: Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m | val intro_ptr_interp (#a: Type0) (r: ref a) (v: erased a) (m: mem)
: Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m)
let intro_ptr_interp (#a: Type0) (r: ref a) (v: erased a) (m: mem)
: Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = | false | null | true | intro_ptrp_interp r full_perm v m | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"lemma"
] | [
"Steel.Reference.ref",
"FStar.Ghost.erased",
"Steel.Memory.mem",
"Steel.Reference.intro_ptrp_interp",
"Steel.FractionalPermission.full_perm",
"Prims.unit",
"Steel.Memory.interp",
"Steel.Reference.pts_to_sl",
"FStar.Ghost.reveal",
"Prims.squash",
"Steel.Reference.ptr",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val intro_ptr_interp (#a: Type0) (r: ref a) (v: erased a) (m: mem)
: Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) | [] | Steel.Reference.intro_ptr_interp | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref a -> v: FStar.Ghost.erased a -> m: Steel.Memory.mem
-> FStar.Pervasives.Lemma
(requires
Steel.Memory.interp (Steel.Reference.pts_to_sl r
Steel.FractionalPermission.full_perm
(FStar.Ghost.reveal v))
m) (ensures Steel.Memory.interp (Steel.Reference.ptr r) m) | {
"end_col": 35,
"end_line": 218,
"start_col": 2,
"start_line": 218
} |
Prims.Tot | val ghost_pts_to (#a: Type0) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a)
: vprop | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v) | val ghost_pts_to (#a: Type0) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a)
: vprop
let ghost_pts_to (#a: Type0) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a)
: vprop = | false | null | false | to_vprop (ghost_pts_to_sl r p v) | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ghost_ref",
"Steel.FractionalPermission.perm",
"Steel.Effect.Common.to_vprop",
"Steel.Reference.ghost_pts_to_sl",
"Steel.Effect.Common.vprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_pts_to (#a: Type0) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a)
: vprop | [] | Steel.Reference.ghost_pts_to | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ghost_ref a -> p: Steel.FractionalPermission.perm -> v: a
-> Steel.Effect.Common.vprop | {
"end_col": 36,
"end_line": 363,
"start_col": 4,
"start_line": 363
} |
Prims.Tot | val ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
= ghost_ptrp r full_perm | val ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 = | false | null | false | ghost_ptrp r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ghost_ref",
"Steel.Reference.ghost_ptrp",
"Steel.FractionalPermission.full_perm",
"Steel.Memory.slprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v)
val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm)
: Lemma (is_witness_invariant (ghost_pts_to_sl r p))
val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a)
: SteelGhostT (ghost_ref a) u
emp
(fun r -> ghost_pts_to r full_perm x)
val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a)
: SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp)
val ghost_share_pt (#a:Type) (#u:_)
(#p:perm)
(#x:erased a)
(r:ghost_ref a)
: SteelGhostT unit u
(ghost_pts_to r p x)
(fun _ -> ghost_pts_to r (half_perm p) x `star`
ghost_pts_to r (half_perm p) x)
val ghost_gather_pt (#a:Type) (#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p0 x0 `star`
ghost_pts_to r p1 x1)
(fun _ -> ghost_pts_to r (sum_perm p0 p1) x0)
(requires fun _ -> true)
(ensures fun _ _ _ -> x0 == x1)
val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a)
: SteelGhost unit u
(ghost_pts_to r p v0 `star` ghost_pts_to r q v1)
(fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// A permission is always no greater than one
val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p v)
(fun _ -> ghost_pts_to r p v)
(fun _ -> True)
(fun _ _ _ -> p `lesser_equal_perm` full_perm)
val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a)
: SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == v)
val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a)
: SteelGhostT unit u
(ghost_pts_to r full_perm v)
(fun _ -> ghost_pts_to r full_perm x)
(* Selector version of ghost references *)
val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 | [] | Steel.Reference.ghost_ptr | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ghost_ref a -> Steel.Memory.slprop | {
"end_col": 24,
"end_line": 428,
"start_col": 2,
"start_line": 428
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@smt_fallback] p: perm) = VUnit (ghost_vptr' r p) | let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) = | false | null | false | VUnit (ghost_vptr' r p) | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"total"
] | [
"Steel.Reference.ghost_ref",
"Steel.FractionalPermission.perm",
"Steel.Effect.Common.VUnit",
"Steel.Reference.ghost_vptr'",
"Steel.Effect.Common.vprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v)
val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm)
: Lemma (is_witness_invariant (ghost_pts_to_sl r p))
val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a)
: SteelGhostT (ghost_ref a) u
emp
(fun r -> ghost_pts_to r full_perm x)
val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a)
: SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp)
val ghost_share_pt (#a:Type) (#u:_)
(#p:perm)
(#x:erased a)
(r:ghost_ref a)
: SteelGhostT unit u
(ghost_pts_to r p x)
(fun _ -> ghost_pts_to r (half_perm p) x `star`
ghost_pts_to r (half_perm p) x)
val ghost_gather_pt (#a:Type) (#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p0 x0 `star`
ghost_pts_to r p1 x1)
(fun _ -> ghost_pts_to r (sum_perm p0 p1) x0)
(requires fun _ -> true)
(ensures fun _ _ _ -> x0 == x1)
val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a)
: SteelGhost unit u
(ghost_pts_to r p v0 `star` ghost_pts_to r q v1)
(fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// A permission is always no greater than one
val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p v)
(fun _ -> ghost_pts_to r p v)
(fun _ -> True)
(fun _ _ _ -> p `lesser_equal_perm` full_perm)
val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a)
: SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == v)
val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a)
: SteelGhostT unit u
(ghost_pts_to r full_perm v)
(fun _ -> ghost_pts_to r full_perm x)
(* Selector version of ghost references *)
val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
= ghost_ptrp r full_perm
val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p)
[@@ __steel_reduce__; __reduce__]
let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r)
= ghost_ptrp_sel r full_perm
val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma
(requires interp (ghost_ptrp r p) m)
(ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m)
let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma
(requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
= ghost_ptrp_sel_interp r full_perm m
[@@ __steel_reduce__]
let ghost_vptr' #a r p : vprop' =
{hp = ghost_ptrp r p;
t = a;
sel = ghost_ptrp_sel r p}
[@@ __steel_reduce__] | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_vptrp : r: Steel.Reference.ghost_ref a -> p: Steel.FractionalPermission.perm -> Steel.Effect.Common.vprop | [] | Steel.Reference.ghost_vptrp | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ghost_ref a -> p: Steel.FractionalPermission.perm -> Steel.Effect.Common.vprop | {
"end_col": 97,
"end_line": 453,
"start_col": 74,
"start_line": 453
} |
|
Prims.GTot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r) | let sel
(#a: Type)
(#p: vprop)
(r: ref a)
(h: rmem p {FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= | false | null | false | h (vptr r) | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"sometrivial"
] | [
"Steel.Effect.Common.vprop",
"Steel.Reference.ref",
"Steel.Effect.Common.rmem",
"FStar.Tactics.Effect.with_tactic",
"Steel.Effect.Common.selector_tactic",
"Prims.l_and",
"Steel.Effect.Common.can_be_split",
"Steel.Reference.vptr",
"Prims.l_True",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sel : r: Steel.Reference.ref a ->
h:
Steel.Effect.Common.rmem p
{ FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic
(Steel.Effect.Common.can_be_split p (Steel.Reference.vptr r) /\ Prims.l_True) }
-> Prims.GTot (Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.vptr r))) | [] | Steel.Reference.sel | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
r: Steel.Reference.ref a ->
h:
Steel.Effect.Common.rmem p
{ FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic
(Steel.Effect.Common.can_be_split p (Steel.Reference.vptr r) /\ Prims.l_True) }
-> Prims.GTot (Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.vptr r))) | {
"end_col": 14,
"end_line": 241,
"start_col": 4,
"start_line": 241
} |
|
Prims.GTot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_sel (#a:Type) (#p:vprop) (r:ghost_ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (ghost_vptr r) /\ True)})
= h (ghost_vptr r) | let ghost_sel
(#a: Type)
(#p: vprop)
(r: ghost_ref a)
(h:
rmem p {FStar.Tactics.with_tactic selector_tactic (can_be_split p (ghost_vptr r) /\ True)}
)
= | false | null | false | h (ghost_vptr r) | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"sometrivial"
] | [
"Steel.Effect.Common.vprop",
"Steel.Reference.ghost_ref",
"Steel.Effect.Common.rmem",
"FStar.Tactics.Effect.with_tactic",
"Steel.Effect.Common.selector_tactic",
"Prims.l_and",
"Steel.Effect.Common.can_be_split",
"Steel.Reference.ghost_vptr",
"Prims.l_True",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v)
val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm)
: Lemma (is_witness_invariant (ghost_pts_to_sl r p))
val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a)
: SteelGhostT (ghost_ref a) u
emp
(fun r -> ghost_pts_to r full_perm x)
val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a)
: SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp)
val ghost_share_pt (#a:Type) (#u:_)
(#p:perm)
(#x:erased a)
(r:ghost_ref a)
: SteelGhostT unit u
(ghost_pts_to r p x)
(fun _ -> ghost_pts_to r (half_perm p) x `star`
ghost_pts_to r (half_perm p) x)
val ghost_gather_pt (#a:Type) (#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p0 x0 `star`
ghost_pts_to r p1 x1)
(fun _ -> ghost_pts_to r (sum_perm p0 p1) x0)
(requires fun _ -> true)
(ensures fun _ _ _ -> x0 == x1)
val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a)
: SteelGhost unit u
(ghost_pts_to r p v0 `star` ghost_pts_to r q v1)
(fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// A permission is always no greater than one
val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p v)
(fun _ -> ghost_pts_to r p v)
(fun _ -> True)
(fun _ _ _ -> p `lesser_equal_perm` full_perm)
val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a)
: SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == v)
val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a)
: SteelGhostT unit u
(ghost_pts_to r full_perm v)
(fun _ -> ghost_pts_to r full_perm x)
(* Selector version of ghost references *)
val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
= ghost_ptrp r full_perm
val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p)
[@@ __steel_reduce__; __reduce__]
let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r)
= ghost_ptrp_sel r full_perm
val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma
(requires interp (ghost_ptrp r p) m)
(ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m)
let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma
(requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
= ghost_ptrp_sel_interp r full_perm m
[@@ __steel_reduce__]
let ghost_vptr' #a r p : vprop' =
{hp = ghost_ptrp r p;
t = a;
sel = ghost_ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@smt_fallback] p: perm) = VUnit (ghost_vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_vptr r = ghost_vptrp r full_perm
[@@ __steel_reduce__]
let ghost_sel (#a:Type) (#p:vprop) (r:ghost_ref a) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_sel : r: Steel.Reference.ghost_ref a ->
h:
Steel.Effect.Common.rmem p
{ FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic
(Steel.Effect.Common.can_be_split p (Steel.Reference.ghost_vptr r) /\ Prims.l_True) }
-> Prims.GTot
(Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.ghost_vptr r))) | [] | Steel.Reference.ghost_sel | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
r: Steel.Reference.ghost_ref a ->
h:
Steel.Effect.Common.rmem p
{ FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic
(Steel.Effect.Common.can_be_split p (Steel.Reference.ghost_vptr r) /\ Prims.l_True) }
-> Prims.GTot
(Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.ghost_vptr r))) | {
"end_col": 20,
"end_line": 462,
"start_col": 4,
"start_line": 462
} |
|
FStar.Pervasives.Lemma | val ptr_sel_interp (#a: Type0) (r: ref a) (m: mem)
: Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m | val ptr_sel_interp (#a: Type0) (r: ref a) (m: mem)
: Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
let ptr_sel_interp (#a: Type0) (r: ref a) (m: mem)
: Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = | false | null | true | ptrp_sel_interp r full_perm m | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"lemma"
] | [
"Steel.Reference.ref",
"Steel.Memory.mem",
"Steel.Reference.ptrp_sel_interp",
"Steel.FractionalPermission.full_perm",
"Prims.unit",
"Steel.Memory.interp",
"Steel.Reference.ptr",
"Prims.squash",
"Steel.Reference.pts_to_sl",
"Steel.Reference.ptr_sel",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ptr_sel_interp (#a: Type0) (r: ref a) (m: mem)
: Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) | [] | Steel.Reference.ptr_sel_interp | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref a -> m: Steel.Memory.mem
-> FStar.Pervasives.Lemma (requires Steel.Memory.interp (Steel.Reference.ptr r) m)
(ensures
Steel.Memory.interp (Steel.Reference.pts_to_sl r
Steel.FractionalPermission.full_perm
(Steel.Reference.ptr_sel r m))
m) | {
"end_col": 31,
"end_line": 209,
"start_col": 2,
"start_line": 209
} |
FStar.Pervasives.Lemma | val ghost_ptr_sel_interp (#a: Type0) (r: ghost_ref a) (m: mem)
: Lemma (requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma
(requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
= ghost_ptrp_sel_interp r full_perm m | val ghost_ptr_sel_interp (#a: Type0) (r: ghost_ref a) (m: mem)
: Lemma (requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
let ghost_ptr_sel_interp (#a: Type0) (r: ghost_ref a) (m: mem)
: Lemma (requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m) = | false | null | true | ghost_ptrp_sel_interp r full_perm m | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [
"lemma"
] | [
"Steel.Reference.ghost_ref",
"Steel.Memory.mem",
"Steel.Reference.ghost_ptrp_sel_interp",
"Steel.FractionalPermission.full_perm",
"Prims.unit",
"Steel.Memory.interp",
"Steel.Reference.ghost_ptr",
"Prims.squash",
"Steel.Reference.ghost_pts_to_sl",
"Steel.Reference.ghost_ptr_sel",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v)
val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm)
: Lemma (is_witness_invariant (ghost_pts_to_sl r p))
val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a)
: SteelGhostT (ghost_ref a) u
emp
(fun r -> ghost_pts_to r full_perm x)
val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a)
: SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp)
val ghost_share_pt (#a:Type) (#u:_)
(#p:perm)
(#x:erased a)
(r:ghost_ref a)
: SteelGhostT unit u
(ghost_pts_to r p x)
(fun _ -> ghost_pts_to r (half_perm p) x `star`
ghost_pts_to r (half_perm p) x)
val ghost_gather_pt (#a:Type) (#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p0 x0 `star`
ghost_pts_to r p1 x1)
(fun _ -> ghost_pts_to r (sum_perm p0 p1) x0)
(requires fun _ -> true)
(ensures fun _ _ _ -> x0 == x1)
val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a)
: SteelGhost unit u
(ghost_pts_to r p v0 `star` ghost_pts_to r q v1)
(fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// A permission is always no greater than one
val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p v)
(fun _ -> ghost_pts_to r p v)
(fun _ -> True)
(fun _ _ _ -> p `lesser_equal_perm` full_perm)
val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a)
: SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == v)
val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a)
: SteelGhostT unit u
(ghost_pts_to r full_perm v)
(fun _ -> ghost_pts_to r full_perm x)
(* Selector version of ghost references *)
val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
= ghost_ptrp r full_perm
val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p)
[@@ __steel_reduce__; __reduce__]
let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r)
= ghost_ptrp_sel r full_perm
val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma
(requires interp (ghost_ptrp r p) m)
(ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m)
let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma
(requires interp (ghost_ptr r) m) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_ptr_sel_interp (#a: Type0) (r: ghost_ref a) (m: mem)
: Lemma (requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m) | [] | Steel.Reference.ghost_ptr_sel_interp | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ghost_ref a -> m: Steel.Memory.mem
-> FStar.Pervasives.Lemma (requires Steel.Memory.interp (Steel.Reference.ghost_ptr r) m)
(ensures
Steel.Memory.interp (Steel.Reference.ghost_pts_to_sl r
Steel.FractionalPermission.full_perm
(Steel.Reference.ghost_ptr_sel r m))
m) | {
"end_col": 37,
"end_line": 443,
"start_col": 2,
"start_line": 443
} |
Steel.Effect.Atomic.SteelGhost | val vptr_not_null (#opened: _) (#a: Type) (r: ref a)
: SteelGhost unit
opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm | val vptr_not_null (#opened: _) (#a: Type) (r: ref a)
: SteelGhost unit
opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false)
let vptr_not_null (#opened: _) (#a: Type) (r: ref a)
: SteelGhost unit
opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false) = | true | null | false | vptrp_not_null r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [] | [
"Steel.Memory.inames",
"Steel.Reference.ref",
"Steel.Reference.vptrp_not_null",
"Steel.FractionalPermission.full_perm",
"Prims.unit",
"Steel.Reference.vptr",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"Steel.Reference.sel",
"Prims.bool",
"Steel.Reference.is_null"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vptr_not_null (#opened: _) (#a: Type) (r: ref a)
: SteelGhost unit
opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false) | [] | Steel.Reference.vptr_not_null | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref a -> Steel.Effect.Atomic.SteelGhost Prims.unit | {
"end_col": 28,
"end_line": 340,
"start_col": 2,
"start_line": 340
} |
Steel.Effect.Atomic.SteelGhost | val ghost_read (#a: Type0) (#opened: inames) (r: ghost_ref a)
: SteelGhost (Ghost.erased a)
opened
(ghost_vptr r)
(fun _ -> ghost_vptr r)
(requires fun _ -> True)
(ensures
fun h0 x h1 -> h0 (ghost_vptr r) == h1 (ghost_vptr r) /\ Ghost.reveal x == h1 (ghost_vptr r)
) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_read (#a:Type0) (#opened:inames) (r:ghost_ref a)
: SteelGhost (Ghost.erased a) opened
(ghost_vptr r) (fun _ -> ghost_vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (ghost_vptr r) == h1 (ghost_vptr r) /\ Ghost.reveal x == h1 (ghost_vptr r))
= ghost_readp r full_perm | val ghost_read (#a: Type0) (#opened: inames) (r: ghost_ref a)
: SteelGhost (Ghost.erased a)
opened
(ghost_vptr r)
(fun _ -> ghost_vptr r)
(requires fun _ -> True)
(ensures
fun h0 x h1 -> h0 (ghost_vptr r) == h1 (ghost_vptr r) /\ Ghost.reveal x == h1 (ghost_vptr r)
)
let ghost_read (#a: Type0) (#opened: inames) (r: ghost_ref a)
: SteelGhost (Ghost.erased a)
opened
(ghost_vptr r)
(fun _ -> ghost_vptr r)
(requires fun _ -> True)
(ensures
fun h0 x h1 -> h0 (ghost_vptr r) == h1 (ghost_vptr r) /\ Ghost.reveal x == h1 (ghost_vptr r)
) = | true | null | false | ghost_readp r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [] | [
"Steel.Memory.inames",
"Steel.Reference.ghost_ref",
"Steel.Reference.ghost_readp",
"Steel.FractionalPermission.full_perm",
"FStar.Ghost.erased",
"Steel.Reference.ghost_vptr",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"FStar.Ghost.reveal"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v)
val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm)
: Lemma (is_witness_invariant (ghost_pts_to_sl r p))
val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a)
: SteelGhostT (ghost_ref a) u
emp
(fun r -> ghost_pts_to r full_perm x)
val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a)
: SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp)
val ghost_share_pt (#a:Type) (#u:_)
(#p:perm)
(#x:erased a)
(r:ghost_ref a)
: SteelGhostT unit u
(ghost_pts_to r p x)
(fun _ -> ghost_pts_to r (half_perm p) x `star`
ghost_pts_to r (half_perm p) x)
val ghost_gather_pt (#a:Type) (#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p0 x0 `star`
ghost_pts_to r p1 x1)
(fun _ -> ghost_pts_to r (sum_perm p0 p1) x0)
(requires fun _ -> true)
(ensures fun _ _ _ -> x0 == x1)
val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a)
: SteelGhost unit u
(ghost_pts_to r p v0 `star` ghost_pts_to r q v1)
(fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// A permission is always no greater than one
val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p v)
(fun _ -> ghost_pts_to r p v)
(fun _ -> True)
(fun _ _ _ -> p `lesser_equal_perm` full_perm)
val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a)
: SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == v)
val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a)
: SteelGhostT unit u
(ghost_pts_to r full_perm v)
(fun _ -> ghost_pts_to r full_perm x)
(* Selector version of ghost references *)
val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
= ghost_ptrp r full_perm
val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p)
[@@ __steel_reduce__; __reduce__]
let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r)
= ghost_ptrp_sel r full_perm
val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma
(requires interp (ghost_ptrp r p) m)
(ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m)
let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma
(requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
= ghost_ptrp_sel_interp r full_perm m
[@@ __steel_reduce__]
let ghost_vptr' #a r p : vprop' =
{hp = ghost_ptrp r p;
t = a;
sel = ghost_ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@smt_fallback] p: perm) = VUnit (ghost_vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_vptr r = ghost_vptrp r full_perm
[@@ __steel_reduce__]
let ghost_sel (#a:Type) (#p:vprop) (r:ghost_ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (ghost_vptr r) /\ True)})
= h (ghost_vptr r)
val ghost_alloc (#a:Type0) (#opened:inames) (x:Ghost.erased a)
: SteelGhost (ghost_ref a) opened
emp (fun r -> ghost_vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> ghost_sel r h1 == Ghost.reveal x)
val ghost_free (#a:Type0) (#opened:inames) (r:ghost_ref a) : SteelGhost unit opened
(ghost_vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
val ghost_readp (#a:Type0) (#opened:inames) (r:ghost_ref a)
(p: perm)
: SteelGhost (Ghost.erased a) opened
(ghost_vptrp r p) (fun _ -> ghost_vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (ghost_vptrp r p) == h1 (ghost_vptrp r p) /\ Ghost.reveal x == h1 (ghost_vptrp r p))
let ghost_read (#a:Type0) (#opened:inames) (r:ghost_ref a)
: SteelGhost (Ghost.erased a) opened
(ghost_vptr r) (fun _ -> ghost_vptr r)
(requires fun _ -> True) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_read (#a: Type0) (#opened: inames) (r: ghost_ref a)
: SteelGhost (Ghost.erased a)
opened
(ghost_vptr r)
(fun _ -> ghost_vptr r)
(requires fun _ -> True)
(ensures
fun h0 x h1 -> h0 (ghost_vptr r) == h1 (ghost_vptr r) /\ Ghost.reveal x == h1 (ghost_vptr r)
) | [] | Steel.Reference.ghost_read | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ghost_ref a -> Steel.Effect.Atomic.SteelGhost (FStar.Ghost.erased a) | {
"end_col": 25,
"end_line": 487,
"start_col": 2,
"start_line": 487
} |
Steel.Effect.Steel | val read (#a: Type0) (r: ref a)
: Steel a
(vptr r)
(fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm | val read (#a: Type0) (r: ref a)
: Steel a
(vptr r)
(fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
let read (#a: Type0) (r: ref a)
: Steel a
(vptr r)
(fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) = | true | null | false | readp r full_perm | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [] | [
"Steel.Reference.ref",
"Steel.Reference.readp",
"Steel.FractionalPermission.full_perm",
"Steel.Reference.vptr",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of",
"Steel.Reference.sel"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read (#a: Type0) (r: ref a)
: Steel a
(vptr r)
(fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) | [] | Steel.Reference.read | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ref a -> Steel.Effect.Steel a | {
"end_col": 19,
"end_line": 277,
"start_col": 2,
"start_line": 277
} |
Steel.Effect.Atomic.SteelGhost | val ghost_gather (#a: Type0) (#uses: _) (#p: perm) (r: ghost_ref a)
: SteelGhost unit
uses
((ghost_vptrp r (half_perm p)) `star` (ghost_vptrp r (half_perm p)))
(fun _ -> ghost_vptrp r p)
(fun _ -> True)
(fun h _ h' -> h' (ghost_vptrp r p) == h (ghost_vptrp r (half_perm p))) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "Steel.HigherReference",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghost_gather (#a: Type0) (#uses: _) (#p: perm) (r: ghost_ref a)
: SteelGhost unit uses
(ghost_vptrp r (half_perm p) `star` ghost_vptrp r (half_perm p))
(fun _ -> ghost_vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (ghost_vptrp r p) == h (ghost_vptrp r (half_perm p))
)
= let _ = ghost_gather_gen r _ _ in
change_equal_slprop
(ghost_vptrp r _)
(ghost_vptrp r p) | val ghost_gather (#a: Type0) (#uses: _) (#p: perm) (r: ghost_ref a)
: SteelGhost unit
uses
((ghost_vptrp r (half_perm p)) `star` (ghost_vptrp r (half_perm p)))
(fun _ -> ghost_vptrp r p)
(fun _ -> True)
(fun h _ h' -> h' (ghost_vptrp r p) == h (ghost_vptrp r (half_perm p)))
let ghost_gather (#a: Type0) (#uses: _) (#p: perm) (r: ghost_ref a)
: SteelGhost unit
uses
((ghost_vptrp r (half_perm p)) `star` (ghost_vptrp r (half_perm p)))
(fun _ -> ghost_vptrp r p)
(fun _ -> True)
(fun h _ h' -> h' (ghost_vptrp r p) == h (ghost_vptrp r (half_perm p))) = | true | null | false | let _ = ghost_gather_gen r _ _ in
change_equal_slprop (ghost_vptrp r _) (ghost_vptrp r p) | {
"checked_file": "Steel.Reference.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Reference.fsti"
} | [] | [
"Steel.Memory.inames",
"Steel.FractionalPermission.perm",
"Steel.Reference.ghost_ref",
"Steel.Effect.Atomic.change_equal_slprop",
"Steel.Reference.ghost_vptrp",
"Prims.unit",
"Steel.Reference.ghost_gather_gen",
"Steel.FractionalPermission.half_perm",
"Steel.Effect.Common.star",
"Steel.Effect.Common.vprop",
"Steel.Effect.Common.rmem",
"Prims.l_True",
"Prims.eq2",
"Steel.Effect.Common.normal",
"Steel.Effect.Common.t_of"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Reference
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module U32 = FStar.UInt32
module Mem = Steel.Memory
/// The main user-facing Steel library.
/// This library provides functions to operate on references to values in universe 0, such as uints.
/// This library provides two versions, which can interoperate with each other.
/// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector
/// The second one has a selector which returns the contents of the reference in memory, enabling
/// to better separate reasoning about memory safety and functional correctness when handling references.
/// An abstract datatype for references
val ref ([@@@unused] a:Type0) : Type0
/// The null pointer
[@@ noextract_to "krml"]
val null (#a:Type0) : ref a
/// Checking whether a pointer is null can be done in a decidable way
[@@ noextract_to "krml"]
val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null})
(** First version of references: Non-informative selector and standard pts_to predicate.
All functions names here are postfixed with _pt (for points_to)**)
/// The standard points to separation logic assertion, expressing that
/// reference [r] is valid in memory, stores value [v], and that we have
/// permission [p] on it.
val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector.
/// The permission [p] and the value [v] are annotated with the smt_fallback attribute,
/// enabling SMT rewriting on them during frame inference
[@@ __steel_reduce__]
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a)
= to_vprop (pts_to_sl r p v)
/// If two pts_to predicates on the same reference [r] are valid in the memory [m],
/// then the two values [v0] and [v1] are identical
val pts_to_ref_injective
(#a: Type u#0)
(r: ref a)
(p0 p1:perm)
(v0 v1:a)
(m:mem)
: Lemma
(requires
interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m)
(ensures v0 == v1)
/// A valid pts_to predicate implies that the pointer is not the null pointer
val pts_to_not_null (#a:Type u#0)
(x:ref a)
(p:perm)
(v:a)
(m:mem)
: Lemma (requires interp (pts_to_sl x p v) m)
(ensures x =!= null)
/// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions
val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p))
/// A stateful version of the pts_to_ref_injective lemma above
val pts_to_injective_eq
(#a: Type)
(#opened:inames)
(#p0 #p1:perm)
(#v0 #v1: erased a)
(r: ref a)
: SteelGhost unit opened
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc_pt (#a:Type) (x:a)
: Steel (ref a) emp (fun r -> pts_to r full_perm x)
(requires fun _ -> True)
(ensures fun _ r _ -> not (is_null r))
/// Reads the value in reference [r], as long as it initially is valid
val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a)
: Steel a (pts_to r p v) (fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
/// A variant of read, useful when an existentially quantified predicate
/// depends on the value stored in the reference
val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a)
: SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v))
(fun v -> pts_to r p v `star` q v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a)
: SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x)
/// Frees reference [r], as long as we have full ownership of [r]
val free_pt (#a:Type0) (#v:erased a) (r:ref a)
: SteelT unit (pts_to r full_perm v) (fun _ -> emp)
/// Splits the permission on reference [r] into two.
/// This function is computationally irrelevant (it has effect SteelGhost)
val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a)
: SteelGhostT unit uses
(pts_to r p v)
(fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v)
/// Combines permissions on reference [r].
/// This function is computationally irrelevant (it has effect SteelGhost)
val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a)
: SteelGhostT (_:unit{v0 == v1}) uses
(pts_to r p0 v0 `star` pts_to r p1 v1)
(fun _ -> pts_to r (sum_perm p0 p1) v0)
/// Atomic operations, read, write, and cas
///
/// These are not polymorphic and are allowed only for small types (e.g. word-sized)
/// For now, exporting only for U32
val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t)
: SteelAtomic U32.t opened
(pts_to r p v)
(fun x -> pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == Ghost.reveal v)
val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t)
: SteelAtomicT unit opened
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
val cas_pt_u32 (#uses:inames)
(r:ref U32.t)
(v:Ghost.erased U32.t)
(v_old:U32.t)
(v_new:U32.t)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
val cas_pt_bool (#uses:inames)
(r:ref bool)
(v:Ghost.erased bool)
(v_old:bool)
(v_new:bool)
: SteelAtomicT
(b:bool{b <==> (Ghost.reveal v == v_old)})
uses
(pts_to r full_perm v)
(fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v)
(** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **)
/// An abstract separation logic predicate stating that reference [r] is valid in memory.
val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
/// A selector for references, returning the value of type [a] stored in memory
val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
/// Some lemmas to interoperate between the two versions of references
val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma
(requires interp (ptrp r p) m)
(ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma
(requires interp (ptr r) m)
(ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
= ptrp_sel_interp r full_perm m
val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r p v) m)
(ensures interp (ptrp r p) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma
(requires interp (pts_to_sl r full_perm v) m)
(ensures interp (ptr r) m)
= intro_ptrp_interp r full_perm v m
/// Combining the separation logic predicate and selector into a vprop
[@@ __steel_reduce__]
let vptr' #a r p : vprop' =
{hp = ptrp r p;
t = a;
sel = ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let vptr r = vptrp r full_perm
/// A wrapper to access a reference selector more easily.
/// Ensuring that the corresponding ptr vprop is in the context is done by
/// calling a variant of the framing tactic, as defined in Steel.Effect.Common
[@@ __steel_reduce__]
let sel (#a:Type) (#p:vprop) (r:ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)})
= h (vptr r)
/// Moving from indexed pts_to assertions to selector-based vprops and back
val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a)
: SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v)
val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm)
: SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v)
(requires fun _ -> True)
(ensures fun h0 v _ -> reveal v == h0 (vptrp r p))
/// Allocates a reference with value [x].
val malloc (#a:Type0) (x:a) : Steel (ref a)
emp (fun r -> vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r))
/// Frees a reference [r]
val free (#a:Type0) (r:ref a) : Steel unit
(vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
/// Reads the current value of reference [r]
val readp (#a:Type0) (r:ref a) (p: perm) : Steel a
(vptrp r p) (fun _ -> vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p))
let read (#a:Type0) (r:ref a) : Steel a
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1)
= readp r full_perm
/// Writes value [x] in reference [r]
val write (#a:Type0) (r:ref a) (x:a) : Steel unit
(vptr r) (fun _ -> vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> x == sel r h1)
val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a)
: SteelGhost unit uses
(vptrp r p)
(fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r (half_perm p)) == h (vptrp r p)
)
val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(vptrp r p0 `star` vptrp r p1)
(fun res -> vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (vptrp r res) == h (vptrp r p0) /\
h' (vptrp r res) == h (vptrp r p1)
)
val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a)
: SteelGhost unit uses
(vptrp r (half_perm p) `star` vptrp r (half_perm p))
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (vptrp r p) == h (vptrp r (half_perm p))
)
/// A stateful lemma variant of the pts_to_not_null lemma above.
/// This stateful function is computationally irrelevant and does not modify memory
val vptrp_not_null (#opened: _)
(#a: Type)
(r: ref a)
(p: perm)
: SteelGhost unit opened
(vptrp r p)
(fun _ -> vptrp r p)
(fun _ -> True)
(fun h0 _ h1 ->
h0 (vptrp r p) == h1 (vptrp r p) /\
is_null r == false
)
let vptr_not_null (#opened: _)
(#a: Type)
(r: ref a)
: SteelGhost unit opened
(vptr r)
(fun _ -> vptr r)
(fun _ -> True)
(fun h0 _ h1 ->
sel r h0 == sel r h1 /\
is_null r == false
)
= vptrp_not_null r full_perm
(*** Ghost references ***)
/// We also define a ghost variant of references, useful to do proofs relying on a ghost state
/// Ghost references are marked as erasable, ensuring that they are computationally irrelevant,
/// and only used in computationally irrelevant contexts.
/// The functions below are variants of the reference functions defined above,
/// but operating on ghost references, and with the computationally irrelevant SteelGhost effect
[@@ erasable]
val ghost_ref (a:Type u#0) : Type u#0
(* Textbook separation logic version of ghost references *)
val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
[@@ __steel_reduce__]
let ghost_pts_to (#a:Type0)
(r:ghost_ref a)
([@@@smt_fallback] p:perm)
([@@@ smt_fallback] v:a)
: vprop
= to_vprop (ghost_pts_to_sl r p v)
val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm)
: Lemma (is_witness_invariant (ghost_pts_to_sl r p))
val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a)
: SteelGhostT (ghost_ref a) u
emp
(fun r -> ghost_pts_to r full_perm x)
val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a)
: SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp)
val ghost_share_pt (#a:Type) (#u:_)
(#p:perm)
(#x:erased a)
(r:ghost_ref a)
: SteelGhostT unit u
(ghost_pts_to r p x)
(fun _ -> ghost_pts_to r (half_perm p) x `star`
ghost_pts_to r (half_perm p) x)
val ghost_gather_pt (#a:Type) (#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p0 x0 `star`
ghost_pts_to r p1 x1)
(fun _ -> ghost_pts_to r (sum_perm p0 p1) x0)
(requires fun _ -> true)
(ensures fun _ _ _ -> x0 == x1)
val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a)
: SteelGhost unit u
(ghost_pts_to r p v0 `star` ghost_pts_to r q v1)
(fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0)
(requires fun _ -> True)
(ensures fun _ _ _ -> v0 == v1)
/// A permission is always no greater than one
val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a)
: SteelGhost unit u
(ghost_pts_to r p v)
(fun _ -> ghost_pts_to r p v)
(fun _ -> True)
(fun _ _ _ -> p `lesser_equal_perm` full_perm)
val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a)
: SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x)
(requires fun _ -> True)
(ensures fun _ x _ -> x == v)
val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a)
: SteelGhostT unit u
(ghost_pts_to r full_perm v)
(fun _ -> ghost_pts_to r full_perm x)
(* Selector version of ghost references *)
val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
= ghost_ptrp r full_perm
val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p)
[@@ __steel_reduce__; __reduce__]
let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r)
= ghost_ptrp_sel r full_perm
val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma
(requires interp (ghost_ptrp r p) m)
(ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m)
let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma
(requires interp (ghost_ptr r) m)
(ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
= ghost_ptrp_sel_interp r full_perm m
[@@ __steel_reduce__]
let ghost_vptr' #a r p : vprop' =
{hp = ghost_ptrp r p;
t = a;
sel = ghost_ptrp_sel r p}
[@@ __steel_reduce__]
unfold
let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@smt_fallback] p: perm) = VUnit (ghost_vptr' r p)
[@@ __steel_reduce__; __reduce__]
unfold
let ghost_vptr r = ghost_vptrp r full_perm
[@@ __steel_reduce__]
let ghost_sel (#a:Type) (#p:vprop) (r:ghost_ref a)
(h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (ghost_vptr r) /\ True)})
= h (ghost_vptr r)
val ghost_alloc (#a:Type0) (#opened:inames) (x:Ghost.erased a)
: SteelGhost (ghost_ref a) opened
emp (fun r -> ghost_vptr r)
(requires fun _ -> True)
(ensures fun _ r h1 -> ghost_sel r h1 == Ghost.reveal x)
val ghost_free (#a:Type0) (#opened:inames) (r:ghost_ref a) : SteelGhost unit opened
(ghost_vptr r) (fun _ -> emp)
(requires fun _ -> True)
(ensures fun _ _ _ -> True)
val ghost_readp (#a:Type0) (#opened:inames) (r:ghost_ref a)
(p: perm)
: SteelGhost (Ghost.erased a) opened
(ghost_vptrp r p) (fun _ -> ghost_vptrp r p)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (ghost_vptrp r p) == h1 (ghost_vptrp r p) /\ Ghost.reveal x == h1 (ghost_vptrp r p))
let ghost_read (#a:Type0) (#opened:inames) (r:ghost_ref a)
: SteelGhost (Ghost.erased a) opened
(ghost_vptr r) (fun _ -> ghost_vptr r)
(requires fun _ -> True)
(ensures fun h0 x h1 -> h0 (ghost_vptr r) == h1 (ghost_vptr r) /\ Ghost.reveal x == h1 (ghost_vptr r))
= ghost_readp r full_perm
val ghost_write (#a:Type0) (#opened:inames) (r:ghost_ref a) (x:Ghost.erased a)
: SteelGhost unit opened
(ghost_vptr r) (fun _ -> ghost_vptr r)
(requires fun _ -> True)
(ensures fun _ _ h1 -> Ghost.reveal x == h1 (ghost_vptr r))
val ghost_share (#a:Type0) (#uses:_) (#p: perm) (r:ghost_ref a)
: SteelGhost unit uses
(ghost_vptrp r p)
(fun _ -> ghost_vptrp r (half_perm p) `star` ghost_vptrp r (half_perm p))
(fun _ -> True)
(fun h res h' ->
h' (ghost_vptrp r (half_perm p)) == h (ghost_vptrp r p)
)
val ghost_gather_gen (#a:Type0) (#uses:_) (r:ghost_ref a) (p0:perm) (p1:perm)
: SteelGhost perm uses
(ghost_vptrp r p0 `star` ghost_vptrp r p1)
(fun res -> ghost_vptrp r res)
(fun _ -> True)
(fun h res h' ->
res == sum_perm p0 p1 /\
h' (ghost_vptrp r res) == h (ghost_vptrp r p0) /\
h' (ghost_vptrp r res) == h (ghost_vptrp r p1)
)
let ghost_gather (#a: Type0) (#uses: _) (#p: perm) (r: ghost_ref a)
: SteelGhost unit uses
(ghost_vptrp r (half_perm p) `star` ghost_vptrp r (half_perm p))
(fun _ -> ghost_vptrp r p)
(fun _ -> True)
(fun h _ h' ->
h' (ghost_vptrp r p) == h (ghost_vptrp r (half_perm p)) | false | false | Steel.Reference.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghost_gather (#a: Type0) (#uses: _) (#p: perm) (r: ghost_ref a)
: SteelGhost unit
uses
((ghost_vptrp r (half_perm p)) `star` (ghost_vptrp r (half_perm p)))
(fun _ -> ghost_vptrp r p)
(fun _ -> True)
(fun h _ h' -> h' (ghost_vptrp r p) == h (ghost_vptrp r (half_perm p))) | [] | Steel.Reference.ghost_gather | {
"file_name": "lib/steel/Steel.Reference.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Reference.ghost_ref a -> Steel.Effect.Atomic.SteelGhost Prims.unit | {
"end_col": 21,
"end_line": 526,
"start_col": 1,
"start_line": 523
} |
FStar.Pervasives.Lemma | val mask_select_lemma: #t:inttype{~(S128? t)} -> mask:int_t t SEC -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(requires v mask = 0 \/ v mask = v (ones t SEC))
(ensures mask_select mask a b == (if v mask = 0 then b else a)) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end | val mask_select_lemma: #t:inttype{~(S128? t)} -> mask:int_t t SEC -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(requires v mask = 0 \/ v mask = v (ones t SEC))
(ensures mask_select mask a b == (if v mask = 0 then b else a))
let mask_select_lemma #t mask a b = | false | null | true | let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^. b);
if v mask = 0
then
(assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
())
else
(assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
()) | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.inttype",
"Prims.l_not",
"Prims.b2t",
"Lib.IntTypes.uu___is_S128",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Prims.unit",
"Prims._assert",
"Lib.IntTypes.range_t",
"Lib.IntTypes.logxor_lemma",
"Prims.eq2",
"Prims.bool",
"Lib.IntTypes.op_Hat_Dot",
"Lib.IntTypes.logand_lemma",
"Lib.IntTypes.op_Amp_Dot"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b)) | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mask_select_lemma: #t:inttype{~(S128? t)} -> mask:int_t t SEC -> a:int_t t SEC -> b:int_t t SEC -> Lemma
(requires v mask = 0 \/ v mask = v (ones t SEC))
(ensures mask_select mask a b == (if v mask = 0 then b else a)) | [] | Lib.ByteSequence.mask_select_lemma | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mask: Lib.IntTypes.int_t t Lib.IntTypes.SEC ->
a: Lib.IntTypes.int_t t Lib.IntTypes.SEC ->
b: Lib.IntTypes.int_t t Lib.IntTypes.SEC
-> FStar.Pervasives.Lemma
(requires
Lib.IntTypes.v mask = 0 \/
Lib.IntTypes.v mask = Lib.IntTypes.v (Lib.IntTypes.ones t Lib.IntTypes.SEC))
(ensures
Lib.ByteSequence.mask_select mask a b ==
(match Lib.IntTypes.v mask = 0 with
| true -> b
| _ -> a)) | {
"end_col": 10,
"end_line": 94,
"start_col": 35,
"start_line": 81
} |
Prims.Tot | val nat_from_intseq_le: #t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l) -> n:nat{n < pow2 (length b * bits t)} | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_from_intseq_le = nat_from_intseq_le_ | val nat_from_intseq_le: #t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l) -> n:nat{n < pow2 (length b * bits t)}
let nat_from_intseq_le = | false | null | false | nat_from_intseq_le_ | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.ByteSequence.nat_from_intseq_le_"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_from_intseq_le: #t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l) -> n:nat{n < pow2 (length b * bits t)} | [] | Lib.ByteSequence.nat_from_intseq_le | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Sequence.seq (Lib.IntTypes.uint_t t l)
-> n: Prims.nat{n < Prims.pow2 (Lib.Sequence.length b * Lib.IntTypes.bits t)} | {
"end_col": 44,
"end_line": 141,
"start_col": 25,
"start_line": 141
} |
Prims.Tot | val nat_from_intseq_be: #t:inttype{unsigned t} -> #l:secrecy_level -> b:seq (uint_t t l)
-> n:nat{n < pow2 (length b * bits t)} | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_from_intseq_be = nat_from_intseq_be_ | val nat_from_intseq_be: #t:inttype{unsigned t} -> #l:secrecy_level -> b:seq (uint_t t l)
-> n:nat{n < pow2 (length b * bits t)}
let nat_from_intseq_be = | false | null | false | nat_from_intseq_be_ | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.ByteSequence.nat_from_intseq_be_"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n' | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_from_intseq_be: #t:inttype{unsigned t} -> #l:secrecy_level -> b:seq (uint_t t l)
-> n:nat{n < pow2 (length b * bits t)} | [] | Lib.ByteSequence.nat_from_intseq_be | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Sequence.seq (Lib.IntTypes.uint_t t l)
-> n: Prims.nat{n < Prims.pow2 (Lib.Sequence.length b * Lib.IntTypes.bits t)} | {
"end_col": 44,
"end_line": 122,
"start_col": 25,
"start_line": 122
} |
Prims.Tot | val nat_to_intseq_be: #t:inttype{unsigned t} -> #l:secrecy_level -> len:nat -> n:nat{n < pow2 (bits t * len)} ->
b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_be b} | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_to_intseq_be = nat_to_intseq_be_ | val nat_to_intseq_be: #t:inttype{unsigned t} -> #l:secrecy_level -> len:nat -> n:nat{n < pow2 (bits t * len)} ->
b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_be b}
let nat_to_intseq_be = | false | null | false | nat_to_intseq_be_ | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.ByteSequence.nat_to_intseq_be_"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_to_intseq_be: #t:inttype{unsigned t} -> #l:secrecy_level -> len:nat -> n:nat{n < pow2 (bits t * len)} ->
b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_be b} | [] | Lib.ByteSequence.nat_to_intseq_be | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Prims.nat -> n: Prims.nat{n < Prims.pow2 (Lib.IntTypes.bits t * len)}
-> b:
Lib.Sequence.seq (Lib.IntTypes.uint_t t l)
{Lib.Sequence.length b == len /\ n == Lib.ByteSequence.nat_from_intseq_be b} | {
"end_col": 40,
"end_line": 163,
"start_col": 23,
"start_line": 163
} |
FStar.Pervasives.Lemma | val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k))) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i)) | val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k = | false | null | true | assert (forall (n: nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i)) | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"Prims._assert",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Prims.eq2",
"FStar.Seq.Base.index",
"FStar.Seq.Base.slice",
"Prims.op_Addition",
"Prims.unit"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k))) | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k))) | [] | Lib.ByteSequence.lemma_not_equal_slice | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b1: FStar.Seq.Base.seq a ->
b2: FStar.Seq.Base.seq a ->
i: Prims.nat ->
j: Prims.nat ->
k:
Prims.nat
{ i <= j /\ i <= k /\ j <= k /\ k <= FStar.Seq.Base.length b1 /\
k <= FStar.Seq.Base.length b2 }
-> FStar.Pervasives.Lemma
(requires ~(FStar.Seq.Base.equal (FStar.Seq.Base.slice b1 i j) (FStar.Seq.Base.slice b2 i j)))
(ensures ~(FStar.Seq.Base.equal (FStar.Seq.Base.slice b1 i k) (FStar.Seq.Base.slice b2 i k))) | {
"end_col": 92,
"end_line": 20,
"start_col": 2,
"start_line": 20
} |
Prims.Tot | val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t)) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uints_to_bytes_le_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_le #t #l b.[i] | val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_le_inner #t #l #len b i () = | false | null | false | let open Lib.Sequence in (), uint_to_bytes_le #t #l b.[ i ] | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Prims.pow2",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Prims.nat",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.ByteSequence.uint_to_bytes_le",
"Lib.Sequence.op_String_Access",
"FStar.Pervasives.Native.tuple2"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end
let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n)
let index_uint_to_bytes_le #t #l u =
Classical.forall_intro (index_nat_to_intseq_le #U8 #l (numbytes t) (v u))
let uint_to_bytes_be #t #l n =
nat_to_bytes_be (numbytes t) (v n)
let index_uint_to_bytes_be #t #l u =
Classical.forall_intro (index_nat_to_intseq_be #U8 #l (numbytes t) (v u))
let uint_from_bytes_le #t #l b =
let n = nat_from_intseq_le #U8 b in
uint #t #l n
let uint_from_bytes_be #t #l b =
let n = nat_from_intseq_be #U8 b in
uint #t #l n
val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t)) | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t)) | [] | Lib.ByteSequence.uints_to_bytes_le_inner | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Sequence.lseq (Lib.IntTypes.int_t t l) len -> i: Prims.nat{i < len} -> _: Prims.unit
-> Prims.unit *
Lib.Sequence.lseq (Lib.IntTypes.uint_t Lib.IntTypes.U8 l) (Lib.IntTypes.numbytes t) | {
"end_col": 34,
"end_line": 307,
"start_col": 2,
"start_line": 306
} |
Prims.Tot | val uint_to_bytes_le: #t:inttype{unsigned t} -> #l:secrecy_level -> uint_t t l -> lbytes_l l (numbytes t) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n) | val uint_to_bytes_le: #t:inttype{unsigned t} -> #l:secrecy_level -> uint_t t l -> lbytes_l l (numbytes t)
let uint_to_bytes_le #t #l n = | false | null | false | nat_to_bytes_le (numbytes t) (v n) | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.uint_t",
"Lib.ByteSequence.nat_to_bytes_le",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.v",
"Lib.ByteSequence.lbytes_l"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint_to_bytes_le: #t:inttype{unsigned t} -> #l:secrecy_level -> uint_t t l -> lbytes_l l (numbytes t) | [] | Lib.ByteSequence.uint_to_bytes_le | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Lib.IntTypes.uint_t t l -> Lib.ByteSequence.lbytes_l l (Lib.IntTypes.numbytes t) | {
"end_col": 36,
"end_line": 282,
"start_col": 2,
"start_line": 282
} |
FStar.Pervasives.Lemma | val lemma_uint_to_from_bytes_le_preserves_value :
#t : inttype{unsigned t /\ ~(U1? t)} ->
#l : secrecy_level ->
i : uint_t t l ->
Lemma(uint_from_bytes_le #t #l (uint_to_bytes_le #t #l i) == i) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_uint_to_from_bytes_le_preserves_value #t #l i =
lemma_reveal_uint_to_bytes_le #t #l (uint_to_bytes_le #t #l i);
assert(nat_from_bytes_le (uint_to_bytes_le #t #l i) ==
uint_v (uint_from_bytes_le #t #l (uint_to_bytes_le #t #l i)));
lemma_uint_to_bytes_le_preserves_value #t #l i;
assert(nat_from_bytes_le (uint_to_bytes_le #t #l i) == uint_v i) | val lemma_uint_to_from_bytes_le_preserves_value :
#t : inttype{unsigned t /\ ~(U1? t)} ->
#l : secrecy_level ->
i : uint_t t l ->
Lemma(uint_from_bytes_le #t #l (uint_to_bytes_le #t #l i) == i)
let lemma_uint_to_from_bytes_le_preserves_value #t #l i = | false | null | true | lemma_reveal_uint_to_bytes_le #t #l (uint_to_bytes_le #t #l i);
assert (nat_from_bytes_le (uint_to_bytes_le #t #l i) ==
uint_v (uint_from_bytes_le #t #l (uint_to_bytes_le #t #l i)));
lemma_uint_to_bytes_le_preserves_value #t #l i;
assert (nat_from_bytes_le (uint_to_bytes_le #t #l i) == uint_v i) | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Prims.l_not",
"Lib.IntTypes.uu___is_U1",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.uint_t",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"Lib.Sequence.length",
"Lib.IntTypes.U8",
"Lib.ByteSequence.uint_to_bytes_le",
"Lib.ByteSequence.nat_from_bytes_le",
"Lib.IntTypes.uint_v",
"Prims.unit",
"Lib.ByteSequence.lemma_uint_to_bytes_le_preserves_value",
"Lib.ByteSequence.uint_from_bytes_le",
"Lib.ByteSequence.lemma_reveal_uint_to_bytes_le"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end
let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n)
let index_uint_to_bytes_le #t #l u =
Classical.forall_intro (index_nat_to_intseq_le #U8 #l (numbytes t) (v u))
let uint_to_bytes_be #t #l n =
nat_to_bytes_be (numbytes t) (v n)
let index_uint_to_bytes_be #t #l u =
Classical.forall_intro (index_nat_to_intseq_be #U8 #l (numbytes t) (v u))
let uint_from_bytes_le #t #l b =
let n = nat_from_intseq_le #U8 b in
uint #t #l n
let uint_from_bytes_be #t #l b =
let n = nat_from_intseq_be #U8 b in
uint #t #l n
val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_le_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_le #t #l b.[i]
let uints_to_bytes_le #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_le_inner #t #l #len ul) () in
o
(* Could also be written more simply as:
let uints_to_bytes_le #t #l #len ul =
createi (len * numbytes t)
(fun i -> let s = uint_to_bytes_le ul.[i / numbytes t] in
s.[i % numbytes t])
*)
let index_uints_to_bytes_le #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_le_inner #t #l #len ul) i
val uints_to_bytes_be_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_be_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_be #t #l b.[i]
let uints_to_bytes_be #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_be_inner #t #l #len ul) () in
o
let index_uints_to_bytes_be #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_be_inner #t #l #len ul) i
let uints_from_bytes_le #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_le (sub b (i * numbytes t) (numbytes t)))
let index_uints_from_bytes_le #t #l #len b i = ()
let uints_from_bytes_be #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_be (sub b (i * numbytes t) (numbytes t)))
let index_uints_from_bytes_be #t #l #len b i = ()
let uint_at_index_le #t #l #len b i =
uint_from_bytes_le (sub b (i * numbytes t) (numbytes t))
let uint_at_index_be #t #l #len b i =
uint_from_bytes_be (sub b (i * numbytes t) (numbytes t))
#push-options "--max_fuel 1"
val nat_from_intseq_slice_lemma_aux: len:pos -> a:nat -> b:nat -> c:nat -> i:pos{i <= len} ->
Lemma (pow2 ((i - 1) * c) * (a + pow2 c * b) == pow2 ((i - 1) * c) * a + pow2 (i * c) * b)
let nat_from_intseq_slice_lemma_aux len a b c i =
FStar.Math.Lemmas.distributivity_add_right (pow2 ((i - 1) * c)) a (pow2 c * b);
FStar.Math.Lemmas.paren_mul_right (pow2 ((i - 1) * c)) (pow2 c) b;
FStar.Math.Lemmas.pow2_plus ((i - 1) * c) c
val nat_from_intseq_le_slice_lemma_:
#t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat
-> b:lseq (int_t t l) len
-> i:nat{i <= len} ->
Lemma (nat_from_intseq_le_ b == nat_from_intseq_le_ (slice b 0 i) + pow2 (i * bits t) * nat_from_intseq_le_ (slice b i len))
let rec nat_from_intseq_le_slice_lemma_ #t #l #len b i =
if len = 0 then ()
else begin
if i = 0 then ()
else begin
let b1 = slice b 0 i in
nat_from_intseq_le_slice_lemma_ #t #l #i b1 (i - 1);
assert (nat_from_intseq_le_ b1 == nat_from_intseq_le_ (slice b 0 (i - 1)) + pow2 ((i - 1) * bits t) * v b.[i - 1]);
nat_from_intseq_le_slice_lemma_ #t #l #len b (i - 1);
assert (nat_from_intseq_le_ b == nat_from_intseq_le_ (slice b 0 (i - 1)) + pow2 ((i - 1) * bits t) * nat_from_intseq_le_ (slice b (i - 1) len));
nat_from_intseq_slice_lemma_aux len (v b.[i - 1]) (nat_from_intseq_le_ (slice b i len)) (bits t) i
end
end
let nat_from_intseq_le_lemma0 #t #l b = ()
let nat_from_intseq_le_slice_lemma #t #l #len b i =
nat_from_intseq_le_slice_lemma_ b i
val nat_from_intseq_be_slice_lemma_:
#t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat
-> b:lseq (int_t t l) len
-> i:nat{i <= len} ->
Lemma (ensures (nat_from_intseq_be_ b == nat_from_intseq_be_ (slice b i len) + pow2 ((len - i) * bits t) * nat_from_intseq_be_ (slice b 0 i)))
(decreases (len - i))
let rec nat_from_intseq_be_slice_lemma_ #t #l #len b i =
if len = 0 then ()
else begin
if i = len then ()
else begin
let b1 = slice b i len in
nat_from_intseq_be_slice_lemma_ #t #l #(len - i) b1 1;
assert (nat_from_intseq_be_ b1 == nat_from_intseq_be_ (slice b (i + 1) len) + pow2 ((len - i - 1) * bits t) * v b.[i]);
nat_from_intseq_be_slice_lemma_ #t #l #len b (i + 1);
assert (nat_from_intseq_be_ b == nat_from_intseq_be_ (slice b (i + 1) len) + pow2 ((len - i - 1) * bits t) * nat_from_intseq_be_ (slice b 0 (i + 1)));
nat_from_intseq_slice_lemma_aux len (v b.[i]) (nat_from_intseq_be_ (slice b 0 i)) (bits t) (len - i)
end
end
let nat_from_intseq_be_lemma0 #t #l b = ()
#pop-options
let nat_from_intseq_be_slice_lemma #t #l #len b i =
nat_from_intseq_be_slice_lemma_ #t #l #len b i
val uints_from_bytes_le_slice_lemma_lp:
#t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) -> i:nat -> j:nat{i <= j /\ j <= len} -> k:nat{k < j - i} ->
Lemma (index (slice (uints_from_bytes_le #t #l #len b) i j) k ==
uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_le_slice_lemma_lp #t #l #len b i j k =
let r = slice (uints_from_bytes_le #t #l #len b) i j in
index_uints_from_bytes_le #t #l #len b (i + k);
assert (r.[k] == uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
val uints_from_bytes_le_slice_lemma_rp:
#t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) -> i:nat -> j:nat{i <= j /\ j <= len} -> k:nat{k < j - i} ->
Lemma (index (uints_from_bytes_le #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t))) k ==
uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_le_slice_lemma_rp #t #l #len b i j k =
let b1 = slice b (i * numbytes t) (j * numbytes t) in
let r = uints_from_bytes_le #t #l #(j-i) b1 in
index_uints_from_bytes_le #t #l #(j-i) b1 k;
assert (r.[k] == uint_from_bytes_le (sub b1 (k * numbytes t) (numbytes t)));
assert (r.[k] == uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_le_slice_lemma #t #l #len b i j =
FStar.Classical.forall_intro (uints_from_bytes_le_slice_lemma_lp #t #l #len b i j);
FStar.Classical.forall_intro (uints_from_bytes_le_slice_lemma_rp #t #l #len b i j);
eq_intro (slice (uints_from_bytes_le #t #l #len b) i j) (uints_from_bytes_le #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t)))
#push-options "--max_fuel 1"
val uints_from_bytes_le_nat_lemma_aux:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) ->
Lemma (nat_from_intseq_le_ (uints_from_bytes_le #t #l #len b) ==
nat_from_intseq_le_ (slice b 0 (numbytes t)) + pow2 (bits t) *
nat_from_intseq_le_ (uints_from_bytes_le #t #l #(len-1) (slice b (numbytes t) (len * numbytes t))))
let uints_from_bytes_le_nat_lemma_aux #t #l #len b =
let r = uints_from_bytes_le #t #l #len b in
assert (nat_from_intseq_le_ r == v r.[0] + pow2 (bits t) * nat_from_intseq_le_ (slice r 1 len));
assert (nat_from_intseq_le_ (slice b 0 (numbytes t)) == v r.[0]);
uints_from_bytes_le_slice_lemma #t #l #len b 1 len;
assert (slice r 1 len == uints_from_bytes_le #t #l #(len-1) (slice b (numbytes t) (len * numbytes t)))
val uints_from_bytes_le_nat_lemma_:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) ->
Lemma (nat_from_intseq_le_ (uints_from_bytes_le #t #l #len b) == nat_from_intseq_le_ b)
let rec uints_from_bytes_le_nat_lemma_ #t #l #len b =
if len = 0 then ()
else begin
let b1 = slice b (numbytes t) (len * numbytes t) in
nat_from_intseq_le_slice_lemma_ #U8 #l #(len * numbytes t) b (numbytes t);
assert (nat_from_intseq_le_ b == nat_from_intseq_le_ (slice b 0 (numbytes t)) + pow2 (bits t) * nat_from_intseq_le_ b1);
uints_from_bytes_le_nat_lemma_ #t #l #(len - 1) b1;
assert (nat_from_intseq_le_ (uints_from_bytes_le #t #l #(len - 1) b1) == nat_from_intseq_le_ b1);
uints_from_bytes_le_nat_lemma_aux #t #l #len b
end
let uints_from_bytes_le_nat_lemma #t #l #len b =
uints_from_bytes_le_nat_lemma_ #t #l #len b
val uints_from_bytes_be_slice_lemma_lp:
#t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) -> i:nat -> j:nat{i <= j /\ j <= len} -> k:nat{k < j - i} ->
Lemma (index (slice (uints_from_bytes_le #t #l #len b) i j) k ==
uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_be_slice_lemma_lp #t #l #len b i j k =
let r = slice (uints_from_bytes_le #t #l #len b) i j in
index_uints_from_bytes_be #t #l #len b (i + k);
assert (r.[k] == uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
val uints_from_bytes_be_slice_lemma_rp:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t)
-> i:nat
-> j:nat{i <= j /\ j <= len}
-> k:nat{k < j - i} ->
Lemma (index (uints_from_bytes_be #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t))) k ==
uint_from_bytes_be (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_be_slice_lemma_rp #t #l #len b i j k =
let b1 = slice b (i * numbytes t) (j * numbytes t) in
let r = uints_from_bytes_be #t #l #(j-i) b1 in
index_uints_from_bytes_be #t #l #(j-i) b1 k;
assert (r.[k] == uint_from_bytes_be (sub b1 (k * numbytes t) (numbytes t)));
assert (r.[k] == uint_from_bytes_be (sub b ((i + k) * numbytes t) (numbytes t)))
val uints_from_bytes_be_slice_lemma: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) -> i:nat -> j:nat{i <= j /\ j <= len} ->
Lemma (slice (uints_from_bytes_be #t #l #len b) i j == uints_from_bytes_be #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t)))
let uints_from_bytes_be_slice_lemma #t #l #len b i j =
FStar.Classical.forall_intro (uints_from_bytes_be_slice_lemma_lp #t #l #len b i j);
FStar.Classical.forall_intro (uints_from_bytes_be_slice_lemma_rp #t #l #len b i j);
eq_intro (slice (uints_from_bytes_be #t #l #len b) i j) (uints_from_bytes_be #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t)))
val uints_from_bytes_be_nat_lemma_aux:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) ->
Lemma (nat_from_intseq_be_ (uints_from_bytes_be #t #l #len b) ==
nat_from_intseq_be (uints_from_bytes_be #t #l #(len-1) (slice b (numbytes t) (len * numbytes t))) + pow2 ((len - 1) * bits t) * nat_from_intseq_be_ (slice b 0 (numbytes t)))
let uints_from_bytes_be_nat_lemma_aux #t #l #len b =
let r = uints_from_bytes_be #t #l #len b in
uints_from_bytes_be_slice_lemma #t #l #len b 1 len;
nat_from_intseq_be_slice_lemma r 1;
assert (nat_from_intseq_be_ r == nat_from_intseq_be (slice r 1 len) + pow2 ((len - 1) * bits t) * uint_v r.[0])
val uints_from_bytes_be_nat_lemma_:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) ->
Lemma (nat_from_intseq_be_ (uints_from_bytes_be #t #l #len b) == nat_from_intseq_be_ b)
let rec uints_from_bytes_be_nat_lemma_ #t #l #len b =
if len = 0 then ()
else begin
uints_from_bytes_be_nat_lemma_aux #t #l #len b;
nat_from_intseq_be_slice_lemma_ b (numbytes t);
uints_from_bytes_be_nat_lemma_ #t #l #(len - 1) (slice b (numbytes t) (len * numbytes t))
end
let uints_from_bytes_be_nat_lemma #t #l #len b =
uints_from_bytes_be_nat_lemma_ #t #l #len b
#pop-options
val index_uints_to_bytes_le_aux:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma (let s:lseq (int_t t l) len = nat_to_intseq_le #t #l len n in
Seq.index (uints_to_bytes_le #t #l #len s) i ==
Seq.index (nat_to_bytes_le #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t))
let index_uints_to_bytes_le_aux #t #l len n i =
let open Lib.Sequence in
let s: lseq (int_t t l) len = nat_to_intseq_le #t #l len n in
index_generate_blocks (numbytes t) len len
(uints_to_bytes_le_inner #t #l #len s) i
val index_uints_to_bytes_be_aux:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma (let s:lseq (int_t t l) len = nat_to_intseq_be #t #l len n in
Seq.index (uints_to_bytes_be #t #l #len s) i ==
Seq.index (nat_to_bytes_be #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t))
let index_uints_to_bytes_be_aux #t #l len n i =
let open Lib.Sequence in
let s:lseq (int_t t l) len = nat_to_intseq_be #t #l len n in
index_generate_blocks (numbytes t) len len
(uints_to_bytes_be_inner #t #l #len s) i
val modulo_pow2_prop: r:pos -> a:nat -> b:nat -> c:nat{c < b} -> Lemma
((a % pow2 (r * b) / pow2 (r * c)) % pow2 r == (a / pow2 (r * c)) % pow2 r)
let modulo_pow2_prop r a b c =
calc (==) {
((a % pow2 (r * b)) / pow2 (r * c)) % pow2 r;
== { Math.Lemmas.pow2_modulo_division_lemma_1 a (r * c) (r * b) }
((a / pow2 (r * c) % pow2 (r * b - r * c))) % pow2 r;
== { Math.Lemmas.lemma_mul_sub_distr r b c }
((a / pow2 (r * c) % pow2 (r * (b - c)))) % pow2 r;
== { Math.Lemmas.pow2_plus r (r * (b - c) - r) }
(a / pow2 (r * c)) % (pow2 r * pow2 (r * (b - c) - r)) % pow2 r;
== { Math.Lemmas.modulo_modulo_lemma (a / pow2 (r * c)) (pow2 r) (pow2 (r * (b - c) - r))}
(a / pow2 (r * c)) % pow2 r;
}
val some_arithmetic: t:inttype{~(U1? t)} -> n:nat -> i:nat -> Lemma
(let m = numbytes t in
n / pow2 (bits t * (i / m)) % pow2 (bits t) / pow2 (8 * (i % m)) % pow2 8 ==
n / pow2 (8 * i) % pow2 8)
#push-options "--z3rlimit 150 --fuel 0 --ifuel 0"
let some_arithmetic t n i =
let m = numbytes t in
calc (==) {
n / pow2 (bits t * (i / m)) % pow2 (bits t) / pow2 (8 * (i % m)) % pow2 8;
== { assert (bits t == 8 * m) }
n / pow2 ((8 * m) * (i / m)) % pow2 (8 * m) / pow2 (8 * (i % m)) % pow2 8;
== { FStar.Math.Lemmas.paren_mul_right 8 m (i / m);
FStar.Math.Lemmas.euclidean_division_definition i m }
n / pow2 (8 * (i - i % m)) % pow2 (8 * m) / pow2 (8 * (i % m)) % pow2 8;
== { Math.Lemmas.distributivity_sub_right 8 i (i % m) }
n / pow2 (8 * i - 8 * (i % m)) % pow2 (8 * m) / pow2 (8 * (i % m)) % pow2 8;
== { modulo_pow2_prop 8 (n / pow2 (8 * i - 8 * (i % m))) m (i % m) }
(n / pow2 (8 * i - 8 * (i % m))) / pow2 (8 * (i % m)) % pow2 8;
== { Math.Lemmas.division_multiplication_lemma n
(pow2 (8 * i - 8 * (i % m))) (pow2 (8 * (i % m))) }
(n / (pow2 (8 * i - 8 * (i % m)) * pow2 (8 * (i % m)))) % pow2 8;
== { Math.Lemmas.pow2_plus (8 * i - 8 * (i % m)) (8 * (i % m)) }
(n / pow2 (8 * i)) % pow2 8;
}
#pop-options
val index_nat_to_intseq_to_bytes_le:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma (let s:lseq (int_t t l) len = nat_to_intseq_le #t #l len n in
Seq.index (nat_to_bytes_le #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t) ==
Seq.index (nat_to_bytes_le #l (len * numbytes t) n) i)
let index_nat_to_intseq_to_bytes_le #t #l len n i =
let s:lseq (int_t t l) len = nat_to_intseq_le #t #l len n in
let m = numbytes t in
index_nat_to_intseq_le #U8 #l (len * m) n i;
assert (Seq.index (nat_to_bytes_le #l (len * m) n) i ==
uint (n / pow2 (8 * i) % pow2 8));
index_nat_to_intseq_le #U8 #l m (v s.[i / m]) (i % m);
assert (Seq.index (nat_to_bytes_le #l m (v s.[i / m])) (i % m) ==
uint (v s.[i / m] / pow2 (8 * (i % m)) % pow2 8));
index_nat_to_intseq_le #t #l len n (i / m);
some_arithmetic t n i
val uints_to_bytes_le_nat_lemma_: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma
(Seq.index (uints_to_bytes_le #t #l #len (nat_to_intseq_le #t #l len n)) i ==
Seq.index (nat_to_bytes_le (len * numbytes t) n) i)
let uints_to_bytes_le_nat_lemma_ #t #l len n i =
let s:lseq (uint_t t l) len = nat_to_intseq_le #t #l len n in
calc (==) {
Seq.index (uints_to_bytes_le #t #l #len (nat_to_intseq_le #t #l len n)) i;
== { index_uints_to_bytes_le_aux #t #l len n i }
Seq.index (nat_to_bytes_le #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t);
== { index_nat_to_intseq_to_bytes_le #t #l len n i}
Seq.index (nat_to_bytes_le (len * numbytes t) n) i;
}
let uints_to_bytes_le_nat_lemma #t #l len n =
Classical.forall_intro (uints_to_bytes_le_nat_lemma_ #t #l len n);
eq_intro (uints_to_bytes_le #t #l #len (nat_to_intseq_le #t #l len n))
(nat_to_bytes_le (len * numbytes t) n)
val index_nat_to_intseq_to_bytes_be:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma (let s:lseq (int_t t l) len = nat_to_intseq_be #t #l len n in
Seq.index (nat_to_bytes_be #l (numbytes t) (v s.[len - 1 - i / numbytes t])) (numbytes t - 1 - i % numbytes t) ==
Seq.index (nat_to_bytes_be #l (len * numbytes t) n) (len * numbytes t - i - 1))
let index_nat_to_intseq_to_bytes_be #t #l len n i =
let s:lseq (uint_t t l) len = nat_to_intseq_be #t #l len n in
let m = numbytes t in
calc (==) {
Seq.index (nat_to_bytes_be #l m (v s.[len - 1 - i / m])) (m - (i % m) - 1);
== { index_nat_to_intseq_be #U8 #l m (v s.[len - 1 - i / m]) (i % m) }
uint (v s.[len - 1 - i / m] / pow2 (8 * (i % m)) % pow2 8);
== { index_nat_to_intseq_be #t #l len n (i / m) }
uint ((n / pow2 (bits t * (i / m)) % pow2 (bits t)) / pow2 (8 * (i % m)) % pow2 8);
== { some_arithmetic t n i }
uint (n / pow2 (8 * i) % pow2 8);
== { index_nat_to_intseq_be #U8 #l (len * m) n i }
Seq.index (nat_to_bytes_be #l (len * m) n) (len * m - 1 - i);
}
val uints_to_bytes_be_nat_lemma_: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma
(Seq.index (uints_to_bytes_be #t #l #len (nat_to_intseq_be #t #l len n)) i ==
Seq.index (nat_to_bytes_be (len * numbytes t) n) i)
let uints_to_bytes_be_nat_lemma_ #t #l len n i =
let s:lseq (uint_t t l) len = nat_to_intseq_be #t #l len n in
calc (==) {
Seq.index (uints_to_bytes_be #t #l #len (nat_to_intseq_be #t #l len n)) i;
== { index_uints_to_bytes_be_aux #t #l len n i }
Seq.index (nat_to_bytes_be #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t);
== { index_nat_to_intseq_to_bytes_be #t #l len n (len * numbytes t - 1 - i)}
Seq.index (nat_to_bytes_be (len * numbytes t) n) i;
}
let uints_to_bytes_be_nat_lemma #t #l len n =
Classical.forall_intro (uints_to_bytes_be_nat_lemma_ #t #l len n);
eq_intro (uints_to_bytes_be #t #l #len (nat_to_intseq_be #t #l len n))
(nat_to_bytes_be (len * numbytes t) n)
#push-options "--max_fuel 1"
let rec nat_from_intseq_le_inj #t #l b1 b2 =
if length b1 = 0 then ()
else begin
nat_from_intseq_le_inj (Seq.slice b1 1 (length b1)) (Seq.slice b2 1 (length b2));
Seq.lemma_split b1 1;
Seq.lemma_split b2 1
end
let rec nat_from_intseq_be_inj #t #l b1 b2 =
if length b1 = 0 then ()
else begin
nat_from_intseq_be_inj (Seq.slice b1 0 (length b1 - 1)) (Seq.slice b2 0 (length b2 - 1));
Seq.lemma_split b1 (length b1 - 1);
Seq.lemma_split b2 (length b2 - 1)
end
let lemma_nat_to_from_bytes_be_preserves_value #l b len x = ()
let lemma_nat_to_from_bytes_le_preserves_value #l b len x = ()
let lemma_uint_to_bytes_le_preserves_value #t #l x = ()
let lemma_uint_to_bytes_be_preserves_value #t #l x = ()
let lemma_nat_from_to_intseq_le_preserves_value #t #l len b =
nat_from_intseq_le_inj (nat_to_intseq_le len (nat_from_intseq_le b)) b
let lemma_nat_from_to_intseq_be_preserves_value #t #l len b =
nat_from_intseq_be_inj (nat_to_intseq_be len (nat_from_intseq_be b)) b
let lemma_nat_from_to_bytes_le_preserves_value #l b len =
lemma_nat_from_to_intseq_le_preserves_value len b
let lemma_nat_from_to_bytes_be_preserves_value #l b len =
lemma_nat_from_to_intseq_be_preserves_value len b
let lemma_reveal_uint_to_bytes_le #t #l b = ()
let lemma_reveal_uint_to_bytes_be #t #l b = () | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_uint_to_from_bytes_le_preserves_value :
#t : inttype{unsigned t /\ ~(U1? t)} ->
#l : secrecy_level ->
i : uint_t t l ->
Lemma(uint_from_bytes_le #t #l (uint_to_bytes_le #t #l i) == i) | [] | Lib.ByteSequence.lemma_uint_to_from_bytes_le_preserves_value | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Lib.IntTypes.uint_t t l
-> FStar.Pervasives.Lemma
(ensures Lib.ByteSequence.uint_from_bytes_le (Lib.ByteSequence.uint_to_bytes_le i) == i) | {
"end_col": 66,
"end_line": 767,
"start_col": 2,
"start_line": 763
} |
FStar.Pervasives.Lemma | val nat_from_intseq_slice_lemma_aux: len:pos -> a:nat -> b:nat -> c:nat -> i:pos{i <= len} ->
Lemma (pow2 ((i - 1) * c) * (a + pow2 c * b) == pow2 ((i - 1) * c) * a + pow2 (i * c) * b) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_from_intseq_slice_lemma_aux len a b c i =
FStar.Math.Lemmas.distributivity_add_right (pow2 ((i - 1) * c)) a (pow2 c * b);
FStar.Math.Lemmas.paren_mul_right (pow2 ((i - 1) * c)) (pow2 c) b;
FStar.Math.Lemmas.pow2_plus ((i - 1) * c) c | val nat_from_intseq_slice_lemma_aux: len:pos -> a:nat -> b:nat -> c:nat -> i:pos{i <= len} ->
Lemma (pow2 ((i - 1) * c) * (a + pow2 c * b) == pow2 ((i - 1) * c) * a + pow2 (i * c) * b)
let nat_from_intseq_slice_lemma_aux len a b c i = | false | null | true | FStar.Math.Lemmas.distributivity_add_right (pow2 ((i - 1) * c)) a (pow2 c * b);
FStar.Math.Lemmas.paren_mul_right (pow2 ((i - 1) * c)) (pow2 c) b;
FStar.Math.Lemmas.pow2_plus ((i - 1) * c) c | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"lemma"
] | [
"Prims.pos",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Math.Lemmas.pow2_plus",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Prims.unit",
"FStar.Math.Lemmas.paren_mul_right",
"Prims.pow2",
"FStar.Math.Lemmas.distributivity_add_right"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end
let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n)
let index_uint_to_bytes_le #t #l u =
Classical.forall_intro (index_nat_to_intseq_le #U8 #l (numbytes t) (v u))
let uint_to_bytes_be #t #l n =
nat_to_bytes_be (numbytes t) (v n)
let index_uint_to_bytes_be #t #l u =
Classical.forall_intro (index_nat_to_intseq_be #U8 #l (numbytes t) (v u))
let uint_from_bytes_le #t #l b =
let n = nat_from_intseq_le #U8 b in
uint #t #l n
let uint_from_bytes_be #t #l b =
let n = nat_from_intseq_be #U8 b in
uint #t #l n
val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_le_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_le #t #l b.[i]
let uints_to_bytes_le #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_le_inner #t #l #len ul) () in
o
(* Could also be written more simply as:
let uints_to_bytes_le #t #l #len ul =
createi (len * numbytes t)
(fun i -> let s = uint_to_bytes_le ul.[i / numbytes t] in
s.[i % numbytes t])
*)
let index_uints_to_bytes_le #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_le_inner #t #l #len ul) i
val uints_to_bytes_be_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_be_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_be #t #l b.[i]
let uints_to_bytes_be #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_be_inner #t #l #len ul) () in
o
let index_uints_to_bytes_be #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_be_inner #t #l #len ul) i
let uints_from_bytes_le #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_le (sub b (i * numbytes t) (numbytes t)))
let index_uints_from_bytes_le #t #l #len b i = ()
let uints_from_bytes_be #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_be (sub b (i * numbytes t) (numbytes t)))
let index_uints_from_bytes_be #t #l #len b i = ()
let uint_at_index_le #t #l #len b i =
uint_from_bytes_le (sub b (i * numbytes t) (numbytes t))
let uint_at_index_be #t #l #len b i =
uint_from_bytes_be (sub b (i * numbytes t) (numbytes t))
#push-options "--max_fuel 1"
val nat_from_intseq_slice_lemma_aux: len:pos -> a:nat -> b:nat -> c:nat -> i:pos{i <= len} ->
Lemma (pow2 ((i - 1) * c) * (a + pow2 c * b) == pow2 ((i - 1) * c) * a + pow2 (i * c) * b) | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_from_intseq_slice_lemma_aux: len:pos -> a:nat -> b:nat -> c:nat -> i:pos{i <= len} ->
Lemma (pow2 ((i - 1) * c) * (a + pow2 c * b) == pow2 ((i - 1) * c) * a + pow2 (i * c) * b) | [] | Lib.ByteSequence.nat_from_intseq_slice_lemma_aux | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Prims.pos -> a: Prims.nat -> b: Prims.nat -> c: Prims.nat -> i: Prims.pos{i <= len}
-> FStar.Pervasives.Lemma
(ensures
Prims.pow2 ((i - 1) * c) * (a + Prims.pow2 c * b) ==
Prims.pow2 ((i - 1) * c) * a + Prims.pow2 (i * c) * b) | {
"end_col": 45,
"end_line": 367,
"start_col": 2,
"start_line": 365
} |
Prims.Tot | val uints_from_bytes_le: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lbytes_l l (len * numbytes t) -> lseq (uint_t t l) len | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uints_from_bytes_le #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_le (sub b (i * numbytes t) (numbytes t))) | val uints_from_bytes_le: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lbytes_l l (len * numbytes t) -> lseq (uint_t t l) len
let uints_from_bytes_le #t #l #len b = | false | null | false | Lib.Sequence.createi #(int_t t l)
len
(fun i -> uint_from_bytes_le (sub b (i * numbytes t) (numbytes t))) | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Prims.l_not",
"Lib.IntTypes.uu___is_U1",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Prims.pow2",
"Lib.ByteSequence.lbytes_l",
"Lib.Sequence.createi",
"Lib.IntTypes.int_t",
"Prims.nat",
"Lib.ByteSequence.uint_from_bytes_le",
"Lib.Sequence.sub",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.Sequence.lseq"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end
let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n)
let index_uint_to_bytes_le #t #l u =
Classical.forall_intro (index_nat_to_intseq_le #U8 #l (numbytes t) (v u))
let uint_to_bytes_be #t #l n =
nat_to_bytes_be (numbytes t) (v n)
let index_uint_to_bytes_be #t #l u =
Classical.forall_intro (index_nat_to_intseq_be #U8 #l (numbytes t) (v u))
let uint_from_bytes_le #t #l b =
let n = nat_from_intseq_le #U8 b in
uint #t #l n
let uint_from_bytes_be #t #l b =
let n = nat_from_intseq_be #U8 b in
uint #t #l n
val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_le_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_le #t #l b.[i]
let uints_to_bytes_le #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_le_inner #t #l #len ul) () in
o
(* Could also be written more simply as:
let uints_to_bytes_le #t #l #len ul =
createi (len * numbytes t)
(fun i -> let s = uint_to_bytes_le ul.[i / numbytes t] in
s.[i % numbytes t])
*)
let index_uints_to_bytes_le #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_le_inner #t #l #len ul) i
val uints_to_bytes_be_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_be_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_be #t #l b.[i]
let uints_to_bytes_be #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_be_inner #t #l #len ul) () in
o
let index_uints_to_bytes_be #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_be_inner #t #l #len ul) i | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uints_from_bytes_le: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lbytes_l l (len * numbytes t) -> lseq (uint_t t l) len | [] | Lib.ByteSequence.uints_from_bytes_le | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.ByteSequence.lbytes_l l (len * Lib.IntTypes.numbytes t)
-> Lib.Sequence.lseq (Lib.IntTypes.uint_t t l) len | {
"end_col": 71,
"end_line": 344,
"start_col": 2,
"start_line": 343
} |
FStar.Pervasives.Lemma | val nat_from_intseq_le_slice_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat
-> b:lseq (uint_t t l) len -> i:nat{i <= len} ->
Lemma (nat_from_intseq_le b == nat_from_intseq_le (slice b 0 i) + pow2 (i * bits t) * nat_from_intseq_le (slice b i len)) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_from_intseq_le_slice_lemma #t #l #len b i =
nat_from_intseq_le_slice_lemma_ b i | val nat_from_intseq_le_slice_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat
-> b:lseq (uint_t t l) len -> i:nat{i <= len} ->
Lemma (nat_from_intseq_le b == nat_from_intseq_le (slice b 0 i) + pow2 (i * bits t) * nat_from_intseq_le (slice b i len))
let nat_from_intseq_le_slice_lemma #t #l #len b i = | false | null | true | nat_from_intseq_le_slice_lemma_ b i | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint_t",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Lib.ByteSequence.nat_from_intseq_le_slice_lemma_",
"Prims.unit"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end
let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n)
let index_uint_to_bytes_le #t #l u =
Classical.forall_intro (index_nat_to_intseq_le #U8 #l (numbytes t) (v u))
let uint_to_bytes_be #t #l n =
nat_to_bytes_be (numbytes t) (v n)
let index_uint_to_bytes_be #t #l u =
Classical.forall_intro (index_nat_to_intseq_be #U8 #l (numbytes t) (v u))
let uint_from_bytes_le #t #l b =
let n = nat_from_intseq_le #U8 b in
uint #t #l n
let uint_from_bytes_be #t #l b =
let n = nat_from_intseq_be #U8 b in
uint #t #l n
val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_le_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_le #t #l b.[i]
let uints_to_bytes_le #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_le_inner #t #l #len ul) () in
o
(* Could also be written more simply as:
let uints_to_bytes_le #t #l #len ul =
createi (len * numbytes t)
(fun i -> let s = uint_to_bytes_le ul.[i / numbytes t] in
s.[i % numbytes t])
*)
let index_uints_to_bytes_le #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_le_inner #t #l #len ul) i
val uints_to_bytes_be_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_be_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_be #t #l b.[i]
let uints_to_bytes_be #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_be_inner #t #l #len ul) () in
o
let index_uints_to_bytes_be #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_be_inner #t #l #len ul) i
let uints_from_bytes_le #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_le (sub b (i * numbytes t) (numbytes t)))
let index_uints_from_bytes_le #t #l #len b i = ()
let uints_from_bytes_be #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_be (sub b (i * numbytes t) (numbytes t)))
let index_uints_from_bytes_be #t #l #len b i = ()
let uint_at_index_le #t #l #len b i =
uint_from_bytes_le (sub b (i * numbytes t) (numbytes t))
let uint_at_index_be #t #l #len b i =
uint_from_bytes_be (sub b (i * numbytes t) (numbytes t))
#push-options "--max_fuel 1"
val nat_from_intseq_slice_lemma_aux: len:pos -> a:nat -> b:nat -> c:nat -> i:pos{i <= len} ->
Lemma (pow2 ((i - 1) * c) * (a + pow2 c * b) == pow2 ((i - 1) * c) * a + pow2 (i * c) * b)
let nat_from_intseq_slice_lemma_aux len a b c i =
FStar.Math.Lemmas.distributivity_add_right (pow2 ((i - 1) * c)) a (pow2 c * b);
FStar.Math.Lemmas.paren_mul_right (pow2 ((i - 1) * c)) (pow2 c) b;
FStar.Math.Lemmas.pow2_plus ((i - 1) * c) c
val nat_from_intseq_le_slice_lemma_:
#t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat
-> b:lseq (int_t t l) len
-> i:nat{i <= len} ->
Lemma (nat_from_intseq_le_ b == nat_from_intseq_le_ (slice b 0 i) + pow2 (i * bits t) * nat_from_intseq_le_ (slice b i len))
let rec nat_from_intseq_le_slice_lemma_ #t #l #len b i =
if len = 0 then ()
else begin
if i = 0 then ()
else begin
let b1 = slice b 0 i in
nat_from_intseq_le_slice_lemma_ #t #l #i b1 (i - 1);
assert (nat_from_intseq_le_ b1 == nat_from_intseq_le_ (slice b 0 (i - 1)) + pow2 ((i - 1) * bits t) * v b.[i - 1]);
nat_from_intseq_le_slice_lemma_ #t #l #len b (i - 1);
assert (nat_from_intseq_le_ b == nat_from_intseq_le_ (slice b 0 (i - 1)) + pow2 ((i - 1) * bits t) * nat_from_intseq_le_ (slice b (i - 1) len));
nat_from_intseq_slice_lemma_aux len (v b.[i - 1]) (nat_from_intseq_le_ (slice b i len)) (bits t) i
end
end
let nat_from_intseq_le_lemma0 #t #l b = () | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_from_intseq_le_slice_lemma: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat
-> b:lseq (uint_t t l) len -> i:nat{i <= len} ->
Lemma (nat_from_intseq_le b == nat_from_intseq_le (slice b 0 i) + pow2 (i * bits t) * nat_from_intseq_le (slice b i len)) | [] | Lib.ByteSequence.nat_from_intseq_le_slice_lemma | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Sequence.lseq (Lib.IntTypes.uint_t t l) len -> i: Prims.nat{i <= len}
-> FStar.Pervasives.Lemma
(ensures
Lib.ByteSequence.nat_from_intseq_le b ==
Lib.ByteSequence.nat_from_intseq_le (Lib.Sequence.slice b 0 i) +
Prims.pow2 (i * Lib.IntTypes.bits t) *
Lib.ByteSequence.nat_from_intseq_le (Lib.Sequence.slice b i len)) | {
"end_col": 37,
"end_line": 391,
"start_col": 2,
"start_line": 391
} |
Prims.Tot | val uints_to_bytes_be: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (uint_t t l) len -> lbytes_l l (len * numbytes t) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uints_to_bytes_be #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_be_inner #t #l #len ul) () in
o | val uints_to_bytes_be: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (uint_t t l) len -> lbytes_l l (len * numbytes t)
let uints_to_bytes_be #t #l #len ul = | false | null | false | let a_spec (i: nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec (uints_to_bytes_be_inner #t #l #len ul) () in
o | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Prims.pow2",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint_t",
"Lib.Sequence.seq",
"Lib.IntTypes.U8",
"Prims.eq2",
"Prims.int",
"Lib.Sequence.length",
"Lib.ByteSequence.lbytes_l",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Prims.op_Multiply",
"Lib.Sequence.generate_blocks",
"Lib.ByteSequence.uints_to_bytes_be_inner",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.eqtype",
"Prims.unit"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end
let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n)
let index_uint_to_bytes_le #t #l u =
Classical.forall_intro (index_nat_to_intseq_le #U8 #l (numbytes t) (v u))
let uint_to_bytes_be #t #l n =
nat_to_bytes_be (numbytes t) (v n)
let index_uint_to_bytes_be #t #l u =
Classical.forall_intro (index_nat_to_intseq_be #U8 #l (numbytes t) (v u))
let uint_from_bytes_le #t #l b =
let n = nat_from_intseq_le #U8 b in
uint #t #l n
let uint_from_bytes_be #t #l b =
let n = nat_from_intseq_be #U8 b in
uint #t #l n
val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_le_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_le #t #l b.[i]
let uints_to_bytes_le #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_le_inner #t #l #len ul) () in
o
(* Could also be written more simply as:
let uints_to_bytes_le #t #l #len ul =
createi (len * numbytes t)
(fun i -> let s = uint_to_bytes_le ul.[i / numbytes t] in
s.[i % numbytes t])
*)
let index_uints_to_bytes_le #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_le_inner #t #l #len ul) i
val uints_to_bytes_be_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_be_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_be #t #l b.[i] | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uints_to_bytes_be: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (uint_t t l) len -> lbytes_l l (len * numbytes t) | [] | Lib.ByteSequence.uints_to_bytes_be | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ul: Lib.Sequence.lseq (Lib.IntTypes.uint_t t l) len
-> Lib.ByteSequence.lbytes_l l (len * Lib.IntTypes.numbytes t) | {
"end_col": 3,
"end_line": 337,
"start_col": 37,
"start_line": 333
} |
Prims.Tot | val lbytes_eq: #len:size_nat -> b1:lbytes len -> b2:lbytes len -> b:bool{b <==> b1 == b2} | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy | val lbytes_eq: #len:size_nat -> b1:lbytes len -> b2:lbytes len -> b:bool{b <==> b1 == b2}
let lbytes_eq #len b1 b2 = | false | null | false | let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Lib.ByteSequence.lbytes",
"Prims.op_Equality",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_to_UInt8",
"FStar.UInt8.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_and",
"Prims.l_imp",
"Prims.eq2",
"Lib.Sequence.lseq",
"Prims.l_or",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Lib.IntTypes.ones",
"Prims.l_not",
"Lib.IntTypes.zeros",
"Lib.ByteSequence.seq_eq_mask",
"Prims.bool",
"Prims.l_iff"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC) | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lbytes_eq: #len:size_nat -> b1:lbytes len -> b2:lbytes len -> b:bool{b <==> b1 == b2} | [] | Lib.ByteSequence.lbytes_eq | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b1: Lib.ByteSequence.lbytes len -> b2: Lib.ByteSequence.lbytes len -> b: Prims.bool{b <==> b1 == b2} | {
"end_col": 37,
"end_line": 74,
"start_col": 26,
"start_line": 72
} |
FStar.Pervasives.Lemma | val lemma_nat_from_to_intseq_be_preserves_value: #t:inttype{unsigned t} -> #l:secrecy_level -> len:nat -> b:seq (uint_t t l){length b == len} ->
Lemma (nat_to_intseq_be len (nat_from_intseq_be b) == b) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_nat_from_to_intseq_be_preserves_value #t #l len b =
nat_from_intseq_be_inj (nat_to_intseq_be len (nat_from_intseq_be b)) b | val lemma_nat_from_to_intseq_be_preserves_value: #t:inttype{unsigned t} -> #l:secrecy_level -> len:nat -> b:seq (uint_t t l){length b == len} ->
Lemma (nat_to_intseq_be len (nat_from_intseq_be b) == b)
let lemma_nat_from_to_intseq_be_preserves_value #t #l len b = | false | null | true | nat_from_intseq_be_inj (nat_to_intseq_be len (nat_from_intseq_be b)) b | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Prims.nat",
"Lib.Sequence.seq",
"Lib.IntTypes.uint_t",
"Prims.eq2",
"Lib.Sequence.length",
"Lib.ByteSequence.nat_from_intseq_be_inj",
"Lib.ByteSequence.nat_to_intseq_be",
"Lib.ByteSequence.nat_from_intseq_be",
"Prims.unit"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end
let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n)
let index_uint_to_bytes_le #t #l u =
Classical.forall_intro (index_nat_to_intseq_le #U8 #l (numbytes t) (v u))
let uint_to_bytes_be #t #l n =
nat_to_bytes_be (numbytes t) (v n)
let index_uint_to_bytes_be #t #l u =
Classical.forall_intro (index_nat_to_intseq_be #U8 #l (numbytes t) (v u))
let uint_from_bytes_le #t #l b =
let n = nat_from_intseq_le #U8 b in
uint #t #l n
let uint_from_bytes_be #t #l b =
let n = nat_from_intseq_be #U8 b in
uint #t #l n
val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_le_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_le #t #l b.[i]
let uints_to_bytes_le #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_le_inner #t #l #len ul) () in
o
(* Could also be written more simply as:
let uints_to_bytes_le #t #l #len ul =
createi (len * numbytes t)
(fun i -> let s = uint_to_bytes_le ul.[i / numbytes t] in
s.[i % numbytes t])
*)
let index_uints_to_bytes_le #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_le_inner #t #l #len ul) i
val uints_to_bytes_be_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_be_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_be #t #l b.[i]
let uints_to_bytes_be #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_be_inner #t #l #len ul) () in
o
let index_uints_to_bytes_be #t #l #len ul i =
index_generate_blocks (numbytes t) len len (uints_to_bytes_be_inner #t #l #len ul) i
let uints_from_bytes_le #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_le (sub b (i * numbytes t) (numbytes t)))
let index_uints_from_bytes_le #t #l #len b i = ()
let uints_from_bytes_be #t #l #len b =
Lib.Sequence.createi #(int_t t l) len
(fun i -> uint_from_bytes_be (sub b (i * numbytes t) (numbytes t)))
let index_uints_from_bytes_be #t #l #len b i = ()
let uint_at_index_le #t #l #len b i =
uint_from_bytes_le (sub b (i * numbytes t) (numbytes t))
let uint_at_index_be #t #l #len b i =
uint_from_bytes_be (sub b (i * numbytes t) (numbytes t))
#push-options "--max_fuel 1"
val nat_from_intseq_slice_lemma_aux: len:pos -> a:nat -> b:nat -> c:nat -> i:pos{i <= len} ->
Lemma (pow2 ((i - 1) * c) * (a + pow2 c * b) == pow2 ((i - 1) * c) * a + pow2 (i * c) * b)
let nat_from_intseq_slice_lemma_aux len a b c i =
FStar.Math.Lemmas.distributivity_add_right (pow2 ((i - 1) * c)) a (pow2 c * b);
FStar.Math.Lemmas.paren_mul_right (pow2 ((i - 1) * c)) (pow2 c) b;
FStar.Math.Lemmas.pow2_plus ((i - 1) * c) c
val nat_from_intseq_le_slice_lemma_:
#t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat
-> b:lseq (int_t t l) len
-> i:nat{i <= len} ->
Lemma (nat_from_intseq_le_ b == nat_from_intseq_le_ (slice b 0 i) + pow2 (i * bits t) * nat_from_intseq_le_ (slice b i len))
let rec nat_from_intseq_le_slice_lemma_ #t #l #len b i =
if len = 0 then ()
else begin
if i = 0 then ()
else begin
let b1 = slice b 0 i in
nat_from_intseq_le_slice_lemma_ #t #l #i b1 (i - 1);
assert (nat_from_intseq_le_ b1 == nat_from_intseq_le_ (slice b 0 (i - 1)) + pow2 ((i - 1) * bits t) * v b.[i - 1]);
nat_from_intseq_le_slice_lemma_ #t #l #len b (i - 1);
assert (nat_from_intseq_le_ b == nat_from_intseq_le_ (slice b 0 (i - 1)) + pow2 ((i - 1) * bits t) * nat_from_intseq_le_ (slice b (i - 1) len));
nat_from_intseq_slice_lemma_aux len (v b.[i - 1]) (nat_from_intseq_le_ (slice b i len)) (bits t) i
end
end
let nat_from_intseq_le_lemma0 #t #l b = ()
let nat_from_intseq_le_slice_lemma #t #l #len b i =
nat_from_intseq_le_slice_lemma_ b i
val nat_from_intseq_be_slice_lemma_:
#t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat
-> b:lseq (int_t t l) len
-> i:nat{i <= len} ->
Lemma (ensures (nat_from_intseq_be_ b == nat_from_intseq_be_ (slice b i len) + pow2 ((len - i) * bits t) * nat_from_intseq_be_ (slice b 0 i)))
(decreases (len - i))
let rec nat_from_intseq_be_slice_lemma_ #t #l #len b i =
if len = 0 then ()
else begin
if i = len then ()
else begin
let b1 = slice b i len in
nat_from_intseq_be_slice_lemma_ #t #l #(len - i) b1 1;
assert (nat_from_intseq_be_ b1 == nat_from_intseq_be_ (slice b (i + 1) len) + pow2 ((len - i - 1) * bits t) * v b.[i]);
nat_from_intseq_be_slice_lemma_ #t #l #len b (i + 1);
assert (nat_from_intseq_be_ b == nat_from_intseq_be_ (slice b (i + 1) len) + pow2 ((len - i - 1) * bits t) * nat_from_intseq_be_ (slice b 0 (i + 1)));
nat_from_intseq_slice_lemma_aux len (v b.[i]) (nat_from_intseq_be_ (slice b 0 i)) (bits t) (len - i)
end
end
let nat_from_intseq_be_lemma0 #t #l b = ()
#pop-options
let nat_from_intseq_be_slice_lemma #t #l #len b i =
nat_from_intseq_be_slice_lemma_ #t #l #len b i
val uints_from_bytes_le_slice_lemma_lp:
#t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) -> i:nat -> j:nat{i <= j /\ j <= len} -> k:nat{k < j - i} ->
Lemma (index (slice (uints_from_bytes_le #t #l #len b) i j) k ==
uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_le_slice_lemma_lp #t #l #len b i j k =
let r = slice (uints_from_bytes_le #t #l #len b) i j in
index_uints_from_bytes_le #t #l #len b (i + k);
assert (r.[k] == uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
val uints_from_bytes_le_slice_lemma_rp:
#t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) -> i:nat -> j:nat{i <= j /\ j <= len} -> k:nat{k < j - i} ->
Lemma (index (uints_from_bytes_le #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t))) k ==
uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_le_slice_lemma_rp #t #l #len b i j k =
let b1 = slice b (i * numbytes t) (j * numbytes t) in
let r = uints_from_bytes_le #t #l #(j-i) b1 in
index_uints_from_bytes_le #t #l #(j-i) b1 k;
assert (r.[k] == uint_from_bytes_le (sub b1 (k * numbytes t) (numbytes t)));
assert (r.[k] == uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_le_slice_lemma #t #l #len b i j =
FStar.Classical.forall_intro (uints_from_bytes_le_slice_lemma_lp #t #l #len b i j);
FStar.Classical.forall_intro (uints_from_bytes_le_slice_lemma_rp #t #l #len b i j);
eq_intro (slice (uints_from_bytes_le #t #l #len b) i j) (uints_from_bytes_le #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t)))
#push-options "--max_fuel 1"
val uints_from_bytes_le_nat_lemma_aux:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) ->
Lemma (nat_from_intseq_le_ (uints_from_bytes_le #t #l #len b) ==
nat_from_intseq_le_ (slice b 0 (numbytes t)) + pow2 (bits t) *
nat_from_intseq_le_ (uints_from_bytes_le #t #l #(len-1) (slice b (numbytes t) (len * numbytes t))))
let uints_from_bytes_le_nat_lemma_aux #t #l #len b =
let r = uints_from_bytes_le #t #l #len b in
assert (nat_from_intseq_le_ r == v r.[0] + pow2 (bits t) * nat_from_intseq_le_ (slice r 1 len));
assert (nat_from_intseq_le_ (slice b 0 (numbytes t)) == v r.[0]);
uints_from_bytes_le_slice_lemma #t #l #len b 1 len;
assert (slice r 1 len == uints_from_bytes_le #t #l #(len-1) (slice b (numbytes t) (len * numbytes t)))
val uints_from_bytes_le_nat_lemma_:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) ->
Lemma (nat_from_intseq_le_ (uints_from_bytes_le #t #l #len b) == nat_from_intseq_le_ b)
let rec uints_from_bytes_le_nat_lemma_ #t #l #len b =
if len = 0 then ()
else begin
let b1 = slice b (numbytes t) (len * numbytes t) in
nat_from_intseq_le_slice_lemma_ #U8 #l #(len * numbytes t) b (numbytes t);
assert (nat_from_intseq_le_ b == nat_from_intseq_le_ (slice b 0 (numbytes t)) + pow2 (bits t) * nat_from_intseq_le_ b1);
uints_from_bytes_le_nat_lemma_ #t #l #(len - 1) b1;
assert (nat_from_intseq_le_ (uints_from_bytes_le #t #l #(len - 1) b1) == nat_from_intseq_le_ b1);
uints_from_bytes_le_nat_lemma_aux #t #l #len b
end
let uints_from_bytes_le_nat_lemma #t #l #len b =
uints_from_bytes_le_nat_lemma_ #t #l #len b
val uints_from_bytes_be_slice_lemma_lp:
#t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) -> i:nat -> j:nat{i <= j /\ j <= len} -> k:nat{k < j - i} ->
Lemma (index (slice (uints_from_bytes_le #t #l #len b) i j) k ==
uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_be_slice_lemma_lp #t #l #len b i j k =
let r = slice (uints_from_bytes_le #t #l #len b) i j in
index_uints_from_bytes_be #t #l #len b (i + k);
assert (r.[k] == uint_from_bytes_le (sub b ((i + k) * numbytes t) (numbytes t)))
val uints_from_bytes_be_slice_lemma_rp:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t)
-> i:nat
-> j:nat{i <= j /\ j <= len}
-> k:nat{k < j - i} ->
Lemma (index (uints_from_bytes_be #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t))) k ==
uint_from_bytes_be (sub b ((i + k) * numbytes t) (numbytes t)))
let uints_from_bytes_be_slice_lemma_rp #t #l #len b i j k =
let b1 = slice b (i * numbytes t) (j * numbytes t) in
let r = uints_from_bytes_be #t #l #(j-i) b1 in
index_uints_from_bytes_be #t #l #(j-i) b1 k;
assert (r.[k] == uint_from_bytes_be (sub b1 (k * numbytes t) (numbytes t)));
assert (r.[k] == uint_from_bytes_be (sub b ((i + k) * numbytes t) (numbytes t)))
val uints_from_bytes_be_slice_lemma: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level -> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) -> i:nat -> j:nat{i <= j /\ j <= len} ->
Lemma (slice (uints_from_bytes_be #t #l #len b) i j == uints_from_bytes_be #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t)))
let uints_from_bytes_be_slice_lemma #t #l #len b i j =
FStar.Classical.forall_intro (uints_from_bytes_be_slice_lemma_lp #t #l #len b i j);
FStar.Classical.forall_intro (uints_from_bytes_be_slice_lemma_rp #t #l #len b i j);
eq_intro (slice (uints_from_bytes_be #t #l #len b) i j) (uints_from_bytes_be #t #l #(j-i) (slice b (i * numbytes t) (j * numbytes t)))
val uints_from_bytes_be_nat_lemma_aux:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_pos{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) ->
Lemma (nat_from_intseq_be_ (uints_from_bytes_be #t #l #len b) ==
nat_from_intseq_be (uints_from_bytes_be #t #l #(len-1) (slice b (numbytes t) (len * numbytes t))) + pow2 ((len - 1) * bits t) * nat_from_intseq_be_ (slice b 0 (numbytes t)))
let uints_from_bytes_be_nat_lemma_aux #t #l #len b =
let r = uints_from_bytes_be #t #l #len b in
uints_from_bytes_be_slice_lemma #t #l #len b 1 len;
nat_from_intseq_be_slice_lemma r 1;
assert (nat_from_intseq_be_ r == nat_from_intseq_be (slice r 1 len) + pow2 ((len - 1) * bits t) * uint_v r.[0])
val uints_from_bytes_be_nat_lemma_:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> b:lbytes_l l (len * numbytes t) ->
Lemma (nat_from_intseq_be_ (uints_from_bytes_be #t #l #len b) == nat_from_intseq_be_ b)
let rec uints_from_bytes_be_nat_lemma_ #t #l #len b =
if len = 0 then ()
else begin
uints_from_bytes_be_nat_lemma_aux #t #l #len b;
nat_from_intseq_be_slice_lemma_ b (numbytes t);
uints_from_bytes_be_nat_lemma_ #t #l #(len - 1) (slice b (numbytes t) (len * numbytes t))
end
let uints_from_bytes_be_nat_lemma #t #l #len b =
uints_from_bytes_be_nat_lemma_ #t #l #len b
#pop-options
val index_uints_to_bytes_le_aux:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma (let s:lseq (int_t t l) len = nat_to_intseq_le #t #l len n in
Seq.index (uints_to_bytes_le #t #l #len s) i ==
Seq.index (nat_to_bytes_le #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t))
let index_uints_to_bytes_le_aux #t #l len n i =
let open Lib.Sequence in
let s: lseq (int_t t l) len = nat_to_intseq_le #t #l len n in
index_generate_blocks (numbytes t) len len
(uints_to_bytes_le_inner #t #l #len s) i
val index_uints_to_bytes_be_aux:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma (let s:lseq (int_t t l) len = nat_to_intseq_be #t #l len n in
Seq.index (uints_to_bytes_be #t #l #len s) i ==
Seq.index (nat_to_bytes_be #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t))
let index_uints_to_bytes_be_aux #t #l len n i =
let open Lib.Sequence in
let s:lseq (int_t t l) len = nat_to_intseq_be #t #l len n in
index_generate_blocks (numbytes t) len len
(uints_to_bytes_be_inner #t #l #len s) i
val modulo_pow2_prop: r:pos -> a:nat -> b:nat -> c:nat{c < b} -> Lemma
((a % pow2 (r * b) / pow2 (r * c)) % pow2 r == (a / pow2 (r * c)) % pow2 r)
let modulo_pow2_prop r a b c =
calc (==) {
((a % pow2 (r * b)) / pow2 (r * c)) % pow2 r;
== { Math.Lemmas.pow2_modulo_division_lemma_1 a (r * c) (r * b) }
((a / pow2 (r * c) % pow2 (r * b - r * c))) % pow2 r;
== { Math.Lemmas.lemma_mul_sub_distr r b c }
((a / pow2 (r * c) % pow2 (r * (b - c)))) % pow2 r;
== { Math.Lemmas.pow2_plus r (r * (b - c) - r) }
(a / pow2 (r * c)) % (pow2 r * pow2 (r * (b - c) - r)) % pow2 r;
== { Math.Lemmas.modulo_modulo_lemma (a / pow2 (r * c)) (pow2 r) (pow2 (r * (b - c) - r))}
(a / pow2 (r * c)) % pow2 r;
}
val some_arithmetic: t:inttype{~(U1? t)} -> n:nat -> i:nat -> Lemma
(let m = numbytes t in
n / pow2 (bits t * (i / m)) % pow2 (bits t) / pow2 (8 * (i % m)) % pow2 8 ==
n / pow2 (8 * i) % pow2 8)
#push-options "--z3rlimit 150 --fuel 0 --ifuel 0"
let some_arithmetic t n i =
let m = numbytes t in
calc (==) {
n / pow2 (bits t * (i / m)) % pow2 (bits t) / pow2 (8 * (i % m)) % pow2 8;
== { assert (bits t == 8 * m) }
n / pow2 ((8 * m) * (i / m)) % pow2 (8 * m) / pow2 (8 * (i % m)) % pow2 8;
== { FStar.Math.Lemmas.paren_mul_right 8 m (i / m);
FStar.Math.Lemmas.euclidean_division_definition i m }
n / pow2 (8 * (i - i % m)) % pow2 (8 * m) / pow2 (8 * (i % m)) % pow2 8;
== { Math.Lemmas.distributivity_sub_right 8 i (i % m) }
n / pow2 (8 * i - 8 * (i % m)) % pow2 (8 * m) / pow2 (8 * (i % m)) % pow2 8;
== { modulo_pow2_prop 8 (n / pow2 (8 * i - 8 * (i % m))) m (i % m) }
(n / pow2 (8 * i - 8 * (i % m))) / pow2 (8 * (i % m)) % pow2 8;
== { Math.Lemmas.division_multiplication_lemma n
(pow2 (8 * i - 8 * (i % m))) (pow2 (8 * (i % m))) }
(n / (pow2 (8 * i - 8 * (i % m)) * pow2 (8 * (i % m)))) % pow2 8;
== { Math.Lemmas.pow2_plus (8 * i - 8 * (i % m)) (8 * (i % m)) }
(n / pow2 (8 * i)) % pow2 8;
}
#pop-options
val index_nat_to_intseq_to_bytes_le:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma (let s:lseq (int_t t l) len = nat_to_intseq_le #t #l len n in
Seq.index (nat_to_bytes_le #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t) ==
Seq.index (nat_to_bytes_le #l (len * numbytes t) n) i)
let index_nat_to_intseq_to_bytes_le #t #l len n i =
let s:lseq (int_t t l) len = nat_to_intseq_le #t #l len n in
let m = numbytes t in
index_nat_to_intseq_le #U8 #l (len * m) n i;
assert (Seq.index (nat_to_bytes_le #l (len * m) n) i ==
uint (n / pow2 (8 * i) % pow2 8));
index_nat_to_intseq_le #U8 #l m (v s.[i / m]) (i % m);
assert (Seq.index (nat_to_bytes_le #l m (v s.[i / m])) (i % m) ==
uint (v s.[i / m] / pow2 (8 * (i % m)) % pow2 8));
index_nat_to_intseq_le #t #l len n (i / m);
some_arithmetic t n i
val uints_to_bytes_le_nat_lemma_: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma
(Seq.index (uints_to_bytes_le #t #l #len (nat_to_intseq_le #t #l len n)) i ==
Seq.index (nat_to_bytes_le (len * numbytes t) n) i)
let uints_to_bytes_le_nat_lemma_ #t #l len n i =
let s:lseq (uint_t t l) len = nat_to_intseq_le #t #l len n in
calc (==) {
Seq.index (uints_to_bytes_le #t #l #len (nat_to_intseq_le #t #l len n)) i;
== { index_uints_to_bytes_le_aux #t #l len n i }
Seq.index (nat_to_bytes_le #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t);
== { index_nat_to_intseq_to_bytes_le #t #l len n i}
Seq.index (nat_to_bytes_le (len * numbytes t) n) i;
}
let uints_to_bytes_le_nat_lemma #t #l len n =
Classical.forall_intro (uints_to_bytes_le_nat_lemma_ #t #l len n);
eq_intro (uints_to_bytes_le #t #l #len (nat_to_intseq_le #t #l len n))
(nat_to_bytes_le (len * numbytes t) n)
val index_nat_to_intseq_to_bytes_be:
#t:inttype{unsigned t /\ ~(U1? t)}
-> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma (let s:lseq (int_t t l) len = nat_to_intseq_be #t #l len n in
Seq.index (nat_to_bytes_be #l (numbytes t) (v s.[len - 1 - i / numbytes t])) (numbytes t - 1 - i % numbytes t) ==
Seq.index (nat_to_bytes_be #l (len * numbytes t) n) (len * numbytes t - i - 1))
let index_nat_to_intseq_to_bytes_be #t #l len n i =
let s:lseq (uint_t t l) len = nat_to_intseq_be #t #l len n in
let m = numbytes t in
calc (==) {
Seq.index (nat_to_bytes_be #l m (v s.[len - 1 - i / m])) (m - (i % m) - 1);
== { index_nat_to_intseq_be #U8 #l m (v s.[len - 1 - i / m]) (i % m) }
uint (v s.[len - 1 - i / m] / pow2 (8 * (i % m)) % pow2 8);
== { index_nat_to_intseq_be #t #l len n (i / m) }
uint ((n / pow2 (bits t * (i / m)) % pow2 (bits t)) / pow2 (8 * (i % m)) % pow2 8);
== { some_arithmetic t n i }
uint (n / pow2 (8 * i) % pow2 8);
== { index_nat_to_intseq_be #U8 #l (len * m) n i }
Seq.index (nat_to_bytes_be #l (len * m) n) (len * m - 1 - i);
}
val uints_to_bytes_be_nat_lemma_: #t:inttype{unsigned t /\ ~(U1? t)} -> #l:secrecy_level
-> len:nat{len * numbytes t < pow2 32}
-> n:nat{n < pow2 (bits t * len)}
-> i:nat{i < len * numbytes t}
-> Lemma
(Seq.index (uints_to_bytes_be #t #l #len (nat_to_intseq_be #t #l len n)) i ==
Seq.index (nat_to_bytes_be (len * numbytes t) n) i)
let uints_to_bytes_be_nat_lemma_ #t #l len n i =
let s:lseq (uint_t t l) len = nat_to_intseq_be #t #l len n in
calc (==) {
Seq.index (uints_to_bytes_be #t #l #len (nat_to_intseq_be #t #l len n)) i;
== { index_uints_to_bytes_be_aux #t #l len n i }
Seq.index (nat_to_bytes_be #l (numbytes t) (v s.[i / numbytes t])) (i % numbytes t);
== { index_nat_to_intseq_to_bytes_be #t #l len n (len * numbytes t - 1 - i)}
Seq.index (nat_to_bytes_be (len * numbytes t) n) i;
}
let uints_to_bytes_be_nat_lemma #t #l len n =
Classical.forall_intro (uints_to_bytes_be_nat_lemma_ #t #l len n);
eq_intro (uints_to_bytes_be #t #l #len (nat_to_intseq_be #t #l len n))
(nat_to_bytes_be (len * numbytes t) n)
#push-options "--max_fuel 1"
let rec nat_from_intseq_le_inj #t #l b1 b2 =
if length b1 = 0 then ()
else begin
nat_from_intseq_le_inj (Seq.slice b1 1 (length b1)) (Seq.slice b2 1 (length b2));
Seq.lemma_split b1 1;
Seq.lemma_split b2 1
end
let rec nat_from_intseq_be_inj #t #l b1 b2 =
if length b1 = 0 then ()
else begin
nat_from_intseq_be_inj (Seq.slice b1 0 (length b1 - 1)) (Seq.slice b2 0 (length b2 - 1));
Seq.lemma_split b1 (length b1 - 1);
Seq.lemma_split b2 (length b2 - 1)
end
let lemma_nat_to_from_bytes_be_preserves_value #l b len x = ()
let lemma_nat_to_from_bytes_le_preserves_value #l b len x = ()
let lemma_uint_to_bytes_le_preserves_value #t #l x = ()
let lemma_uint_to_bytes_be_preserves_value #t #l x = ()
let lemma_nat_from_to_intseq_le_preserves_value #t #l len b =
nat_from_intseq_le_inj (nat_to_intseq_le len (nat_from_intseq_le b)) b | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_nat_from_to_intseq_be_preserves_value: #t:inttype{unsigned t} -> #l:secrecy_level -> len:nat -> b:seq (uint_t t l){length b == len} ->
Lemma (nat_to_intseq_be len (nat_from_intseq_be b) == b) | [] | Lib.ByteSequence.lemma_nat_from_to_intseq_be_preserves_value | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Prims.nat -> b: Lib.Sequence.seq (Lib.IntTypes.uint_t t l) {Lib.Sequence.length b == len}
-> FStar.Pervasives.Lemma
(ensures Lib.ByteSequence.nat_to_intseq_be len (Lib.ByteSequence.nat_from_intseq_be b) == b) | {
"end_col": 72,
"end_line": 750,
"start_col": 2,
"start_line": 750
} |
Prims.Tot | val uints_to_bytes_le: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (uint_t t l) len -> lbytes_l l (len * numbytes t) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"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": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uints_to_bytes_le #t #l #len ul =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(uints_to_bytes_le_inner #t #l #len ul) () in
o | val uints_to_bytes_le: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (uint_t t l) len -> lbytes_l l (len * numbytes t)
let uints_to_bytes_le #t #l #len ul = | false | null | false | let a_spec (i: nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec (uints_to_bytes_le_inner #t #l #len ul) () in
o | {
"checked_file": "Lib.ByteSequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.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.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.ByteSequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntTypes.secrecy_level",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Prims.pow2",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint_t",
"Lib.Sequence.seq",
"Lib.IntTypes.U8",
"Prims.eq2",
"Prims.int",
"Lib.Sequence.length",
"Lib.ByteSequence.lbytes_l",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Prims.op_Multiply",
"Lib.Sequence.generate_blocks",
"Lib.ByteSequence.uints_to_bytes_le_inner",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.eqtype",
"Prims.unit"
] | [] | module Lib.ByteSequence
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.RawIntTypes
open Lib.LoopCombinators
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0"
/// BEGIN constant-time sequence equality
val lemma_not_equal_slice: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat -> j:nat ->
k:nat{i <= j /\ i <= k /\ j <= k /\ k <= Seq.length b1 /\ k <= Seq.length b2 } ->
Lemma
(requires ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
(ensures ~(Seq.equal (Seq.slice b1 i k) (Seq.slice b2 i k)))
let lemma_not_equal_slice #a b1 b2 i j k =
assert (forall (n:nat{n < k - i}). Seq.index (Seq.slice b1 i k) n == Seq.index b1 (n + i))
val lemma_not_equal_last: #a:Type -> b1:Seq.seq a -> b2:Seq.seq a -> i:nat ->
j:nat{i < j /\ j <= Seq.length b1 /\ j <= Seq.length b2} ->
Lemma
(requires ~(Seq.index b1 (j - 1) == Seq.index b2 (j - 1)))
(ensures ~(Seq.equal (Seq.slice b1 i j) (Seq.slice b2 i j)))
let lemma_not_equal_last #a b1 b2 i j =
Seq.lemma_index_slice b1 i j (j - i - 1);
Seq.lemma_index_slice b2 i j (j - i - 1)
val seq_eq_mask_inner: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat
-> b1:lseq (int_t t SEC) len1
-> b2:lseq (int_t t SEC) len2
-> len:size_nat{len <= len1 /\ len <= len2}
-> i:size_nat{i < len}
-> res:int_t t SEC{
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC))}
-> res':int_t t SEC{
(sub b1 0 (i + 1) == sub b2 0 (i + 1) ==> v res' == v (ones t SEC)) /\
(sub b1 0 (i + 1) =!= sub b2 0 (i + 1) ==> v res' == v (zeros t SEC))}
let seq_eq_mask_inner #t #len1 #len2 b1 b2 len i res =
logand_zeros (ones t SEC);
logand_ones (ones t SEC);
logand_zeros (zeros t SEC);
logand_ones (zeros t SEC);
let z0 = res in
let res = eq_mask b1.[i] b2.[i] &. z0 in
logand_spec (eq_mask b1.[i] b2.[i]) z0;
if v res = ones_v t then
begin
let s1 = sub b1 0 (i + 1) in
let s2 = sub b2 0 (i + 1) in
Seq.lemma_split s1 i;
Seq.lemma_split s2 i;
assert (equal s1 s2)
end
else if v z0 = 0 then
lemma_not_equal_slice b1 b2 0 i (i + 1)
else
lemma_not_equal_last b1 b2 0 (i + 1);
res
let seq_eq_mask #t #len1 #len2 b1 b2 len =
repeati_inductive len
(fun (i:nat{i <= len}) res ->
(sub b1 0 i == sub b2 0 i ==> v res == v (ones t SEC)) /\
(sub b1 0 i =!= sub b2 0 i ==> v res == v (zeros t SEC)))
(seq_eq_mask_inner b1 b2 len)
(ones t SEC)
let lbytes_eq #len b1 b2 =
let res = seq_eq_mask b1 b2 len in
RawIntTypes.u8_to_UInt8 res = 255uy
/// END constant-time sequence equality
let mask_select #t mask a b =
b ^. (mask &. (a ^. b))
let mask_select_lemma #t mask a b =
let t1 = mask &. (a ^. b) in
let t2 = b ^. t1 in
logand_lemma mask (a ^.b);
if v mask = 0 then begin
assert (v t1 == 0);
logxor_lemma b t1;
assert (v t2 = v b);
() end
else begin
assert (v t1 == v (a ^. b));
logxor_lemma b a;
assert (v t2 = v a);
() end
let seq_mask_select #t #len a b mask =
let res = map2 (mask_select mask) a b in
let lemma_aux (i:nat{i < len}) : Lemma (v res.[i] == (if v mask = 0 then v b.[i] else v a.[i])) =
mask_select_lemma mask a.[i] b.[i] in
Classical.forall_intro lemma_aux;
if v mask = 0 then eq_intro res b else eq_intro res a;
res
val nat_from_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_be_ #t #l b =
let len = length b in
if len = 0 then 0
else
let l = v (Seq.index b (len - 1)) in
let pre = Seq.slice b 0 (len - 1) in
let shift = pow2 (bits t) in
let n' = nat_from_intseq_be_ pre in
Math.Lemmas.pow2_plus (bits t) (len * bits t - bits t);
l + shift * n'
let nat_from_intseq_be = nat_from_intseq_be_
val nat_from_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> b:seq (uint_t t l)
-> Tot (n:nat{n < pow2 (length b * bits t)}) (decreases (length b))
let rec nat_from_intseq_le_ #t #l b =
let len = length b in
if len = 0 then 0
else
let shift = pow2 (bits t) in
let tt = Seq.slice b 1 len in
let n' = nat_from_intseq_le_ #t #l tt in
let l = v (Seq.index b 0) in
Math.Lemmas.pow2_plus (bits t) ( len * bits t - bits t);
let n = l + shift * n' in
n
let nat_from_intseq_le = nat_from_intseq_le_
#set-options "--max_fuel 1"
val nat_to_intseq_be_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (int_t t l){length b == len /\ n == nat_from_intseq_be b}) (decreases len)
let rec nat_to_intseq_be_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_be_ len' n' in
let b = Seq.append b' (create 1 tt) in
Seq.append_slices b' (create 1 tt);
b
let nat_to_intseq_be = nat_to_intseq_be_
val nat_to_intseq_le_:
#t:inttype{unsigned t} -> #l:secrecy_level
-> len:nat
-> n:nat{n < pow2 (bits t * len)}
-> Tot (b:seq (uint_t t l){length b == len /\ n == nat_from_intseq_le b}) (decreases len)
let rec nat_to_intseq_le_ #t #l len n =
if len = 0 then Seq.empty
else
let len' = len - 1 in
let tt = uint #t #l (n % modulus t) in
let n' = n / modulus t in
assert (modulus t = pow2 (bits t));
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
let b' = nat_to_intseq_le_ len' n' in
let b = Seq.append (create 1 tt) b' in
Seq.append_slices (create 1 tt) b';
b
let nat_to_intseq_le = nat_to_intseq_le_
/// These lemmas allow to unfold the definition of nat_to_intseq_{b}e without using
/// fuel > 0 below, which makes the proof more expensive
val head_nat_to_intseq_le:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_le #t #l len n) 0 ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_le #t #l len n = ()
val nat_to_intseq_le_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_le #t #l len n ==
Seq.append (create 1 (uint #t #l (n % modulus t)))
(nat_to_intseq_le (len - 1) (n / modulus t)))
let nat_to_intseq_le_pos #t #l len n = ()
val head_nat_to_intseq_be:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (Seq.index (nat_to_intseq_be #t #l len n) (len - 1) ==
uint #t #l (n % pow2 (bits t)))
let head_nat_to_intseq_be #t #l len n = ()
val nat_to_intseq_be_pos:
#t:inttype{unsigned t}
-> #l:secrecy_level
-> len:size_pos
-> n:nat{n < pow2 (bits t * len)}
-> Lemma (nat_to_intseq_be #t #l len n ==
Seq.append (nat_to_intseq_be (len - 1) (n / modulus t))
(create 1 (uint #t #l (n % modulus t))))
let nat_to_intseq_be_pos #t #l len n = ()
#push-options "--fuel 0 --ifuel 0"
let rec index_nat_to_intseq_le #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_le #t #l len n
else
begin
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_le #t #l (len - 1) (n / modulus t)) (i - 1);
== { index_nat_to_intseq_le #t #l (len - 1) (n / modulus t) (i - 1) }
uint ((n / modulus t) / pow2 (bits t * (i - 1)) % modulus t);
== { Math.Lemmas.division_multiplication_lemma n (modulus t) (pow2 (bits t * (i - 1))) }
uint ((n / (pow2 (bits t) * pow2 (bits t * (i - 1)))) % modulus t);
== { Math.Lemmas.pow2_plus (bits t) (bits t * (i - 1)) }
uint ((n / pow2 (bits t + bits t * (i - 1))) % modulus t);
== { Math.Lemmas.distributivity_add_right (bits t) i (-1) }
uint (n / pow2 (bits t + (bits t * i - bits t)) % modulus t);
== { }
uint (n / pow2 (bits t * i) % pow2 (bits t));
};
nat_to_intseq_le_pos #t #l len n
end
let rec index_nat_to_intseq_be #t #l len n i =
if i = 0 then
if len = 0 then () else head_nat_to_intseq_be #t #l len n
else
begin
let len' = len - 1 in
let i' = i - 1 in
let n' = n / pow2 (bits t) in
FStar.Math.Lemmas.lemma_div_lt_nat n (bits t * len) (bits t);
calc (==) {
Seq.index (nat_to_intseq_be #t #l len' n') (len' - i' - 1);
== {index_nat_to_intseq_be #t #l len' n' i'}
uint (n' / pow2 (bits t * i') % pow2 (bits t));
== {}
uint (n / pow2 (bits t) / pow2 (bits t * i') % pow2 (bits t));
== {Math.Lemmas.division_multiplication_lemma n (pow2 (bits t)) (pow2 (bits t * i'))}
uint (n / (pow2 (bits t) * pow2 (bits t * i')) % pow2 (bits t));
== {Math.Lemmas.pow2_plus (bits t) (bits t * i')}
uint (n / (pow2 (bits t + bits t * i')) % pow2 (bits t));
== {Math.Lemmas.distributivity_add_right (bits t) 1 (i - 1)}
uint (n / (pow2 (bits t * i)) % pow2 (bits t));
};
nat_to_intseq_be_pos #t #l len n
end
let uint_to_bytes_le #t #l n =
nat_to_bytes_le (numbytes t) (v n)
let index_uint_to_bytes_le #t #l u =
Classical.forall_intro (index_nat_to_intseq_le #U8 #l (numbytes t) (v u))
let uint_to_bytes_be #t #l n =
nat_to_bytes_be (numbytes t) (v n)
let index_uint_to_bytes_be #t #l u =
Classical.forall_intro (index_nat_to_intseq_be #U8 #l (numbytes t) (v u))
let uint_from_bytes_le #t #l b =
let n = nat_from_intseq_le #U8 b in
uint #t #l n
let uint_from_bytes_be #t #l b =
let n = nat_from_intseq_be #U8 b in
uint #t #l n
val uints_to_bytes_le_inner: #t:inttype{unsigned t} -> #l:secrecy_level
-> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (int_t t l) len
-> i:nat{i < len} -> unit -> unit & (lseq (uint_t U8 l) (numbytes t))
let uints_to_bytes_le_inner #t #l #len b i () =
let open Lib.Sequence in
(), uint_to_bytes_le #t #l b.[i] | false | false | Lib.ByteSequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uints_to_bytes_le: #t:inttype{unsigned t} -> #l:secrecy_level -> #len:size_nat{len * numbytes t < pow2 32}
-> lseq (uint_t t l) len -> lbytes_l l (len * numbytes t) | [] | Lib.ByteSequence.uints_to_bytes_le | {
"file_name": "lib/Lib.ByteSequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ul: Lib.Sequence.lseq (Lib.IntTypes.uint_t t l) len
-> Lib.ByteSequence.lbytes_l l (len * Lib.IntTypes.numbytes t) | {
"end_col": 3,
"end_line": 313,
"start_col": 37,
"start_line": 309
} |
Subsets and Splits