file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.balance | val balance (#a: eqtype) (#b: Type) (t: tree a b) : tree a b | val balance (#a: eqtype) (#b: Type) (t: tree a b) : tree a b | let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 10,
"end_line": 39,
"start_col": 0,
"start_line": 31
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.Lib.MapTree.tree a b -> Vale.Lib.MapTree.tree a b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.tree",
"Prims.nat",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Addition",
"Vale.Lib.MapTree.rotate_r",
"Prims.bool",
"Vale.Lib.MapTree.rotate_l",
"Vale.Lib.MapTree.height"
] | [] | false | false | false | false | false | let balance (#a: eqtype) (#b: Type) (t: tree a b) : tree a b =
| match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else if hr >= hl + 2 then rotate_l t else t
| _ -> t | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.rotate_l | val rotate_l (#a: eqtype) (#b: Type) (t: tree a b) : tree a b | val rotate_l (#a: eqtype) (#b: Type) (t: tree a b) : tree a b | let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 10,
"end_line": 24,
"start_col": 0,
"start_line": 21
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.Lib.MapTree.tree a b -> Vale.Lib.MapTree.tree a b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.tree",
"Prims.nat",
"Vale.Lib.MapTree.mkNode"
] | [] | false | false | false | false | false | let rotate_l (#a: eqtype) (#b: Type) (t: tree a b) : tree a b =
| match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.tuint64 | val tuint64 : Vale.Interop.Base.td | let tuint64 = TD_Base TUInt64 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 44,
"start_col": 0,
"start_line": 44
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public}) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.Interop.Base.td | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.TD_Base",
"Vale.Arch.HeapTypes_s.TUInt64"
] | [] | false | false | false | true | false | let tuint64 =
| TD_Base TUInt64 | false |
|
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.serialize_bounded_vlgenbytes | val serialize_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong})
: Tot (serializer (parse_bounded_vlgenbytes min max pk)) | val serialize_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong})
: Tot (serializer (parse_bounded_vlgenbytes min max pk)) | let serialize_bounded_vlgenbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong })
: Tot (serializer (parse_bounded_vlgenbytes min max pk))
= serialize_synth
(parse_bounded_vlgen min max pk serialize_all_bytes)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlgen min max sk serialize_all_bytes)
(synth_bounded_vlbytes_recip min max)
() | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 297,
"start_col": 0,
"start_line": 285
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options
let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes
inline_for_extraction
let synth_bounded_vlbytes_recip
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
= x
let serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes' min max l))
= serialize_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
let serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (serializer (parse_bounded_vlbytes min max))
= serialize_bounded_vlbytes' min max (log256' max)
let length_serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes' min max l) x) == l + B32.length x)
= serialize_synth_eq
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
x
let length_serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes min max) x) == log256' max + B32.length x)
= length_serialize_bounded_vlbytes' min max (log256' max) x
let parse_bounded_vlgenbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(#sk: parser_kind)
(pk: parser sk (bounded_int32 min max))
: Tot (parser (parse_bounded_vlgen_kind sk min max parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlgen min max pk serialize_all_bytes `parse_synth` synth_bounded_vlbytes min max | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} ->
sk:
LowParse.Spec.Base.serializer pk
{ Mkparser_kind'?.parser_kind_subkind kk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong }
-> LowParse.Spec.Base.serializer (LowParse.Spec.Bytes.parse_bounded_vlgenbytes min max pk) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.serializer",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.Spec.Combinators.serialize_synth",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"LowParse.Spec.Bytes.synth_bounded_vlbytes",
"LowParse.Spec.VLGen.serialize_bounded_vlgen",
"LowParse.Spec.Bytes.synth_bounded_vlbytes_recip",
"LowParse.Spec.Bytes.parse_bounded_vlgenbytes"
] | [] | false | false | false | false | false | let serialize_bounded_vlgenbytes
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong})
: Tot (serializer (parse_bounded_vlgenbytes min max pk)) =
| serialize_synth (parse_bounded_vlgen min max pk serialize_all_bytes)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlgen min max sk serialize_all_bytes)
(synth_bounded_vlbytes_recip min max)
() | false |
ElGamal.fst | ElGamal.bij' | val bij' : m: ElGamal.Group.group -> FStar.DM4F.Random.bijection | let bij' (m:group) =
let f = fun h -> upd h (to_id 0) ((sel h (to_id 0) - log m) % q) in
let finv = fun h -> upd h (to_id 0) ((sel h (to_id 0) + log m) % q) in
Bijection f finv | {
"file_name": "examples/rel/ElGamal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 26,
"start_col": 0,
"start_line": 23
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module ElGamal
open FStar.DM4F.Heap.Random
open FStar.DM4F.Random
open ElGamal.Group | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.Random.fst.checked",
"FStar.DM4F.Heap.Random.fsti.checked",
"ElGamal.Group.fst.checked"
],
"interface_file": false,
"source_file": "ElGamal.fst"
} | [
{
"abbrev": false,
"full_module": "ElGamal.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: ElGamal.Group.group -> FStar.DM4F.Random.bijection | Prims.Tot | [
"total"
] | [] | [
"ElGamal.Group.group",
"FStar.DM4F.Random.Bijection",
"FStar.DM4F.Heap.Random.tape",
"FStar.DM4F.Heap.Random.upd",
"FStar.DM4F.Heap.Random.to_id",
"Prims.op_Modulus",
"Prims.op_Addition",
"FStar.DM4F.Heap.Random.sel",
"ElGamal.Group.log",
"FStar.DM4F.Heap.Random.q",
"Prims.op_Subtraction",
"FStar.DM4F.Random.bijection"
] | [] | false | false | false | true | false | let bij' (m: group) =
| let f = fun h -> upd h (to_id 0) ((sel h (to_id 0) - log m) % q) in
let finv = fun h -> upd h (to_id 0) ((sel h (to_id 0) + log m) % q) in
Bijection f finv | false |
|
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.length_serialize_bounded_vlbytes' | val length_serialize_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
(x: parse_bounded_vlbytes_t min max)
: Lemma (Seq.length (serialize (serialize_bounded_vlbytes' min max l) x) == l + B32.length x) | val length_serialize_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
(x: parse_bounded_vlbytes_t min max)
: Lemma (Seq.length (serialize (serialize_bounded_vlbytes' min max l) x) == l + B32.length x) | let length_serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(x: parse_bounded_vlbytes_t min max)
: Lemma
(Seq.length (serialize (serialize_bounded_vlbytes' min max l) x) == l + B32.length x)
= serialize_synth_eq
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
x | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 267,
"start_col": 0,
"start_line": 254
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16"
let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz)
#reset-options
let serialize_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes_aux min max l))
= serialize_bounded_vldata_strong' min max l serialize_all_bytes
inline_for_extraction
let synth_bounded_vlbytes_recip
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vlbytes_t min max)
: Tot (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
= x
let serialize_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (serializer (parse_bounded_vlbytes' min max l))
= serialize_synth
(parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
let serialize_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (serializer (parse_bounded_vlbytes min max))
= serialize_bounded_vlbytes' min max (log256' max) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} ->
l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} ->
x: LowParse.Spec.Bytes.parse_bounded_vlbytes_t min max
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.length (LowParse.Spec.Base.serialize (LowParse.Spec.Bytes.serialize_bounded_vlbytes'
min
max
l)
x) ==
l + FStar.Bytes.length x) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.Combinators.serialize_synth_eq",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_aux",
"LowParse.Spec.Bytes.synth_bounded_vlbytes",
"LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux",
"LowParse.Spec.Bytes.synth_bounded_vlbytes_recip",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.Bytes.parse_bounded_vlbytes'",
"LowParse.Spec.Bytes.serialize_bounded_vlbytes'",
"Prims.op_Addition",
"FStar.Bytes.length",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let length_serialize_bounded_vlbytes'
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
(x: parse_bounded_vlbytes_t min max)
: Lemma (Seq.length (serialize (serialize_bounded_vlbytes' min max l) x) == l + B32.length x) =
| serialize_synth_eq (parse_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes min max)
(serialize_bounded_vlbytes_aux min max l)
(synth_bounded_vlbytes_recip min max)
()
x | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.mkNode | val mkNode (#a: eqtype) (#b: Type) (key: a) (value: b) (l r: tree a b) : tree a b | val mkNode (#a: eqtype) (#b: Type) (key: a) (value: b) (l r: tree a b) : tree a b | let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 19,
"start_col": 0,
"start_line": 15
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | key: a -> value: b -> l: Vale.Lib.MapTree.tree a b -> r: Vale.Lib.MapTree.tree a b
-> Vale.Lib.MapTree.tree a b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.tree",
"Vale.Lib.MapTree.Node",
"Prims.op_Addition",
"Prims.int",
"Prims.op_GreaterThan",
"Prims.bool",
"Prims.nat",
"Vale.Lib.MapTree.height"
] | [] | false | false | false | false | false | let mkNode (#a: eqtype) (#b: Type) (key: a) (value: b) (l r: tree a b) : tree a b =
| let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.is_lt_option | val is_lt_option (#a: eqtype) (is_le: (a -> a -> bool)) (x y: option a) : bool | val is_lt_option (#a: eqtype) (is_le: (a -> a -> bool)) (x y: option a) : bool | let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 66,
"start_col": 0,
"start_line": 63
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
is_le: (_: a -> _: a -> Prims.bool) ->
x: FStar.Pervasives.Native.option a ->
y: FStar.Pervasives.Native.option a
-> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.bool",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_AmpAmp",
"Prims.op_disEquality",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | false | false | let is_lt_option (#a: eqtype) (is_le: (a -> a -> bool)) (x y: option a) : bool =
| match (x, y) with
| Some x, Some y -> is_le x y && x <> y
| _ -> true | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.map | val map (a:eqtype) (b:Type u#a) : Type u#a | val map (a:eqtype) (b:Type u#a) : Type u#a | let map = map' | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 144,
"start_col": 0,
"start_line": 144
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
#push-options "--max_fuel 2 --max_ifuel 1"
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi
let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma
(requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_self is_le l key value lo (Some k)
else
lemma_get_put_self is_le r key value (Some k) hi
let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\
key =!= kx
)
(ensures get is_le (put is_le t key value) kx == get is_le t kx)
=
lemma_put_inv is_le t key value lo hi;
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_other is_le l key kx value lo (Some k)
else
lemma_get_put_other is_le r key kx value (Some k) hi
#pop-options
(** Map interface *)
#push-options "--max_fuel 1 --max_ifuel 2"
noeq
type map' (a:eqtype) b =
| Map :
is_le:(a -> a -> bool) ->
t:tree a b ->
default_v:b ->
invs:squash (is_cmp is_le /\ inv is_le t None None) ->
map' a b
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Prims.eqtype -> b: Type -> Type | Prims.Tot | [
"total"
] | [] | [
"Vale.Lib.MapTree.map'"
] | [] | false | false | false | true | true | let map =
| map' | false |
ElGamal.fst | ElGamal.elgamal_equiv | val elgamal_equiv (m c: group)
: Lemma
(let f1 h = reify (elgamal m) h in
let f2 h = reify (elgamal' m) h in
mass f1 (point c) == mass f2 (point c)) | val elgamal_equiv (m c: group)
: Lemma
(let f1 h = reify (elgamal m) h in
let f2 h = reify (elgamal' m) h in
mass f1 (point c) == mass f2 (point c)) | let elgamal_equiv (m c:group)
: Lemma
(let f1 h = reify (elgamal m) h in
let f2 h = reify (elgamal' m) h in
mass f1 (point c) == mass f2 (point c))
= let f1 h = reify (elgamal m) h in
let f2 h = reify (elgamal' m) h in
pr_eq f1 f2 (point c) (point c) (bij' m) | {
"file_name": "examples/rel/ElGamal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 64,
"start_col": 0,
"start_line": 57
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module ElGamal
open FStar.DM4F.Heap.Random
open FStar.DM4F.Random
open ElGamal.Group
let bij' (m:group) =
let f = fun h -> upd h (to_id 0) ((sel h (to_id 0) - log m) % q) in
let finv = fun h -> upd h (to_id 0) ((sel h (to_id 0) + log m) % q) in
Bijection f finv
let elgamal (m:group)
: Rand group
= let z = sample () in
g^z
let elgamal' (m:group) : Rand group =
let z = sample () in
(g^z) * m
let elgamal_prop (m:group) (z:elem)
: Lemma
(ensures (g^((z - log m) %q)) * m == g^z)
[SMTPat ((g^(z - log m) % q) * m) ]
= pow_log m;
mul_pow ((z - log m) % q) (log m);
mod_minus_plus z (log m)
(*
g^((z - log m) % q) * m
== [pow_log m]
g^((z - log m) % q) * g^(log m)
== [mul_pow ((z - log m) % q) (log m)]
g^(((z - log m) % q + log m) % Q)
== [mod_minus_plus z (log m)]
g^z
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.Random.fst.checked",
"FStar.DM4F.Heap.Random.fsti.checked",
"ElGamal.Group.fst.checked"
],
"interface_file": false,
"source_file": "ElGamal.fst"
} | [
{
"abbrev": false,
"full_module": "ElGamal.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: ElGamal.Group.group -> c: ElGamal.Group.group
-> FStar.Pervasives.Lemma
(ensures
(let f1 h = reify (ElGamal.elgamal m) h in
let f2 h = reify (ElGamal.elgamal' m) h in
FStar.DM4F.Random.mass f1 (FStar.DM4F.Random.point c) ==
FStar.DM4F.Random.mass f2 (FStar.DM4F.Random.point c))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"ElGamal.Group.group",
"FStar.DM4F.Random.pr_eq",
"FStar.Pervasives.Native.option",
"FStar.DM4F.Random.point",
"ElGamal.bij'",
"FStar.Pervasives.Native.tuple2",
"FStar.DM4F.Heap.Random.id",
"FStar.DM4F.Heap.Random.tape",
"ElGamal.elgamal'",
"ElGamal.elgamal",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.nat",
"FStar.DM4F.Random.mass",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let elgamal_equiv (m c: group)
: Lemma
(let f1 h = reify (elgamal m) h in
let f2 h = reify (elgamal' m) h in
mass f1 (point c) == mass f2 (point c)) =
| let f1 h = reify (elgamal m) h in
let f2 h = reify (elgamal' m) h in
pr_eq f1 f2 (point c) (point c) (bij' m) | false |
ElGamal.fst | ElGamal.elgamal_prop | val elgamal_prop (m: group) (z: elem)
: Lemma (ensures (g ^ ((z - log m) % q)) * m == g ^ z) [SMTPat ((g ^ (z - log m) % q) * m)] | val elgamal_prop (m: group) (z: elem)
: Lemma (ensures (g ^ ((z - log m) % q)) * m == g ^ z) [SMTPat ((g ^ (z - log m) % q) * m)] | let elgamal_prop (m:group) (z:elem)
: Lemma
(ensures (g^((z - log m) %q)) * m == g^z)
[SMTPat ((g^(z - log m) % q) * m) ]
= pow_log m;
mul_pow ((z - log m) % q) (log m);
mod_minus_plus z (log m) | {
"file_name": "examples/rel/ElGamal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 44,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module ElGamal
open FStar.DM4F.Heap.Random
open FStar.DM4F.Random
open ElGamal.Group
let bij' (m:group) =
let f = fun h -> upd h (to_id 0) ((sel h (to_id 0) - log m) % q) in
let finv = fun h -> upd h (to_id 0) ((sel h (to_id 0) + log m) % q) in
Bijection f finv
let elgamal (m:group)
: Rand group
= let z = sample () in
g^z
let elgamal' (m:group) : Rand group =
let z = sample () in
(g^z) * m | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.Random.fst.checked",
"FStar.DM4F.Heap.Random.fsti.checked",
"ElGamal.Group.fst.checked"
],
"interface_file": false,
"source_file": "ElGamal.fst"
} | [
{
"abbrev": false,
"full_module": "ElGamal.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: ElGamal.Group.group -> z: FStar.DM4F.Heap.Random.elem
-> FStar.Pervasives.Lemma
(ensures
(ElGamal.Group.g ^ (z - ElGamal.Group.log m) % FStar.DM4F.Heap.Random.q) * m ==
ElGamal.Group.g ^ z)
[SMTPat ((ElGamal.Group.g ^ (z - ElGamal.Group.log m) % FStar.DM4F.Heap.Random.q) * m)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"ElGamal.Group.group",
"FStar.DM4F.Heap.Random.elem",
"ElGamal.Group.mod_minus_plus",
"ElGamal.Group.log",
"Prims.unit",
"ElGamal.Group.mul_pow",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"FStar.DM4F.Heap.Random.q",
"ElGamal.Group.pow_log",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"ElGamal.Group.op_Star",
"ElGamal.Group.op_Hat",
"ElGamal.Group.g",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | true | false | true | false | false | let elgamal_prop (m: group) (z: elem)
: Lemma (ensures (g ^ ((z - log m) % q)) * m == g ^ z) [SMTPat ((g ^ (z - log m) % q) * m)] =
| pow_log m;
mul_pow ((z - log m) % q) (log m);
mod_minus_plus z (log m) | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.code_poly | val code_poly : Vale.X64.Decls.va_code | let code_poly = PO.va_code_Poly1305 IA.win | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 111,
"start_col": 0,
"start_line": 111
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64; tuint64] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state) ->
PO.va_req_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_post : VSig.vale_post dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
PO.va_ens_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
va_s1 f
module VS = Vale.X64.State
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let poly_lemma'
(code:V.va_code)
(_win:bool)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
poly_pre code ctx_b inp_b len finish va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
poly_post code ctx_b inp_b len finish va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer ctx_b) /\
ME.buffer_writeable (as_vale_buffer inp_b)
)) =
let va_s1, f = PO.va_lemma_Poly1305 code va_s0 IA.win (as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 ctx_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 inp_b;
va_s1, f
(* Prove that poly_lemma' has the required type *)
noextract
let poly_lemma = as_t #(VSig.vale_sig_stdcall poly_pre poly_post) poly_lemma' | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.X64.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.Poly1305.X64.va_code_Poly1305",
"Vale.Interop.Assumptions.win"
] | [] | false | false | false | true | false | let code_poly =
| PO.va_code_Poly1305 IA.win | false |
|
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.get | val get (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) : option b | val get (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) : option b | let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 49,
"start_col": 0,
"start_line": 41
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> key: a
-> FStar.Pervasives.Native.option b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"FStar.Pervasives.Native.None",
"Prims.nat",
"Prims.op_Equality",
"FStar.Pervasives.Native.Some",
"Vale.Lib.MapTree.get",
"FStar.Pervasives.Native.option"
] | [
"recursion"
] | false | false | false | false | false | let rec get (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) : option b =
| match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v else if is_le key k then get is_le l key else get is_le r key | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.height | val height (#a: eqtype) (#b: Type) (t: tree a b) : nat | val height (#a: eqtype) (#b: Type) (t: tree a b) : nat | let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 13,
"start_col": 0,
"start_line": 10
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.Lib.MapTree.tree a b -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.tree",
"Prims.nat"
] | [] | false | false | false | false | false | let height (#a: eqtype) (#b: Type) (t: tree a b) : nat =
| match t with
| Empty -> 0
| Node _ _ h _ _ -> h | false |
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x1 | val frodo_gen_matrix_shake_4x1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r:lbytes (size 8 *! n)
-> i:size_t{v i < v n / 4}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed) | val frodo_gen_matrix_shake_4x1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r:lbytes (size 8 *! n)
-> i:size_t{v i < v n / 4}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed) | let frodo_gen_matrix_shake_4x1 n tmp_seed r i res =
let r0 = sub r (size 0 *! n) (size 2 *! n) in
let r1 = sub r (size 2 *! n) (size 2 *! n) in
let r2 = sub r (size 4 *! n) (size 2 *! n) in
let r3 = sub r (size 6 *! n) (size 2 *! n) in
frodo_gen_matrix_shake_4x1_get_r n tmp_seed r0 r1 r2 r3 i;
[@inline_let]
let spec h0 = S.frodo_gen_matrix_shake_4x0 (v n) (v i)
(as_seq h0 r0) (as_seq h0 r1) (as_seq h0 r2) (as_seq h0 r3) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res
) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 235,
"start_col": 0,
"start_line": 220
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij)
inline_for_extraction noextract private
val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let concat_ind_seed tmp_seed i =
let h0 = ST.get () in
update_sub_f h0 tmp_seed 0ul 2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16)
inline_for_extraction noextract private
val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let frodo_gen_matrix_shake1 n tmp_seed r i res =
concat_ind_seed tmp_seed i;
SHA3.shake128_hacl 18ul tmp_seed (2ul *! n) r;
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake0 n i r j res
)
val frodo_gen_matrix_shake:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed))
[@"c_inline"]
let frodo_gen_matrix_shake n seed res =
push_frame ();
let r = create (size 2 *! n) (u8 0) in
let tmp_seed = create 18ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake1 (v n) (as_seq h0 seed) in
[@ inline_let]
let inv h (i:nat{i <= v n}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res) in
Loops.eq_repeati0 (v n) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul n inv
(fun i ->
Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake1 n tmp_seed r i res);
pop_frame ()
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x0:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> i:size_t{v i < v n / 4}
-> r0:lbytes (size 2 *! n)
-> r1:lbytes (size 2 *! n)
-> r2:lbytes (size 2 *! n)
-> r3:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h r0 /\ live h r1 /\ live h r2 /\
live h r3 /\ live h res /\
B.loc_pairwise_disjoint [loc res; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x0 (v n) (v i) (as_seq h0 r0) (as_seq h0 r1)
(as_seq h0 r2) (as_seq h0 r3) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res =
let resij0 = sub r0 (j *! size 2) (size 2) in
let resij1 = sub r1 (j *! size 2) (size 2) in
let resij2 = sub r2 (j *! size 2) (size 2) in
let resij3 = sub r3 (j *! size 2) (size 2) in
mset res (size 4 *! i +! size 0) j (uint_from_bytes_le resij0);
mset res (size 4 *! i +! size 1) j (uint_from_bytes_le resij1);
mset res (size 4 *! i +! size 2) j (uint_from_bytes_le resij2);
mset res (size 4 *! i +! size 3) j (uint_from_bytes_le resij3)
val tmp_seed4_pre: h:mem -> tmp_seed:lbytes (18ul *! 4ul) -> Type0
let tmp_seed4_pre h tmp_seed =
let seed0 = LSeq.sub (as_seq h tmp_seed) 2 16 in
let seed1 = LSeq.sub (as_seq h tmp_seed) 20 16 in
let seed2 = LSeq.sub (as_seq h tmp_seed) 38 16 in
let seed3 = LSeq.sub (as_seq h tmp_seed) 56 16 in
seed0 == seed1 /\ seed0 == seed2 /\ seed0 == seed3
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x1_get_r:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r0:lbytes (2ul *! n)
-> r1:lbytes (2ul *! n)
-> r2:lbytes (2ul *! n)
-> r3:lbytes (2ul *! n)
-> i:size_t{v i < v n / 4}
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h r0 /\ live h r1 /\ live h r2 /\ live h r3 /\
loc_pairwise_disjoint [loc tmp_seed; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies (loc r0 |+| loc r1 |+| loc r2 |+| loc r3 |+| loc tmp_seed) h0 h1 /\
(as_seq h1 r0, as_seq h1 r1, as_seq h1 r2, as_seq h1 r3) ==
S.frodo_gen_matrix_shake_4x1_get_r (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed)
let frodo_gen_matrix_shake_4x1_get_r n tmp_seed r0 r1 r2 r3 i =
let tmp_seed0 = sub tmp_seed 0ul 18ul in
let tmp_seed1 = sub tmp_seed 18ul 18ul in
let tmp_seed2 = sub tmp_seed 36ul 18ul in
let tmp_seed3 = sub tmp_seed 54ul 18ul in
concat_ind_seed tmp_seed0 (4ul *! i +! 0ul);
concat_ind_seed tmp_seed1 (4ul *! i +! 1ul);
concat_ind_seed tmp_seed2 (4ul *! i +! 2ul);
concat_ind_seed tmp_seed3 (4ul *! i +! 3ul);
Hacl.Keccak.shake128_4x 18ul tmp_seed0 tmp_seed1 tmp_seed2 tmp_seed3 (size 2 *! n) r0 r1 r2 r3
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r:lbytes (size 8 *! n)
-> i:size_t{v i < v n / 4}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n:
Lib.IntTypes.size_t
{ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\
Lib.IntTypes.v n <= Lib.IntTypes.maxint Lib.IntTypes.U16 } ->
tmp_seed: Hacl.Impl.Matrix.lbytes (18ul *! 4ul) ->
r: Hacl.Impl.Matrix.lbytes (Lib.IntTypes.size 8 *! n) ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n / 4} ->
res: Hacl.Impl.Matrix.matrix_t n n
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.maxint",
"Lib.IntTypes.U16",
"Hacl.Impl.Matrix.lbytes",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size",
"Prims.op_LessThan",
"Prims.op_Division",
"Hacl.Impl.Matrix.matrix_t",
"Lib.Buffer.loop1",
"Hacl.Impl.Matrix.elem",
"Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x0",
"Prims.unit",
"Lib.LoopCombinators.unfold_repeati",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Hacl.Impl.Matrix.as_matrix",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims.nat",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.Frodo.Gen.frodo_gen_matrix_shake_4x0",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x1_get_r",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.mul",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub"
] | [] | false | true | false | false | false | let frodo_gen_matrix_shake_4x1 n tmp_seed r i res =
| let r0 = sub r (size 0 *! n) (size 2 *! n) in
let r1 = sub r (size 2 *! n) (size 2 *! n) in
let r2 = sub r (size 4 *! n) (size 2 *! n) in
let r3 = sub r (size 6 *! n) (size 2 *! n) in
frodo_gen_matrix_shake_4x1_get_r n tmp_seed r0 r1 r2 r3 i;
[@@ inline_let ]let spec h0 =
S.frodo_gen_matrix_shake_4x0 (v n)
(v i)
(as_seq h0 r0)
(as_seq h0 r1)
(as_seq h0 r2)
(as_seq h0 r3)
in
let h0 = ST.get () in
loop1 h0
n
res
spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res) | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.put | val put (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b)
: tree a b | val put (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b)
: tree a b | let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value)) | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 59,
"start_col": 0,
"start_line": 51
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | is_le: (_: a -> _: a -> Prims.bool) -> t: Vale.Lib.MapTree.tree a b -> key: a -> value: b
-> Vale.Lib.MapTree.tree a b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"Vale.Lib.MapTree.mkNode",
"Vale.Lib.MapTree.Empty",
"Prims.nat",
"Prims.op_Equality",
"Vale.Lib.MapTree.balance",
"Vale.Lib.MapTree.put"
] | [
"recursion"
] | false | false | false | false | false | let rec put (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (key: a) (value: b)
: tree a b =
| match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k
then mkNode k value l r
else
if is_le key k
then balance (mkNode k v (put is_le l key value) r)
else balance (mkNode k v l (put is_le r key value)) | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.inv | val inv : is_le: (_: a -> _: a -> Prims.bool) ->
t: Vale.Lib.MapTree.tree a b ->
lo: FStar.Pervasives.Native.option a ->
hi: FStar.Pervasives.Native.option a
-> Prims.logical | let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 74,
"start_col": 0,
"start_line": 68
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
is_le: (_: a -> _: a -> Prims.bool) ->
t: Vale.Lib.MapTree.tree a b ->
lo: FStar.Pervasives.Native.option a ->
hi: FStar.Pervasives.Native.option a
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"FStar.Pervasives.Native.option",
"Prims.l_True",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Vale.Lib.MapTree.inv",
"FStar.Pervasives.Native.Some",
"Prims.logical",
"Vale.Lib.MapTree.is_lt_option"
] | [
"recursion"
] | false | false | false | false | true | let rec inv (#a: eqtype) (#b: Type) (is_le: (a -> a -> bool)) (t: tree a b) (lo hi: option a) =
| let ( < ) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi | false |
|
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.const | val const (a:eqtype) (b:Type) (is_le:(a -> a -> bool){is_cmp is_le}) (default_v:b) : map a b | val const (a:eqtype) (b:Type) (is_le:(a -> a -> bool){is_cmp is_le}) (default_v:b) : map a b | let const a b is_le d =
Map is_le Empty d () | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 147,
"start_col": 0,
"start_line": 146
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
#push-options "--max_fuel 2 --max_ifuel 1"
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi
let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma
(requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_self is_le l key value lo (Some k)
else
lemma_get_put_self is_le r key value (Some k) hi
let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\
key =!= kx
)
(ensures get is_le (put is_le t key value) kx == get is_le t kx)
=
lemma_put_inv is_le t key value lo hi;
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_other is_le l key kx value lo (Some k)
else
lemma_get_put_other is_le r key kx value (Some k) hi
#pop-options
(** Map interface *)
#push-options "--max_fuel 1 --max_ifuel 2"
noeq
type map' (a:eqtype) b =
| Map :
is_le:(a -> a -> bool) ->
t:tree a b ->
default_v:b ->
invs:squash (is_cmp is_le /\ inv is_le t None None) ->
map' a b
#pop-options
let map = map' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Prims.eqtype ->
b: Type ->
is_le: (_: a -> _: a -> Prims.bool){Vale.Lib.MapTree.is_cmp is_le} ->
default_v: b
-> Vale.Lib.MapTree.map a b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.bool",
"Vale.Lib.MapTree.is_cmp",
"Vale.Lib.MapTree.Map",
"Vale.Lib.MapTree.Empty",
"Vale.Lib.MapTree.map"
] | [] | false | false | false | false | false | let const a b is_le d =
| Map is_le Empty d () | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.sel | val sel (#a:eqtype) (#b:Type) (m:map a b) (key:a) : b | val sel (#a:eqtype) (#b:Type) (m:map a b) (key:a) : b | let sel #a #b (Map is_le t d _) key =
match get is_le t key with Some v -> v | None -> d | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 150,
"start_col": 0,
"start_line": 149
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
#push-options "--max_fuel 2 --max_ifuel 1"
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi
let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma
(requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_self is_le l key value lo (Some k)
else
lemma_get_put_self is_le r key value (Some k) hi
let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\
key =!= kx
)
(ensures get is_le (put is_le t key value) kx == get is_le t kx)
=
lemma_put_inv is_le t key value lo hi;
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_other is_le l key kx value lo (Some k)
else
lemma_get_put_other is_le r key kx value (Some k) hi
#pop-options
(** Map interface *)
#push-options "--max_fuel 1 --max_ifuel 2"
noeq
type map' (a:eqtype) b =
| Map :
is_le:(a -> a -> bool) ->
t:tree a b ->
default_v:b ->
invs:squash (is_cmp is_le /\ inv is_le t None None) ->
map' a b
#pop-options
let map = map'
let const a b is_le d =
Map is_le Empty d () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: Vale.Lib.MapTree.map a b -> key: a -> b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.map",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"Prims.squash",
"Prims.l_and",
"Vale.Lib.MapTree.is_cmp",
"Vale.Lib.MapTree.inv",
"FStar.Pervasives.Native.None",
"Vale.Lib.MapTree.get"
] | [] | false | false | false | false | false | let sel #a #b (Map is_le t d _) key =
| match get is_le t key with
| Some v -> v
| None -> d | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.lemma_get_put_self | val lemma_get_put_self
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key: a)
(value: b)
(lo hi: option a)
: Lemma (requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value) | val lemma_get_put_self
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key: a)
(value: b)
(lo hi: option a)
: Lemma (requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value) | let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma
(requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_self is_le l key value lo (Some k)
else
lemma_get_put_self is_le r key value (Some k) hi | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 107,
"start_col": 0,
"start_line": 96
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
#push-options "--max_fuel 2 --max_ifuel 1"
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
is_le: (_: a -> _: a -> Prims.bool) ->
t: Vale.Lib.MapTree.tree a b ->
key: a ->
value: b ->
lo: FStar.Pervasives.Native.option a ->
hi: FStar.Pervasives.Native.option a
-> FStar.Pervasives.Lemma
(requires Vale.Lib.MapTree.is_cmp is_le /\ Vale.Lib.MapTree.inv is_le t lo hi)
(ensures
Vale.Lib.MapTree.get is_le (Vale.Lib.MapTree.put is_le t key value) key ==
FStar.Pervasives.Native.Some value) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"FStar.Pervasives.Native.option",
"Prims.nat",
"Prims.op_Equality",
"Vale.Lib.MapTree.lemma_get_put_self",
"FStar.Pervasives.Native.Some",
"Prims.unit",
"Prims.l_and",
"Vale.Lib.MapTree.is_cmp",
"Vale.Lib.MapTree.inv",
"Prims.squash",
"Prims.eq2",
"Vale.Lib.MapTree.get",
"Vale.Lib.MapTree.put",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_get_put_self
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key: a)
(value: b)
(lo hi: option a)
: Lemma (requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value) =
| match t with
| Empty -> ()
| Node k v _ l r ->
if key = k
then ()
else
if is_le key k
then lemma_get_put_self is_le l key value lo (Some k)
else lemma_get_put_self is_le r key value (Some k) hi | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.upd | val upd (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : map a b | val upd (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : map a b | let upd #a #b (Map is_le t d _) key value =
let t' = put is_le t key value in
lemma_put_inv is_le t key value None None;
Map is_le t' d () | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 155,
"start_col": 0,
"start_line": 152
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
#push-options "--max_fuel 2 --max_ifuel 1"
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi
let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma
(requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_self is_le l key value lo (Some k)
else
lemma_get_put_self is_le r key value (Some k) hi
let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\
key =!= kx
)
(ensures get is_le (put is_le t key value) kx == get is_le t kx)
=
lemma_put_inv is_le t key value lo hi;
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_other is_le l key kx value lo (Some k)
else
lemma_get_put_other is_le r key kx value (Some k) hi
#pop-options
(** Map interface *)
#push-options "--max_fuel 1 --max_ifuel 2"
noeq
type map' (a:eqtype) b =
| Map :
is_le:(a -> a -> bool) ->
t:tree a b ->
default_v:b ->
invs:squash (is_cmp is_le /\ inv is_le t None None) ->
map' a b
#pop-options
let map = map'
let const a b is_le d =
Map is_le Empty d ()
let sel #a #b (Map is_le t d _) key =
match get is_le t key with Some v -> v | None -> d | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: Vale.Lib.MapTree.map a b -> key: a -> value: b -> Vale.Lib.MapTree.map a b | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.map",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"Prims.squash",
"Prims.l_and",
"Vale.Lib.MapTree.is_cmp",
"Vale.Lib.MapTree.inv",
"FStar.Pervasives.Native.None",
"Vale.Lib.MapTree.Map",
"Prims.unit",
"Vale.Lib.MapTree.lemma_put_inv",
"Vale.Lib.MapTree.put"
] | [] | false | false | false | false | false | let upd #a #b (Map is_le t d _) key value =
| let t' = put is_le t key value in
lemma_put_inv is_le t key value None None;
Map is_le t' d () | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.lemma_put_inv | val lemma_put_inv
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key: a)
(value: b)
(lo hi: option a)
: Lemma
(requires
is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi) (ensures inv is_le (put is_le t key value) lo hi) | val lemma_put_inv
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key: a)
(value: b)
(lo hi: option a)
: Lemma
(requires
is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi) (ensures inv is_le (put is_le t key value) lo hi) | let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 49,
"end_line": 94,
"start_col": 0,
"start_line": 77
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
is_le: (_: a -> _: a -> Prims.bool) ->
t: Vale.Lib.MapTree.tree a b ->
key: a ->
value: b ->
lo: FStar.Pervasives.Native.option a ->
hi: FStar.Pervasives.Native.option a
-> FStar.Pervasives.Lemma
(requires
Vale.Lib.MapTree.is_cmp is_le /\ Vale.Lib.MapTree.inv is_le t lo hi /\
Vale.Lib.MapTree.is_lt_option is_le lo (FStar.Pervasives.Native.Some key) /\
Vale.Lib.MapTree.is_lt_option is_le (FStar.Pervasives.Native.Some key) hi)
(ensures Vale.Lib.MapTree.inv is_le (Vale.Lib.MapTree.put is_le t key value) lo hi) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"FStar.Pervasives.Native.option",
"Prims.nat",
"Prims.op_Equality",
"Vale.Lib.MapTree.lemma_put_inv",
"FStar.Pervasives.Native.Some",
"Prims.unit",
"Prims.l_and",
"Vale.Lib.MapTree.is_cmp",
"Vale.Lib.MapTree.inv",
"Prims.b2t",
"Vale.Lib.MapTree.is_lt_option",
"Prims.squash",
"Vale.Lib.MapTree.put",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_put_inv
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key: a)
(value: b)
(lo hi: option a)
: Lemma
(requires
is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi) (ensures inv is_le (put is_le t key value) lo hi) =
| match t with
| Empty -> ()
| Node k v _ l r ->
if key = k
then ()
else
if is_le key k
then lemma_put_inv is_le l key value lo (Some k)
else lemma_put_inv is_le r key value (Some k) hi | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.ec | val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b)) | val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b)) | let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 43,
"start_col": 0,
"start_line": 28
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b)) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b <= logq} ->
k: Lib.IntTypes.uint16{Lib.IntTypes.v k < Prims.pow2 b}
-> Prims.Pure Lib.IntTypes.uint16 | Prims.Pure | [] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.uint16",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.pow2",
"Prims.unit",
"Prims._assert",
"Prims.op_Equality",
"Prims.int",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"FStar.Math.Lemmas.small_modulo_lemma_2",
"Lib.IntTypes.modulus",
"FStar.Math.Lemmas.pow2_le_compat",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.eq2",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.lemma_mult_lt_right",
"Prims.squash",
"FStar.Math.Lemmas.pow2_plus",
"Prims.op_Modulus",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.size"
] | [] | false | false | false | false | false | let ec logq b k =
| let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc ( < ) {
v k * pow2 (logq - b);
( < ) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
( == ) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.lemma_sel_upd_self | val lemma_sel_upd_self (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : Lemma
(ensures sel (upd m key value) key == value)
[SMTPat (sel (upd m key value) key)] | val lemma_sel_upd_self (#a:eqtype) (#b:Type) (m:map a b) (key:a) (value:b) : Lemma
(ensures sel (upd m key value) key == value)
[SMTPat (sel (upd m key value) key)] | let lemma_sel_upd_self #a #b (Map is_le t _ _) key value =
lemma_get_put_self is_le t key value None None | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 161,
"start_col": 0,
"start_line": 160
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
#push-options "--max_fuel 2 --max_ifuel 1"
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi
let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma
(requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_self is_le l key value lo (Some k)
else
lemma_get_put_self is_le r key value (Some k) hi
let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\
key =!= kx
)
(ensures get is_le (put is_le t key value) kx == get is_le t kx)
=
lemma_put_inv is_le t key value lo hi;
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_other is_le l key kx value lo (Some k)
else
lemma_get_put_other is_le r key kx value (Some k) hi
#pop-options
(** Map interface *)
#push-options "--max_fuel 1 --max_ifuel 2"
noeq
type map' (a:eqtype) b =
| Map :
is_le:(a -> a -> bool) ->
t:tree a b ->
default_v:b ->
invs:squash (is_cmp is_le /\ inv is_le t None None) ->
map' a b
#pop-options
let map = map'
let const a b is_le d =
Map is_le Empty d ()
let sel #a #b (Map is_le t d _) key =
match get is_le t key with Some v -> v | None -> d
let upd #a #b (Map is_le t d _) key value =
let t' = put is_le t key value in
lemma_put_inv is_le t key value None None;
Map is_le t' d ()
let lemma_const a b is_le d key =
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: Vale.Lib.MapTree.map a b -> key: a -> value: b
-> FStar.Pervasives.Lemma
(ensures Vale.Lib.MapTree.sel (Vale.Lib.MapTree.upd m key value) key == value)
[SMTPat (Vale.Lib.MapTree.sel (Vale.Lib.MapTree.upd m key value) key)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.map",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"Prims.squash",
"Prims.l_and",
"Vale.Lib.MapTree.is_cmp",
"Vale.Lib.MapTree.inv",
"FStar.Pervasives.Native.None",
"Vale.Lib.MapTree.lemma_get_put_self",
"Prims.unit"
] | [] | false | false | true | false | false | let lemma_sel_upd_self #a #b (Map is_le t _ _) key value =
| lemma_get_put_self is_le t key value None None | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.lemma_sel_upd_other | val lemma_sel_upd_other (#a:eqtype) (#b:Type) (m:map a b) (key kx:a) (value:b) : Lemma
(requires key =!= kx)
(ensures sel (upd m key value) kx == sel m kx)
[SMTPat (sel (upd m key value) kx)] | val lemma_sel_upd_other (#a:eqtype) (#b:Type) (m:map a b) (key kx:a) (value:b) : Lemma
(requires key =!= kx)
(ensures sel (upd m key value) kx == sel m kx)
[SMTPat (sel (upd m key value) kx)] | let lemma_sel_upd_other #a #b (Map is_le t _ _) key kx value =
lemma_get_put_other is_le t key kx value None None | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 164,
"start_col": 0,
"start_line": 163
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
#push-options "--max_fuel 2 --max_ifuel 1"
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi
let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma
(requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_self is_le l key value lo (Some k)
else
lemma_get_put_self is_le r key value (Some k) hi
let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\
key =!= kx
)
(ensures get is_le (put is_le t key value) kx == get is_le t kx)
=
lemma_put_inv is_le t key value lo hi;
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_other is_le l key kx value lo (Some k)
else
lemma_get_put_other is_le r key kx value (Some k) hi
#pop-options
(** Map interface *)
#push-options "--max_fuel 1 --max_ifuel 2"
noeq
type map' (a:eqtype) b =
| Map :
is_le:(a -> a -> bool) ->
t:tree a b ->
default_v:b ->
invs:squash (is_cmp is_le /\ inv is_le t None None) ->
map' a b
#pop-options
let map = map'
let const a b is_le d =
Map is_le Empty d ()
let sel #a #b (Map is_le t d _) key =
match get is_le t key with Some v -> v | None -> d
let upd #a #b (Map is_le t d _) key value =
let t' = put is_le t key value in
lemma_put_inv is_le t key value None None;
Map is_le t' d ()
let lemma_const a b is_le d key =
()
let lemma_sel_upd_self #a #b (Map is_le t _ _) key value =
lemma_get_put_self is_le t key value None None | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: Vale.Lib.MapTree.map a b -> key: a -> kx: a -> value: b
-> FStar.Pervasives.Lemma (requires ~(key == kx))
(ensures
Vale.Lib.MapTree.sel (Vale.Lib.MapTree.upd m key value) kx == Vale.Lib.MapTree.sel m kx)
[SMTPat (Vale.Lib.MapTree.sel (Vale.Lib.MapTree.upd m key value) kx)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Vale.Lib.MapTree.map",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"Prims.squash",
"Prims.l_and",
"Vale.Lib.MapTree.is_cmp",
"Vale.Lib.MapTree.inv",
"FStar.Pervasives.Native.None",
"Vale.Lib.MapTree.lemma_get_put_other",
"Prims.unit"
] | [] | false | false | true | false | false | let lemma_sel_upd_other #a #b (Map is_le t _ _) key kx value =
| lemma_get_put_other is_le t key kx value None None | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.frodo_key_encode0 | val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n | val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n | let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 123,
"start_col": 0,
"start_line": 122
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b <= logq /\ b <= 8} ->
n: Lib.IntTypes.size_pos{n == 8} ->
a: Lib.ByteSequence.lbytes ((n * n) * b / 8) ->
x: Lib.IntTypes.uint64 ->
i: Lib.IntTypes.size_nat{i < n} ->
k: Lib.IntTypes.size_nat{k < 8} ->
res: Spec.Matrix.matrix n n
-> Spec.Matrix.matrix n n | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"Lib.ByteSequence.lbytes",
"Prims.op_Division",
"FStar.Mul.op_Star",
"Lib.IntTypes.uint64",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"Spec.Matrix.matrix",
"Spec.Matrix.op_Array_Assignment",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Frodo.Encode.ec1"
] | [] | false | false | false | false | false | let frodo_key_encode0 logq b n a x i k res =
| res.(i, k) <- ec1 logq b x k | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.as_normal_t | val as_normal_t (#a: Type) (x: a) : normal a | val as_normal_t (#a: Type) (x: a) : normal a | let as_normal_t (#a:Type) (x:a) : normal a = x | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 35,
"start_col": 0,
"start_line": 35
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> Vale.Interop.Base.normal a | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.normal"
] | [] | false | false | false | true | false | let as_normal_t (#a: Type) (x: a) : normal a =
| x | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.frodo_key_encode2 | val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n | val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n | let frodo_key_encode2 logq b n a i res =
let x = frodo_key_encode1 logq b n a i in
Loops.repeati 8 (frodo_key_encode0 logq b n a x i) res | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 56,
"end_line": 151,
"start_col": 0,
"start_line": 149
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n
let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k
val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64
let frodo_key_encode1 logq b n a i =
let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8
val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b <= logq /\ b <= 8} ->
n: Lib.IntTypes.size_pos{n == 8} ->
a: Lib.ByteSequence.lbytes ((n * n) * b / 8) ->
i: Lib.IntTypes.size_nat{i < n} ->
res: Spec.Matrix.matrix n n
-> Spec.Matrix.matrix n n | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"Lib.ByteSequence.lbytes",
"Prims.op_Division",
"FStar.Mul.op_Star",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"Spec.Matrix.matrix",
"Lib.LoopCombinators.repeati",
"Spec.Frodo.Encode.frodo_key_encode0",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.Frodo.Encode.frodo_key_encode1"
] | [] | false | false | false | false | false | let frodo_key_encode2 logq b n a i res =
| let x = frodo_key_encode1 logq b n a i in
Loops.repeati 8 (frodo_key_encode0 logq b n a x i) res | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.as_t | val as_t (#a: Type) (x: normal a) : a | val as_t (#a: Type) (x: normal a) : a | let as_t (#a:Type) (x:normal a) : a = x | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 33,
"start_col": 0,
"start_line": 33
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Vale.Interop.Base.normal a -> a | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.normal"
] | [] | false | false | false | true | false | let as_t (#a: Type) (x: normal a) : a =
| x | false |
Vale.Curve25519.FastHybrid_helpers.fsti | Vale.Curve25519.FastHybrid_helpers.int_canon | val int_canon : _: _ -> FStar.Tactics.Effect.Tac Prims.unit | let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring () | {
"file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastHybrid_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 11,
"start_col": 0,
"start_line": 11
} | module Vale.Curve25519.FastHybrid_helpers
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Mul
open FStar.Tactics
open FStar.Tactics.CanonCommSemiring
open Vale.Curve25519.Fast_defs
open FStar.Calc | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.Fast_defs.fst.checked",
"prims.fst.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Curve25519.FastHybrid_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommSemiring",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: _ -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Tactics.CanonCommSemiring.int_semiring",
"Prims.unit",
"FStar.Stubs.Tactics.V1.Builtins.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"Prims.Nil"
] | [] | false | true | false | false | false | let int_canon =
| fun _ ->
norm [delta; zeta; iota];
int_semiring () | false |
|
Vale.Curve25519.FastHybrid_helpers.fsti | Vale.Curve25519.FastHybrid_helpers.pow2_63 | val pow2_63:nat | val pow2_63:nat | let pow2_63:nat = 0x8000000000000000 | {
"file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastHybrid_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 13,
"start_col": 7,
"start_line": 13
} | module Vale.Curve25519.FastHybrid_helpers
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Mul
open FStar.Tactics
open FStar.Tactics.CanonCommSemiring
open Vale.Curve25519.Fast_defs
open FStar.Calc
let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring () //; dump "Final" | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.Fast_defs.fst.checked",
"prims.fst.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Curve25519.FastHybrid_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommSemiring",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.nat | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let pow2_63:nat =
| 0x8000000000000000 | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.frodo_key_encode | val frodo_key_encode:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> matrix n n | val frodo_key_encode:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> matrix n n | let frodo_key_encode logq b n a =
let res = create n n in
Loops.repeati n (frodo_key_encode2 logq b n a) res | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 163,
"start_col": 0,
"start_line": 161
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n
let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k
val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64
let frodo_key_encode1 logq b n a i =
let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8
val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n
let frodo_key_encode2 logq b n a i res =
let x = frodo_key_encode1 logq b n a i in
Loops.repeati 8 (frodo_key_encode0 logq b n a x i) res
val frodo_key_encode:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> matrix n n | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b <= logq /\ b <= 8} ->
n: Lib.IntTypes.size_pos{n == 8} ->
a: Lib.ByteSequence.lbytes ((n * n) * b / 8)
-> Spec.Matrix.matrix n n | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"Lib.ByteSequence.lbytes",
"Prims.op_Division",
"FStar.Mul.op_Star",
"Lib.LoopCombinators.repeati",
"Spec.Matrix.matrix",
"Spec.Frodo.Encode.frodo_key_encode2",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Spec.Matrix.create"
] | [] | false | false | false | false | false | let frodo_key_encode logq b n a =
| let res = create n n in
Loops.repeati n (frodo_key_encode2 logq b n a) res | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.frodo_key_decode2 | val frodo_key_decode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8) | val frodo_key_decode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8) | let frodo_key_decode2 logq b n a i res =
let templong = Loops.repeat_gen 8 decode_templong_t (frodo_key_decode0 logq b n a i) (u64 0) in
frodo_key_decode1 logq b n i templong res | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 207,
"start_col": 0,
"start_line": 205
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n
let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k
val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64
let frodo_key_encode1 logq b n a i =
let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8
val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n
let frodo_key_encode2 logq b n a i res =
let x = frodo_key_encode1 logq b n a i in
Loops.repeati 8 (frodo_key_encode0 logq b n a x i) res
val frodo_key_encode:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> matrix n n
let frodo_key_encode logq b n a =
let res = create n n in
Loops.repeati n (frodo_key_encode2 logq b n a) res
val frodo_key_decode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> templong:uint64
-> uint64
let frodo_key_decode0 logq b n a i k templong =
templong |. to_u64 (dc logq b a.(i, k)) <<. size (b * k)
val frodo_key_decode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> i:size_nat{i < n}
-> templong:uint64
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8)
let frodo_key_decode1 logq b n i templong res =
update_sub res (i * b) b (LSeq.sub (uint_to_bytes_le templong) 0 b)
val decode_templong_t : i:size_nat{i <= 8} -> Type0
let decode_templong_t i = uint64
val frodo_key_decode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b < logq /\ b <= 8} ->
n: Lib.IntTypes.size_pos{n == 8} ->
a: Spec.Matrix.matrix n n ->
i: Lib.IntTypes.size_nat{i < n} ->
res: Lib.ByteSequence.lbytes ((n * n) * b / 8)
-> Lib.ByteSequence.lbytes ((n * n) * b / 8) | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.int",
"Spec.Matrix.matrix",
"Lib.IntTypes.size_nat",
"Lib.ByteSequence.lbytes",
"Prims.op_Division",
"FStar.Mul.op_Star",
"Spec.Frodo.Encode.frodo_key_decode1",
"Spec.Frodo.Encode.decode_templong_t",
"Lib.LoopCombinators.repeat_gen",
"Spec.Frodo.Encode.frodo_key_decode0",
"Lib.IntTypes.u64"
] | [] | false | false | false | false | false | let frodo_key_decode2 logq b n a i res =
| let templong = Loops.repeat_gen 8 decode_templong_t (frodo_key_decode0 logq b n a i) (u64 0) in
frodo_key_decode1 logq b n i templong res | false |
Vale.Lib.MapTree.fst | Vale.Lib.MapTree.lemma_get_put_other | val lemma_get_put_other
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key kx: a)
(value: b)
(lo hi: option a)
: Lemma
(requires
is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\ key =!= kx)
(ensures get is_le (put is_le t key value) kx == get is_le t kx) | val lemma_get_put_other
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key kx: a)
(value: b)
(lo hi: option a)
: Lemma
(requires
is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\ key =!= kx)
(ensures get is_le (put is_le t key value) kx == get is_le t kx) | let rec lemma_get_put_other (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key kx:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\
key =!= kx
)
(ensures get is_le (put is_le t key value) kx == get is_le t kx)
=
lemma_put_inv is_le t key value lo hi;
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_other is_le l key kx value lo (Some k)
else
lemma_get_put_other is_le r key kx value (Some k) hi | {
"file_name": "vale/code/lib/collections/Vale.Lib.MapTree.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 128,
"start_col": 0,
"start_line": 109
} | module Vale.Lib.MapTree
open FStar.Mul
(** Balanced tree implementation *)
type tree (a:eqtype) (b:Type) =
| Empty : tree a b
| Node : a -> b -> nat -> tree a b -> tree a b -> tree a b
let height (#a:eqtype) (#b:Type) (t:tree a b) : nat =
match t with
| Empty -> 0
| Node _ _ h _ _ -> h
let mkNode (#a:eqtype) (#b:Type) (key:a) (value:b) (l r:tree a b) : tree a b =
let hl = height l in
let hr = height r in
let h = if hl > hr then hl else hr in
Node key value (h + 1) l r
let rotate_l (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kl vl _ l (Node kr vr _ lr rr) -> mkNode kr vr (mkNode kl vl l lr) rr
| _ -> t
let rotate_r (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node kr vr _ (Node kl vl _ ll rl) r -> mkNode kl vl ll (mkNode kr vr rl r)
| _ -> t
let balance (#a:eqtype) (#b:Type) (t:tree a b) : tree a b =
match t with
| Node _ _ _ l r ->
let hl = height l in
let hr = height r in
if hl >= hr + 2 then rotate_r t else
if hr >= hl + 2 then rotate_l t else
t
| _ -> t
let rec get (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) : option b =
match t with
| Empty -> None
| Node k v h l r ->
if key = k then Some v
else if is_le key k then
get is_le l key
else
get is_le r key
let rec put (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) : tree a b =
match t with
| Empty -> mkNode key value Empty Empty
| Node k v _ l r ->
if key = k then mkNode k value l r
else if is_le key k then
balance (mkNode k v (put is_le l key value) r)
else
balance (mkNode k v l (put is_le r key value))
(** Invariants and proofs of get-put correctness *)
let is_lt_option (#a:eqtype) (is_le:a -> a -> bool) (x y:option a) : bool =
match (x, y) with
| (Some x, Some y) -> is_le x y && x <> y
| _ -> true
let rec inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (lo hi:option a) =
let (<) x y = is_lt_option is_le x y in
match t with
| Empty -> True
| Node x _ _ l r ->
let x = Some x in
lo < x /\ x < hi /\ inv is_le l lo x /\ inv is_le r x hi
#push-options "--max_fuel 2 --max_ifuel 1"
let rec lemma_put_inv (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a)
: Lemma
(requires
is_cmp is_le /\
inv is_le t lo hi /\
is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi
)
(ensures inv is_le (put is_le t key value) lo hi)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_put_inv is_le l key value lo (Some k)
else
lemma_put_inv is_le r key value (Some k) hi
let rec lemma_get_put_self (#a:eqtype) (#b:Type) (is_le:a -> a -> bool) (t:tree a b) (key:a) (value:b) (lo hi:option a) : Lemma
(requires is_cmp is_le /\ inv is_le t lo hi)
(ensures get is_le (put is_le t key value) key == Some value)
=
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k then ()
else if is_le key k then
lemma_get_put_self is_le l key value lo (Some k)
else
lemma_get_put_self is_le r key value (Some k) hi | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Lib.MapTree.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
is_le: (_: a -> _: a -> Prims.bool) ->
t: Vale.Lib.MapTree.tree a b ->
key: a ->
kx: a ->
value: b ->
lo: FStar.Pervasives.Native.option a ->
hi: FStar.Pervasives.Native.option a
-> FStar.Pervasives.Lemma
(requires
Vale.Lib.MapTree.is_cmp is_le /\ Vale.Lib.MapTree.inv is_le t lo hi /\
Vale.Lib.MapTree.is_lt_option is_le lo (FStar.Pervasives.Native.Some key) /\
Vale.Lib.MapTree.is_lt_option is_le (FStar.Pervasives.Native.Some key) hi /\ ~(key == kx))
(ensures
Vale.Lib.MapTree.get is_le (Vale.Lib.MapTree.put is_le t key value) kx ==
Vale.Lib.MapTree.get is_le t kx) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.bool",
"Vale.Lib.MapTree.tree",
"FStar.Pervasives.Native.option",
"Prims.nat",
"Prims.op_Equality",
"Vale.Lib.MapTree.lemma_get_put_other",
"FStar.Pervasives.Native.Some",
"Prims.unit",
"Vale.Lib.MapTree.lemma_put_inv",
"Prims.l_and",
"Vale.Lib.MapTree.is_cmp",
"Vale.Lib.MapTree.inv",
"Prims.b2t",
"Vale.Lib.MapTree.is_lt_option",
"Prims.l_not",
"Prims.eq2",
"Prims.squash",
"Vale.Lib.MapTree.get",
"Vale.Lib.MapTree.put",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_get_put_other
(#a: eqtype)
(#b: Type)
(is_le: (a -> a -> bool))
(t: tree a b)
(key kx: a)
(value: b)
(lo hi: option a)
: Lemma
(requires
is_cmp is_le /\ inv is_le t lo hi /\ is_lt_option is_le lo (Some key) /\
is_lt_option is_le (Some key) hi /\ key =!= kx)
(ensures get is_le (put is_le t key value) kx == get is_le t kx) =
| lemma_put_inv is_le t key value lo hi;
match t with
| Empty -> ()
| Node k v _ l r ->
if key = k
then ()
else
if is_le key k
then lemma_get_put_other is_le l key kx value lo (Some k)
else lemma_get_put_other is_le r key kx value (Some k) hi | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.frodo_key_encode1 | val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64 | val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64 | let frodo_key_encode1 logq b n a i =
let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8 | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 137,
"start_col": 0,
"start_line": 134
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n
let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k
val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64 | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b <= logq /\ b <= 8} ->
n: Lib.IntTypes.size_pos{n == 8} ->
a: Lib.ByteSequence.lbytes ((n * n) * b / 8) ->
i: Lib.IntTypes.size_nat{i < n}
-> Lib.IntTypes.uint64 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"Lib.ByteSequence.lbytes",
"Prims.op_Division",
"FStar.Mul.op_Star",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"Lib.ByteSequence.uint_from_bytes_le",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.Sequence.sub",
"Prims.op_Multiply",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.op_Addition",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"Lib.IntTypes.uint_t",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_imp",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Lib.IntTypes.uint64"
] | [] | false | false | false | false | false | let frodo_key_encode1 logq b n a i =
| let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8 | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.frodo_key_decode0 | val frodo_key_decode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> templong:uint64
-> uint64 | val frodo_key_decode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> templong:uint64
-> uint64 | let frodo_key_decode0 logq b n a i k templong =
templong |. to_u64 (dc logq b a.(i, k)) <<. size (b * k) | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 177,
"start_col": 0,
"start_line": 176
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n
let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k
val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64
let frodo_key_encode1 logq b n a i =
let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8
val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n
let frodo_key_encode2 logq b n a i res =
let x = frodo_key_encode1 logq b n a i in
Loops.repeati 8 (frodo_key_encode0 logq b n a x i) res
val frodo_key_encode:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> matrix n n
let frodo_key_encode logq b n a =
let res = create n n in
Loops.repeati n (frodo_key_encode2 logq b n a) res
val frodo_key_decode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> templong:uint64
-> uint64 | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b < logq /\ b <= 8} ->
n: Lib.IntTypes.size_pos{n == 8} ->
a: Spec.Matrix.matrix n n ->
i: Lib.IntTypes.size_nat{i < n} ->
k: Lib.IntTypes.size_nat{k < 8} ->
templong: Lib.IntTypes.uint64
-> Lib.IntTypes.uint64 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.int",
"Spec.Matrix.matrix",
"Lib.IntTypes.size_nat",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.U16",
"Spec.Frodo.Encode.dc",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.size",
"FStar.Mul.op_Star"
] | [] | false | false | false | false | false | let frodo_key_decode0 logq b n a i k templong =
| templong |. to_u64 (dc logq b a.(i, k)) <<. size (b * k) | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.frodo_key_decode | val frodo_key_decode:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> lbytes (n * n * b / 8) | val frodo_key_decode:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> lbytes (n * n * b / 8) | let frodo_key_decode logq b n a =
let resLen = n * n * b / 8 in
let res = LSeq.create resLen (u8 0) in
Loops.repeati n (frodo_key_decode2 logq b n a) res | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 220,
"start_col": 0,
"start_line": 217
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n
let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k
val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64
let frodo_key_encode1 logq b n a i =
let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8
val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n
let frodo_key_encode2 logq b n a i res =
let x = frodo_key_encode1 logq b n a i in
Loops.repeati 8 (frodo_key_encode0 logq b n a x i) res
val frodo_key_encode:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> matrix n n
let frodo_key_encode logq b n a =
let res = create n n in
Loops.repeati n (frodo_key_encode2 logq b n a) res
val frodo_key_decode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> templong:uint64
-> uint64
let frodo_key_decode0 logq b n a i k templong =
templong |. to_u64 (dc logq b a.(i, k)) <<. size (b * k)
val frodo_key_decode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> i:size_nat{i < n}
-> templong:uint64
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8)
let frodo_key_decode1 logq b n i templong res =
update_sub res (i * b) b (LSeq.sub (uint_to_bytes_le templong) 0 b)
val decode_templong_t : i:size_nat{i <= 8} -> Type0
let decode_templong_t i = uint64
val frodo_key_decode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8)
let frodo_key_decode2 logq b n a i res =
let templong = Loops.repeat_gen 8 decode_templong_t (frodo_key_decode0 logq b n a i) (u64 0) in
frodo_key_decode1 logq b n i templong res
val frodo_key_decode:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> lbytes (n * n * b / 8) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b < logq /\ b <= 8} ->
n: Lib.IntTypes.size_pos{n == 8} ->
a: Spec.Matrix.matrix n n
-> Lib.ByteSequence.lbytes ((n * n) * b / 8) | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.int",
"Spec.Matrix.matrix",
"Lib.LoopCombinators.repeati",
"Lib.ByteSequence.lbytes",
"Prims.op_Division",
"FStar.Mul.op_Star",
"Spec.Frodo.Encode.frodo_key_decode2",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.Seq.Base.seq",
"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.uint_t",
"Lib.IntTypes.u8"
] | [] | false | false | false | false | false | let frodo_key_decode logq b n a =
| let resLen = (n * n) * b / 8 in
let res = LSeq.create resLen (u8 0) in
Loops.repeati n (frodo_key_decode2 logq b n a) res | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.ec1 | val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk)) | val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk)) | let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk) | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 108,
"start_col": 0,
"start_line": 96
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk)) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b <= logq /\ b <= 8} ->
x: Lib.IntTypes.uint64 ->
k: Lib.IntTypes.size_nat{k < 8}
-> Prims.Pure Lib.IntTypes.uint16 | Prims.Pure | [] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Lib.IntTypes.uint64",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"Spec.Frodo.Encode.ec",
"Lib.IntTypes.to_u16",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Calc.calc_finish",
"Lib.IntTypes.range_t",
"Prims.eq2",
"Lib.IntTypes.v",
"Prims.op_Modulus",
"Prims.op_Division",
"Prims.pow2",
"FStar.Mul.op_Star",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Lib.IntTypes.size",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Spec.Frodo.Lemmas.modulo_pow2_u64",
"Prims.squash",
"FStar.Math.Lemmas.pow2_lt_compat",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.u64",
"Lib.IntTypes.uint16"
] | [] | false | false | false | false | false | let ec1 logq b x k =
| let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc ( == ) {
v rk;
( == ) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
( == ) { () }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk) | false |
Spec.Frodo.Encode.fst | Spec.Frodo.Encode.frodo_key_decode1 | val frodo_key_decode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> i:size_nat{i < n}
-> templong:uint64
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8) | val frodo_key_decode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> i:size_nat{i < n}
-> templong:uint64
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8) | let frodo_key_decode1 logq b n i templong res =
update_sub res (i * b) b (LSeq.sub (uint_to_bytes_le templong) 0 b) | {
"file_name": "specs/frodo/Spec.Frodo.Encode.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 69,
"end_line": 190,
"start_col": 0,
"start_line": 189
} | module Spec.Frodo.Encode
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.Matrix
open Spec.Frodo.Lemmas
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** The simplified version of the encode and decode functions when n = params_nbar = 8 *)
val ec:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq}
-> k:uint16{v k < pow2 b}
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 logq /\ v r == v k * pow2 (logq - b))
let ec logq b k =
let res = k <<. size (logq - b) in
assert (v res = v k * pow2 (logq - b) % modulus U16);
calc (<) {
v k * pow2 (logq - b);
(<) { Math.Lemmas.lemma_mult_lt_right (pow2 (logq - b)) (v k) (pow2 b) }
pow2 b * pow2 (logq - b);
(==) { Math.Lemmas.pow2_plus b (logq - b) }
pow2 logq;
};
Math.Lemmas.pow2_le_compat 16 logq;
Math.Lemmas.small_modulo_lemma_2 (v k * pow2 (logq - b)) (modulus U16);
assert (v res = v k * pow2 (logq - b));
res
val dc:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq}
-> c:uint16
-> Pure uint16
(requires True)
(ensures fun r ->
v r < pow2 b /\ v r = (v c + pow2 (logq - b - 1)) / pow2 (logq - b) % pow2 b)
let dc logq b c =
let res1 = (c +. (u16 1 <<. size (logq - b - 1))) >>. size (logq - b) in
Math.Lemmas.pow2_lt_compat 16 (16 - logq + b);
calc (==) {
v res1;
(==) { }
(((v c + pow2 (logq - b - 1) % modulus U16) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.lemma_mod_plus_distr_r (v c) (pow2 (logq - b - 1)) (modulus U16) }
(((v c + pow2 (logq - b - 1)) % modulus U16) / pow2 (logq - b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (v c + pow2 (logq - b - 1)) (logq - b) 16 }
(((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b)) % modulus U16;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_2 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) 16 (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 (16 - logq + b);
};
let res = res1 &. ((u16 1 <<. size b) -. u16 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v res;
(==) { modulo_pow2_u16 res1 b }
v res1 % pow2 b;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 ((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) b (16 - logq + b) }
((v c + pow2 (logq - b - 1)) / pow2 (logq - b)) % pow2 b;
};
res
val ec1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> x:uint64
-> k:size_nat{k < 8}
-> Pure uint16
(requires True)
(ensures fun res ->
let rk = v x / pow2 (b * k) % pow2 b in
Math.Lemmas.pow2_lt_compat 16 b;
res == ec logq b (u16 rk))
let ec1 logq b x k =
let rk = (x >>. size (b * k)) &. ((u64 1 <<. size b) -. u64 1) in
Math.Lemmas.pow2_lt_compat 16 b;
calc (==) {
v rk;
(==) { modulo_pow2_u64 (x >>. size (b * k)) b }
v (x >>. size (b * k)) % pow2 b;
(==) { }
v x / pow2 (b * k) % pow2 b;
};
ec logq b (to_u16 rk)
val frodo_key_encode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> x:uint64
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> res:matrix n n
-> matrix n n
let frodo_key_encode0 logq b n a x i k res =
res.(i, k) <- ec1 logq b x k
val frodo_key_encode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> uint64
let frodo_key_encode1 logq b n a i =
let v8 = LSeq.create 8 (u8 0) in
let v8 = update_sub v8 0 b (LSeq.sub a (i * b) b) in
uint_from_bytes_le #U64 v8
val frodo_key_encode2:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> i:size_nat{i < n}
-> res:matrix n n
-> matrix n n
let frodo_key_encode2 logq b n a i res =
let x = frodo_key_encode1 logq b n a i in
Loops.repeati 8 (frodo_key_encode0 logq b n a x i) res
val frodo_key_encode:
logq:size_pos{logq <= 16}
-> b:size_pos{b <= logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:lbytes (n * n * b / 8)
-> matrix n n
let frodo_key_encode logq b n a =
let res = create n n in
Loops.repeati n (frodo_key_encode2 logq b n a) res
val frodo_key_decode0:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> a:matrix n n
-> i:size_nat{i < n}
-> k:size_nat{k < 8}
-> templong:uint64
-> uint64
let frodo_key_decode0 logq b n a i k templong =
templong |. to_u64 (dc logq b a.(i, k)) <<. size (b * k)
val frodo_key_decode1:
logq:size_pos{logq <= 16}
-> b:size_pos{b < logq /\ b <= 8}
-> n:size_pos{n == 8}
-> i:size_nat{i < n}
-> templong:uint64
-> res:lbytes (n * n * b / 8)
-> lbytes (n * n * b / 8) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Frodo.Encode.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Spec.Frodo.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
logq: Lib.IntTypes.size_pos{logq <= 16} ->
b: Lib.IntTypes.size_pos{b < logq /\ b <= 8} ->
n: Lib.IntTypes.size_pos{n == 8} ->
i: Lib.IntTypes.size_nat{i < n} ->
templong: Lib.IntTypes.uint64 ->
res: Lib.ByteSequence.lbytes ((n * n) * b / 8)
-> Lib.ByteSequence.lbytes ((n * n) * b / 8) | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.size_nat",
"Lib.IntTypes.uint64",
"Lib.ByteSequence.lbytes",
"Prims.op_Division",
"FStar.Mul.op_Star",
"Lib.Sequence.update_sub",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.U64",
"Lib.ByteSequence.uint_to_bytes_le"
] | [] | false | false | false | false | false | let frodo_key_decode1 logq b n i templong res =
| update_sub res (i * b) b (LSeq.sub (uint_to_bytes_le templong) 0 b) | false |
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x1_get_r | val frodo_gen_matrix_shake_4x1_get_r:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r0:lbytes (2ul *! n)
-> r1:lbytes (2ul *! n)
-> r2:lbytes (2ul *! n)
-> r3:lbytes (2ul *! n)
-> i:size_t{v i < v n / 4}
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h r0 /\ live h r1 /\ live h r2 /\ live h r3 /\
loc_pairwise_disjoint [loc tmp_seed; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies (loc r0 |+| loc r1 |+| loc r2 |+| loc r3 |+| loc tmp_seed) h0 h1 /\
(as_seq h1 r0, as_seq h1 r1, as_seq h1 r2, as_seq h1 r3) ==
S.frodo_gen_matrix_shake_4x1_get_r (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed) | val frodo_gen_matrix_shake_4x1_get_r:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r0:lbytes (2ul *! n)
-> r1:lbytes (2ul *! n)
-> r2:lbytes (2ul *! n)
-> r3:lbytes (2ul *! n)
-> i:size_t{v i < v n / 4}
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h r0 /\ live h r1 /\ live h r2 /\ live h r3 /\
loc_pairwise_disjoint [loc tmp_seed; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies (loc r0 |+| loc r1 |+| loc r2 |+| loc r3 |+| loc tmp_seed) h0 h1 /\
(as_seq h1 r0, as_seq h1 r1, as_seq h1 r2, as_seq h1 r3) ==
S.frodo_gen_matrix_shake_4x1_get_r (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed) | let frodo_gen_matrix_shake_4x1_get_r n tmp_seed r0 r1 r2 r3 i =
let tmp_seed0 = sub tmp_seed 0ul 18ul in
let tmp_seed1 = sub tmp_seed 18ul 18ul in
let tmp_seed2 = sub tmp_seed 36ul 18ul in
let tmp_seed3 = sub tmp_seed 54ul 18ul in
concat_ind_seed tmp_seed0 (4ul *! i +! 0ul);
concat_ind_seed tmp_seed1 (4ul *! i +! 1ul);
concat_ind_seed tmp_seed2 (4ul *! i +! 2ul);
concat_ind_seed tmp_seed3 (4ul *! i +! 3ul);
Hacl.Keccak.shake128_4x 18ul tmp_seed0 tmp_seed1 tmp_seed2 tmp_seed3 (size 2 *! n) r0 r1 r2 r3 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 96,
"end_line": 201,
"start_col": 0,
"start_line": 191
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij)
inline_for_extraction noextract private
val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let concat_ind_seed tmp_seed i =
let h0 = ST.get () in
update_sub_f h0 tmp_seed 0ul 2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16)
inline_for_extraction noextract private
val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let frodo_gen_matrix_shake1 n tmp_seed r i res =
concat_ind_seed tmp_seed i;
SHA3.shake128_hacl 18ul tmp_seed (2ul *! n) r;
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake0 n i r j res
)
val frodo_gen_matrix_shake:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed))
[@"c_inline"]
let frodo_gen_matrix_shake n seed res =
push_frame ();
let r = create (size 2 *! n) (u8 0) in
let tmp_seed = create 18ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake1 (v n) (as_seq h0 seed) in
[@ inline_let]
let inv h (i:nat{i <= v n}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res) in
Loops.eq_repeati0 (v n) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul n inv
(fun i ->
Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake1 n tmp_seed r i res);
pop_frame ()
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x0:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> i:size_t{v i < v n / 4}
-> r0:lbytes (size 2 *! n)
-> r1:lbytes (size 2 *! n)
-> r2:lbytes (size 2 *! n)
-> r3:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h r0 /\ live h r1 /\ live h r2 /\
live h r3 /\ live h res /\
B.loc_pairwise_disjoint [loc res; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x0 (v n) (v i) (as_seq h0 r0) (as_seq h0 r1)
(as_seq h0 r2) (as_seq h0 r3) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res =
let resij0 = sub r0 (j *! size 2) (size 2) in
let resij1 = sub r1 (j *! size 2) (size 2) in
let resij2 = sub r2 (j *! size 2) (size 2) in
let resij3 = sub r3 (j *! size 2) (size 2) in
mset res (size 4 *! i +! size 0) j (uint_from_bytes_le resij0);
mset res (size 4 *! i +! size 1) j (uint_from_bytes_le resij1);
mset res (size 4 *! i +! size 2) j (uint_from_bytes_le resij2);
mset res (size 4 *! i +! size 3) j (uint_from_bytes_le resij3)
val tmp_seed4_pre: h:mem -> tmp_seed:lbytes (18ul *! 4ul) -> Type0
let tmp_seed4_pre h tmp_seed =
let seed0 = LSeq.sub (as_seq h tmp_seed) 2 16 in
let seed1 = LSeq.sub (as_seq h tmp_seed) 20 16 in
let seed2 = LSeq.sub (as_seq h tmp_seed) 38 16 in
let seed3 = LSeq.sub (as_seq h tmp_seed) 56 16 in
seed0 == seed1 /\ seed0 == seed2 /\ seed0 == seed3
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x1_get_r:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r0:lbytes (2ul *! n)
-> r1:lbytes (2ul *! n)
-> r2:lbytes (2ul *! n)
-> r3:lbytes (2ul *! n)
-> i:size_t{v i < v n / 4}
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h r0 /\ live h r1 /\ live h r2 /\ live h r3 /\
loc_pairwise_disjoint [loc tmp_seed; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies (loc r0 |+| loc r1 |+| loc r2 |+| loc r3 |+| loc tmp_seed) h0 h1 /\
(as_seq h1 r0, as_seq h1 r1, as_seq h1 r2, as_seq h1 r3) ==
S.frodo_gen_matrix_shake_4x1_get_r (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n:
Lib.IntTypes.size_t
{ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\
Lib.IntTypes.v n <= Lib.IntTypes.maxint Lib.IntTypes.U16 } ->
tmp_seed: Hacl.Impl.Matrix.lbytes (18ul *! 4ul) ->
r0: Hacl.Impl.Matrix.lbytes (2ul *! n) ->
r1: Hacl.Impl.Matrix.lbytes (2ul *! n) ->
r2: Hacl.Impl.Matrix.lbytes (2ul *! n) ->
r3: Hacl.Impl.Matrix.lbytes (2ul *! n) ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n / 4}
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.maxint",
"Lib.IntTypes.U16",
"Hacl.Impl.Matrix.lbytes",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Prims.op_LessThan",
"Prims.op_Division",
"Hacl.Keccak.shake128_4x",
"Lib.IntTypes.size",
"Prims.unit",
"Hacl.Impl.Frodo.Gen.concat_ind_seed",
"Lib.IntTypes.op_Plus_Bang",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Lib.IntTypes.uint8"
] | [] | false | true | false | false | false | let frodo_gen_matrix_shake_4x1_get_r n tmp_seed r0 r1 r2 r3 i =
| let tmp_seed0 = sub tmp_seed 0ul 18ul in
let tmp_seed1 = sub tmp_seed 18ul 18ul in
let tmp_seed2 = sub tmp_seed 36ul 18ul in
let tmp_seed3 = sub tmp_seed 54ul 18ul in
concat_ind_seed tmp_seed0 (4ul *! i +! 0ul);
concat_ind_seed tmp_seed1 (4ul *! i +! 1ul);
concat_ind_seed tmp_seed2 (4ul *! i +! 2ul);
concat_ind_seed tmp_seed3 (4ul *! i +! 3ul);
Hacl.Keccak.shake128_4x 18ul tmp_seed0 tmp_seed1 tmp_seed2 tmp_seed3 (size 2 *! n) r0 r1 r2 r3 | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.dom | val dom:IX64.arity_ok_stdcall td | val dom:IX64.arity_ok_stdcall td | let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64; tuint64] in
assert_norm (List.length y = 4);
y | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 50,
"start_col": 0,
"start_line": 47
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.Interop.X64.arity_ok_stdcall Vale.Interop.Base.td | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list",
"Prims.Cons",
"Vale.Stdcalls.X64.Poly.t64_mod",
"Vale.Stdcalls.X64.Poly.t64_no_mod",
"Vale.Stdcalls.X64.Poly.tuint64",
"Prims.Nil"
] | [] | false | false | false | true | false | let dom:IX64.arity_ok_stdcall td =
| let y = [t64_mod; t64_no_mod; tuint64; tuint64] in
assert_norm (List.length y = 4);
y | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.poly_post | val poly_post:VSig.vale_post dom | val poly_post:VSig.vale_post dom | let poly_post : VSig.vale_post dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
PO.va_ens_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
va_s1 f | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 77,
"start_col": 0,
"start_line": 66
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64; tuint64] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state) ->
PO.va_req_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
(* Need to rearrange the order of arguments *) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.Poly.dom | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.Poly.b64",
"Vale.Stdcalls.X64.Poly.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.Poly1305.X64.va_ens_Poly1305",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt64",
"FStar.UInt64.v",
"Prims.prop"
] | [] | false | false | false | true | false | let poly_post:VSig.vale_post dom =
| fun
(c: V.va_code)
(ctx_b: b64)
(inp_b: b64)
(len: uint64)
(finish: uint64)
(va_s0: V.va_state)
(va_s1: V.va_state)
(f: V.va_fuel)
->
PO.va_ens_Poly1305 c
va_s0
IA.win
(as_vale_buffer ctx_b)
(as_vale_buffer inp_b)
(UInt64.v len)
(UInt64.v finish)
va_s1
f | false |
LowParse.Spec.Bytes.fst | LowParse.Spec.Bytes.parse_bounded_vlbytes_eq | val parse_bounded_vlbytes_eq
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res ==
Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else res == None) | val parse_bounded_vlbytes_eq
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res ==
Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else res == None) | let parse_bounded_vlbytes_eq
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res == Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else
res == None
)
= let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz) | {
"file_name": "src/lowparse/LowParse.Spec.Bytes.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 83,
"end_line": 217,
"start_col": 0,
"start_line": 197
} | module LowParse.Spec.Bytes
include LowParse.Spec.VLGen
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
#set-options "--z3rlimit 128 --max_fuel 64 --max_ifuel 64"
let lt_pow2_32
(x: nat)
: Lemma
(x < 4294967296 <==> x < pow2 32)
= ()
#reset-options
let parse_flbytes_gen
(sz: nat { sz < 4294967296 } )
(s: bytes { Seq.length s == sz } )
: GTot (B32.lbytes sz)
= lt_pow2_32 sz;
B32.hide s
let parse_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (parser (total_constant_size_parser_kind sz) (B32.lbytes sz))
= make_total_constant_size_parser sz (B32.lbytes sz) (parse_flbytes_gen sz)
let serialize_flbytes'
(sz: nat { sz < 4294967296 } )
: Tot (bare_serializer (B32.lbytes sz))
= fun (x: B32.lbytes sz) -> (
lt_pow2_32 sz;
B32.reveal x
)
let serialize_flbytes_correct
(sz: nat { sz < 4294967296 } )
: Lemma
(serializer_correct (parse_flbytes sz) (serialize_flbytes' sz))
= let prf
(input: B32.lbytes sz)
: Lemma
(
let ser = serialize_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf
let serialize_flbytes
(sz: nat { sz < 4294967296 } )
: Tot (serializer (parse_flbytes sz))
= serialize_flbytes_correct sz;
serialize_flbytes' sz
(* VLBytes *)
(* For the payload: since the input buffer is truncated at the time of
reading the length header, "parsing" the payload will always succeed,
by just returning it unchanged (unless the length of the input
is greater than 2^32) *)
inline_for_extraction
let parse_all_bytes_kind =
{
parser_kind_low = 0;
parser_kind_high = None;
parser_kind_metadata = None;
parser_kind_subkind = Some ParserConsumesAll;
}
let parse_all_bytes'
(input: bytes)
: Tot (option (B32.bytes * consumed_length input))
= let len = Seq.length input in
if len >= 4294967296
then None
else begin
lt_pow2_32 len;
Some (B32.b32_hide input, len)
end
#set-options "--z3rlimit 16"
let parse_all_bytes_injective () : Lemma
(injective parse_all_bytes')
= let prf
(b1 b2: bytes)
: Lemma
(requires (injective_precond parse_all_bytes' b1 b2))
(ensures (injective_postcond parse_all_bytes' b1 b2))
= assert (Seq.length b1 < 4294967296);
assert (Seq.length b2 < 4294967296);
lt_pow2_32 (Seq.length b1);
lt_pow2_32 (Seq.length b2);
B32.reveal_hide b1;
B32.reveal_hide b2
in
Classical.forall_intro_2 (fun x -> Classical.move_requires (prf x))
#reset-options
let parse_all_bytes_correct () : Lemma
(parser_kind_prop parse_all_bytes_kind parse_all_bytes')
= parser_kind_prop_equiv parse_all_bytes_kind parse_all_bytes';
parse_all_bytes_injective ()
let tot_parse_all_bytes : tot_parser parse_all_bytes_kind B32.bytes =
parse_all_bytes_correct ();
parse_all_bytes'
let parse_all_bytes : parser parse_all_bytes_kind B32.bytes =
tot_parse_all_bytes
let serialize_all_bytes'
(input: B32.bytes)
: GTot bytes
= B32.reveal input
#set-options "--z3rlimit 32"
let serialize_all_bytes_correct () : Lemma (serializer_correct parse_all_bytes serialize_all_bytes') =
let prf
(input: B32.bytes)
: Lemma
(
let ser = serialize_all_bytes' input in
let len : consumed_length ser = Seq.length ser in
parse parse_all_bytes ser == Some (input, len)
)
= assert (Seq.length (serialize_all_bytes' input) == B32.length input);
lt_pow2_32 (B32.length input);
B32.hide_reveal input
in
Classical.forall_intro prf
#reset-options
let serialize_all_bytes : serializer parse_all_bytes =
serialize_all_bytes_correct ();
serialize_all_bytes'
let parse_bounded_vlbytes_aux
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes))
= parse_bounded_vldata_strong' min max l serialize_all_bytes
let parse_bounded_vlbytes_pred
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(x: B32.bytes)
: GTot Type0
= let reslen = B32.length x in
min <= reslen /\ reslen <= max
let parse_bounded_vlbytes_t
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot Type
= (x: B32.bytes { parse_bounded_vlbytes_pred min max x } )
let parse_bounded_vlbytes_kind
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
: Tot parser_kind
= parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind
inline_for_extraction
let synth_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)
: Tot (parse_bounded_vlbytes_t min max)
= x
let parse_bounded_vlbytes'
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
(l: nat { l >= log256' max /\ l <= 4 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max)
let parse_bounded_vlbytes
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 } )
: Tot (parser (parse_bounded_vldata_strong_kind min max (log256' max) parse_all_bytes_kind) (parse_bounded_vlbytes_t min max))
= parse_bounded_vlbytes' min max (log256' max)
#set-options "--z3rlimit 16" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Bytes.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} ->
l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} ->
input: LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(ensures
(let res =
LowParse.Spec.Base.parse (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) input
in
(match
LowParse.Spec.Base.parse (LowParse.Spec.BoundedInt.parse_bounded_integer l) input
with
| FStar.Pervasives.Native.None #_ -> res == FStar.Pervasives.Native.None
| FStar.Pervasives.Native.Some
#_
(FStar.Pervasives.Native.Mktuple2 #_ #_ header consumed_header) ->
(match
min <= FStar.UInt32.v header && FStar.UInt32.v header <= max &&
l + FStar.UInt32.v header <= FStar.Seq.Base.length input
with
| true ->
consumed_header == l /\
res ==
FStar.Pervasives.Native.Some
(FStar.Bytes.hide (FStar.Seq.Base.slice input l (l + FStar.UInt32.v header)),
consumed_header + FStar.UInt32.v header)
| _ -> res == FStar.Pervasives.Native.None)
<:
Type0)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"Prims.unit",
"LowParse.Spec.VLData.parse_vldata_gen_eq",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.Bytes.parse_all_bytes_kind",
"FStar.Bytes.bytes",
"LowParse.Spec.Bytes.parse_all_bytes",
"LowParse.Spec.Combinators.parse_synth_eq",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.Spec.Bytes.serialize_all_bytes",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_t",
"LowParse.Spec.Bytes.parse_bounded_vlbytes_aux",
"LowParse.Spec.Bytes.synth_bounded_vlbytes",
"Prims.l_True",
"Prims.squash",
"LowParse.Spec.Base.parse",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"FStar.Pervasives.Native.None",
"Prims.op_AmpAmp",
"FStar.UInt32.v",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.l_or",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Bytes.hide",
"FStar.Seq.Base.slice",
"Prims.bool",
"LowParse.Spec.Bytes.parse_bounded_vlbytes'",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let parse_bounded_vlbytes_eq
(min: nat)
(max: nat{min <= max /\ max > 0 /\ max < 4294967296})
(l: nat{l >= log256' max /\ l <= 4})
(input: bytes)
: Lemma
(let res = parse (parse_bounded_vlbytes' min max l) input in
match parse (parse_bounded_integer l) input with
| None -> res == None
| Some (header, consumed_header) ->
if min <= U32.v header && U32.v header <= max && l + U32.v header <= Seq.length input
then
consumed_header == l /\
res ==
Some (B32.hide (Seq.slice input l (l + U32.v header)), consumed_header + U32.v header)
else res == None) =
| let sz = l in
parse_synth_eq (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input;
parse_vldata_gen_eq sz (in_bounds min max) parse_all_bytes input;
parser_kind_prop_equiv (parse_bounded_integer_kind sz) (parse_bounded_integer sz) | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.poly_pre | val poly_pre:VSig.vale_pre dom | val poly_pre:VSig.vale_pre dom | let poly_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state) ->
PO.va_req_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 86,
"end_line": 62,
"start_col": 0,
"start_line": 54
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64; tuint64] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.Poly.dom | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.Poly.b64",
"Vale.Stdcalls.X64.Poly.uint64",
"Vale.X64.Decls.va_state",
"Vale.Poly1305.X64.va_req_Poly1305",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt64",
"FStar.UInt64.v",
"Prims.prop"
] | [] | false | false | false | true | false | let poly_pre:VSig.vale_pre dom =
| fun (c: V.va_code) (ctx_b: b64) (inp_b: b64) (len: uint64) (finish: uint64) (va_s0: V.va_state) ->
PO.va_req_Poly1305 c
va_s0
IA.win
(as_vale_buffer ctx_b)
(as_vale_buffer inp_b)
(UInt64.v len)
(UInt64.v finish) | false |
Hacl.P256.PrecompTable.fst | Hacl.P256.PrecompTable.precomp_basepoint_table_w5 | val precomp_basepoint_table_w5:
x:glbuffer uint64 384ul{witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x} | val precomp_basepoint_table_w5:
x:glbuffer uint64 384ul{witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x} | let precomp_basepoint_table_w5:
x:glbuffer uint64 384ul{witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x} =
createL_global precomp_basepoint_table_list_w5 | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 295,
"start_col": 0,
"start_line": 293
} | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module SPT = Hacl.Spec.PrecompBaseTable
module SPT256 = Hacl.Spec.PrecompBaseTable256
module SPTK = Hacl.Spec.P256.PrecompTable
module S = Spec.P256
module SL = Spec.P256.Lemmas
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let proj_point_to_list p =
SPTK.proj_point_to_list_lemma p;
SPTK.proj_point_to_list p
let lemma_refl x =
SPTK.proj_point_to_list_lemma x
//-----------------
inline_for_extraction noextract
let proj_g_pow2_64 : S.proj_point =
[@inline_let]
let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in
[@inline_let]
let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in
[@inline_let]
let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in
(rX, rY, rZ)
val lemma_proj_g_pow2_64_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64)
let lemma_proj_g_pow2_64_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64);
let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in
let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in
let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
inline_for_extraction noextract
let proj_g_pow2_128 : S.proj_point =
[@inline_let]
let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in
[@inline_let]
let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in
[@inline_let]
let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in
(rX, rY, rZ)
val lemma_proj_g_pow2_128_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
let lemma_proj_g_pow2_128_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64);
let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in
let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in
let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
inline_for_extraction noextract
let proj_g_pow2_192 : S.proj_point =
[@inline_let]
let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in
[@inline_let]
let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in
[@inline_let]
let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in
(rX, rY, rZ)
val lemma_proj_g_pow2_192_eval : unit ->
Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
let lemma_proj_g_pow2_192_eval () =
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64;
let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in
normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64);
let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in
let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in
let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in
assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
// let proj_g_pow2_64 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64)
// let proj_g_pow2_128 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64)
// let proj_g_pow2_192 : S.proj_point =
// normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64)
inline_for_extraction noextract
let proj_g_pow2_64_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
inline_for_extraction noextract
let proj_g_pow2_128_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
inline_for_extraction noextract
let proj_g_pow2_192_list : SPTK.point_list =
normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64);
Seq.seq_of_list proj_g_pow2_64_list
let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128);
Seq.seq_of_list proj_g_pow2_128_list
let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192);
Seq.seq_of_list proj_g_pow2_192_list
val proj_g_pow2_64_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
let proj_g_pow2_64_lemma () =
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_128_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
let proj_g_pow2_128_lemma () =
lemma_proj_g_pow2_128_eval ();
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_192_lemma: unit ->
Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
let proj_g_pow2_192_lemma () =
lemma_proj_g_pow2_192_eval ();
lemma_proj_g_pow2_128_eval ();
lemma_proj_g_pow2_64_eval ();
SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point
let proj_g_pow2_64_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64);
proj_g_pow2_64_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_64
let proj_g_pow2_128_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128);
proj_g_pow2_128_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_128
let proj_g_pow2_192_lseq_lemma () =
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192);
proj_g_pow2_192_lemma ();
SPTK.proj_point_to_list_lemma proj_g_pow2_192
let mk_proj_g_pow2_64 () =
createL proj_g_pow2_64_list
let mk_proj_g_pow2_128 () =
createL proj_g_pow2_128_list
let mk_proj_g_pow2_192 () =
createL proj_g_pow2_192_list
//----------------
/// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G]
inline_for_extraction noextract
let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15)
let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15);
Seq.seq_of_list precomp_basepoint_table_list_w4
let precomp_basepoint_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4
let precomp_basepoint_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} =
createL_global precomp_basepoint_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)]
inline_for_extraction noextract
let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15)
let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15);
Seq.seq_of_list precomp_g_pow2_64_table_list_w4
let precomp_g_pow2_64_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table
proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_64_lemma ()
let precomp_g_pow2_64_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_64_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)]
inline_for_extraction noextract
let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15)
let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15);
Seq.seq_of_list precomp_g_pow2_128_table_list_w4
let precomp_g_pow2_128_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table
proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_128_lemma ()
let precomp_g_pow2_128_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_128_table_list_w4
/// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)]
inline_for_extraction noextract
let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15)
let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15);
Seq.seq_of_list precomp_g_pow2_192_table_list_w4
let precomp_g_pow2_192_table_lemma_w4 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table
proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4;
proj_g_pow2_192_lemma ()
let precomp_g_pow2_192_table_w4:
x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} =
createL_global precomp_g_pow2_192_table_list_w4
/// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G]
inline_for_extraction noextract
let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 384} =
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31)
let precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 384 =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31);
Seq.seq_of_list precomp_basepoint_table_list_w5
let precomp_basepoint_table_lemma_w5 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31);
SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 32 precomp_basepoint_table_lseq_w5 | {
"checked_file": "/",
"dependencies": [
"Spec.P256.Lemmas.fsti.checked",
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable256.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.PrecompTable.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.P256.PrecompTable.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
Lib.Buffer.glbuffer Lib.IntTypes.uint64 384ul
{ Lib.Buffer.witnessed x Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5 /\
Lib.Buffer.recallable x } | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.P256.PrecompTable.precomp_basepoint_table_list_w5",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.l_and",
"Lib.Buffer.witnessed",
"Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5",
"Lib.Buffer.recallable",
"Lib.Buffer.CONST"
] | [] | false | false | false | false | false | let precomp_basepoint_table_w5:x:
glbuffer uint64 384ul {witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x} =
| createL_global precomp_basepoint_table_list_w5 | false |
Vale.Curve25519.FastHybrid_helpers.fsti | Vale.Curve25519.FastHybrid_helpers.lemma_mul_pow256_add | val lemma_mul_pow256_add (x y: nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime) | val lemma_mul_pow256_add (x y: nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime) | let lemma_mul_pow256_add (x y:nat) :
Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime)
=
assert_norm (pow2_256 % prime == 38);
() | {
"file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastHybrid_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 21,
"start_col": 0,
"start_line": 17
} | module Vale.Curve25519.FastHybrid_helpers
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Mul
open FStar.Tactics
open FStar.Tactics.CanonCommSemiring
open Vale.Curve25519.Fast_defs
open FStar.Calc
let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring () //; dump "Final"
unfold let pow2_63:nat = 0x8000000000000000
let _ = assert_norm (pow2_63 == pow2 63) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.Fast_defs.fst.checked",
"prims.fst.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Curve25519.FastHybrid_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommSemiring",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.nat -> y: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
(x + y * Vale.Curve25519.Fast_defs.pow2_256) % Vale.Curve25519.Fast_defs.prime ==
(x + y * 38) % Vale.Curve25519.Fast_defs.prime) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Vale.Curve25519.Fast_defs.pow2_256",
"Vale.Curve25519.Fast_defs.prime",
"Prims.l_True",
"Prims.squash",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_mul_pow256_add (x y: nat) : Lemma ((x + y * pow2_256) % prime == (x + y * 38) % prime) =
| assert_norm (pow2_256 % prime == 38);
() | false |
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.lowstar_poly_t | val lowstar_poly_t : Type0 | let lowstar_poly_t =
IX64.as_lowstar_sig_t_weak_stdcall
code_poly
dom
[]
_
_
(W.mk_prediction code_poly dom [] (poly_lemma code_poly IA.win)) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 122,
"start_col": 0,
"start_line": 115
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64; tuint64] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state) ->
PO.va_req_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_post : VSig.vale_post dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
PO.va_ens_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
va_s1 f
module VS = Vale.X64.State
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let poly_lemma'
(code:V.va_code)
(_win:bool)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
poly_pre code ctx_b inp_b len finish va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
poly_post code ctx_b inp_b len finish va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer ctx_b) /\
ME.buffer_writeable (as_vale_buffer inp_b)
)) =
let va_s1, f = PO.va_lemma_Poly1305 code va_s0 IA.win (as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 ctx_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 inp_b;
va_s1, f
(* Prove that poly_lemma' has the required type *)
noextract
let poly_lemma = as_t #(VSig.vale_sig_stdcall poly_pre poly_post) poly_lemma'
noextract
let code_poly = PO.va_code_Poly1305 IA.win
(* Here's the type expected for the poly wrapper *) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall",
"Vale.Stdcalls.X64.Poly.code_poly",
"Vale.Stdcalls.X64.Poly.dom",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Vale.Stdcalls.X64.Poly.poly_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.Poly.poly_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.Poly.poly_lemma",
"Vale.Interop.Assumptions.win"
] | [] | false | false | false | true | true | let lowstar_poly_t =
| IX64.as_lowstar_sig_t_weak_stdcall code_poly
dom
[]
_
_
(W.mk_prediction code_poly dom [] (poly_lemma code_poly IA.win)) | false |
|
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.poly_lemma | val poly_lemma : Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Poly.poly_pre
Vale.Stdcalls.X64.Poly.poly_post | let poly_lemma = as_t #(VSig.vale_sig_stdcall poly_pre poly_post) poly_lemma' | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 77,
"end_line": 109,
"start_col": 0,
"start_line": 109
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64; tuint64] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state) ->
PO.va_req_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_post : VSig.vale_post dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
PO.va_ens_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
va_s1 f
module VS = Vale.X64.State
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let poly_lemma'
(code:V.va_code)
(_win:bool)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
poly_pre code ctx_b inp_b len finish va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
poly_post code ctx_b inp_b len finish va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer ctx_b) /\
ME.buffer_writeable (as_vale_buffer inp_b)
)) =
let va_s1, f = PO.va_lemma_Poly1305 code va_s0 IA.win (as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 ctx_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 inp_b;
va_s1, f
(* Prove that poly_lemma' has the required type *) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.AsLowStar.ValeSig.vale_sig_stdcall Vale.Stdcalls.X64.Poly.poly_pre
Vale.Stdcalls.X64.Poly.poly_post | Prims.Tot | [
"total"
] | [] | [
"Vale.Stdcalls.X64.Poly.as_t",
"Vale.AsLowStar.ValeSig.vale_sig_stdcall",
"Vale.Stdcalls.X64.Poly.dom",
"Vale.Stdcalls.X64.Poly.poly_pre",
"Vale.Stdcalls.X64.Poly.poly_post",
"Vale.Stdcalls.X64.Poly.poly_lemma'"
] | [] | false | false | false | true | false | let poly_lemma =
| as_t #(VSig.vale_sig_stdcall poly_pre poly_post) poly_lemma' | false |
|
Vale.Stdcalls.X64.Poly.fsti | Vale.Stdcalls.X64.Poly.poly_lemma' | val poly_lemma'
(code: V.va_code)
(_win: bool)
(ctx_b inp_b: b64)
(len finish: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires poly_pre code ctx_b inp_b len finish va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
poly_post code ctx_b inp_b len finish va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer ctx_b) /\ ME.buffer_writeable (as_vale_buffer inp_b)
)) | val poly_lemma'
(code: V.va_code)
(_win: bool)
(ctx_b inp_b: b64)
(len finish: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires poly_pre code ctx_b inp_b len finish va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
poly_post code ctx_b inp_b len finish va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer ctx_b) /\ ME.buffer_writeable (as_vale_buffer inp_b)
)) | let poly_lemma'
(code:V.va_code)
(_win:bool)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
poly_pre code ctx_b inp_b len finish va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
poly_post code ctx_b inp_b len finish va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer ctx_b) /\
ME.buffer_writeable (as_vale_buffer inp_b)
)) =
let va_s1, f = PO.va_lemma_Poly1305 code va_s0 IA.win (as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 ctx_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 inp_b;
va_s1, f | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Poly.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 105,
"start_col": 0,
"start_line": 84
} | module Vale.Stdcalls.X64.Poly
open FStar.Mul
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PO = Vale.Poly1305.X64
open Vale.Poly1305.Math
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b64 = buf_t TUInt8 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt8 TUInt64 ({modified=true; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt8 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Public})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64; tuint64] in
assert_norm (List.length y = 4);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state) ->
PO.va_req_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let poly_post : VSig.vale_post dom =
fun (c:V.va_code)
(ctx_b:b64)
(inp_b:b64)
(len:uint64)
(finish:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
PO.va_ens_Poly1305 c va_s0 IA.win
(as_vale_buffer ctx_b) (as_vale_buffer inp_b) (UInt64.v len) (UInt64.v finish)
va_s1 f
module VS = Vale.X64.State
#set-options "--z3rlimit 20" | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Poly1305.X64.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Poly.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Poly1305.X64",
"short_module": "PO"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
code: Vale.X64.Decls.va_code ->
_win: Prims.bool ->
ctx_b: Vale.Stdcalls.X64.Poly.b64 ->
inp_b: Vale.Stdcalls.X64.Poly.b64 ->
len: Vale.Stdcalls.X64.Poly.uint64 ->
finish: Vale.Stdcalls.X64.Poly.uint64 ->
va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Prims.bool",
"Vale.Stdcalls.X64.Poly.b64",
"Vale.Stdcalls.X64.Poly.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt64",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.Poly1305.X64.va_lemma_Poly1305",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"FStar.UInt64.v",
"Vale.Stdcalls.X64.Poly.poly_pre",
"Prims.l_and",
"Vale.X64.Decls.eval_code",
"Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall",
"Vale.Stdcalls.X64.Poly.poly_post",
"Vale.X64.Memory.buffer_writeable"
] | [] | false | false | false | false | false | let poly_lemma'
(code: V.va_code)
(_win: bool)
(ctx_b inp_b: b64)
(len finish: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires poly_pre code ctx_b inp_b len finish va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
poly_post code ctx_b inp_b len finish va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer ctx_b) /\ ME.buffer_writeable (as_vale_buffer inp_b)
)) =
| let va_s1, f =
PO.va_lemma_Poly1305 code
va_s0
IA.win
(as_vale_buffer ctx_b)
(as_vale_buffer inp_b)
(UInt64.v len)
(UInt64.v finish)
in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 ctx_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt64 inp_b;
va_s1, f | false |
Hacl.Impl.Frodo.Gen.fst | Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x | val frodo_gen_matrix_shake_4x:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed)) | val frodo_gen_matrix_shake_4x:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed)) | let frodo_gen_matrix_shake_4x n seed res =
push_frame ();
let r = create (size 8 *! n) (u8 0) in
let tmp_seed = create 72ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
copy (sub tmp_seed 20ul 16ul) seed;
copy (sub tmp_seed 38ul 16ul) seed;
copy (sub tmp_seed 56ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
assert (tmp_seed4_pre h0 tmp_seed);
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake_4x1 (v n) (as_seq h0 seed) in
[@ inline_let]
let inv h (i:nat{i <= v n / 4}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
tmp_seed4_pre h tmp_seed /\
as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res) in
Loops.eq_repeati0 (v n / 4) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul (n /. 4ul) inv
(fun i ->
Loops.unfold_repeati (v n / 4) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake_4x1 n tmp_seed r i res);
let h1 = ST.get () in
assert (as_matrix h1 res == S.frodo_gen_matrix_shake_4x (v n) (as_seq h0 seed));
S.frodo_gen_matrix_shake_4x_lemma (v n) (as_seq h0 seed);
pop_frame () | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Gen.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 281,
"start_col": 0,
"start_line": 249
} | module Hacl.Impl.Frodo.Gen
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module Loops = Lib.LoopCombinators
module S = Spec.Frodo.Gen
module Lemmas = Spec.Frodo.Lemmas
module SHA3 = Hacl.SHA3
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract private
val frodo_gen_matrix_shake0:
n:size_t{v n * v n <= max_size_t /\ 2 * v n <= max_size_t}
-> i:size_t{v i < v n}
-> r:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> live h r /\ live h res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake0 n i r j res =
let resij = sub r (size 2 *! j) (size 2) in
mset res i j (uint_from_bytes_le resij)
inline_for_extraction noextract private
val concat_ind_seed:
tmp_seed:lbytes 18ul
-> i:size_t{v i < maxint U16}
-> Stack unit
(requires fun h -> live h tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc tmp_seed) h0 h1 /\
as_seq h1 tmp_seed == LSeq.concat (BSeq.uint_to_bytes_le (u16 (v i))) (LSeq.sub (as_seq h0 tmp_seed) 2 16) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let concat_ind_seed tmp_seed i =
let h0 = ST.get () in
update_sub_f h0 tmp_seed 0ul 2ul
(fun h -> BSeq.uint_to_bytes_le (to_u16 i))
(fun _ -> uint_to_bytes_le (sub tmp_seed 0ul 2ul) (to_u16 i));
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 tmp_seed)
(LSeq.concat (BSeq.uint_to_bytes_le (to_u16 i)) (LSeq.sub (as_seq h0 tmp_seed) 2 16));
LSeq.eq_intro (LSeq.sub (as_seq h0 tmp_seed) 2 16) (LSeq.sub (as_seq h1 tmp_seed) 2 16)
inline_for_extraction noextract private
val frodo_gen_matrix_shake1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes 18ul
-> r:lbytes (size 2 *! n)
-> i:size_t{v i < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16)
let frodo_gen_matrix_shake1 n tmp_seed r i res =
concat_ind_seed tmp_seed i;
SHA3.shake128_hacl 18ul tmp_seed (2ul *! n) r;
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake0 (v n) (v i) (as_seq h0 r) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake0 n i r j res
)
val frodo_gen_matrix_shake:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed))
[@"c_inline"]
let frodo_gen_matrix_shake n seed res =
push_frame ();
let r = create (size 2 *! n) (u8 0) in
let tmp_seed = create 18ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@ inline_let]
let spec h0 = S.frodo_gen_matrix_shake1 (v n) (as_seq h0 seed) in
[@ inline_let]
let inv h (i:nat{i <= v n}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res) in
Loops.eq_repeati0 (v n) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul n inv
(fun i ->
Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake1 n tmp_seed r i res);
pop_frame ()
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x0:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> i:size_t{v i < v n / 4}
-> r0:lbytes (size 2 *! n)
-> r1:lbytes (size 2 *! n)
-> r2:lbytes (size 2 *! n)
-> r3:lbytes (size 2 *! n)
-> j:size_t{v j < v n}
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h r0 /\ live h r1 /\ live h r2 /\
live h r3 /\ live h res /\
B.loc_pairwise_disjoint [loc res; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x0 (v n) (v i) (as_seq h0 r0) (as_seq h0 r1)
(as_seq h0 r2) (as_seq h0 r3) (v j) (as_matrix h0 res))
let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res =
let resij0 = sub r0 (j *! size 2) (size 2) in
let resij1 = sub r1 (j *! size 2) (size 2) in
let resij2 = sub r2 (j *! size 2) (size 2) in
let resij3 = sub r3 (j *! size 2) (size 2) in
mset res (size 4 *! i +! size 0) j (uint_from_bytes_le resij0);
mset res (size 4 *! i +! size 1) j (uint_from_bytes_le resij1);
mset res (size 4 *! i +! size 2) j (uint_from_bytes_le resij2);
mset res (size 4 *! i +! size 3) j (uint_from_bytes_le resij3)
val tmp_seed4_pre: h:mem -> tmp_seed:lbytes (18ul *! 4ul) -> Type0
let tmp_seed4_pre h tmp_seed =
let seed0 = LSeq.sub (as_seq h tmp_seed) 2 16 in
let seed1 = LSeq.sub (as_seq h tmp_seed) 20 16 in
let seed2 = LSeq.sub (as_seq h tmp_seed) 38 16 in
let seed3 = LSeq.sub (as_seq h tmp_seed) 56 16 in
seed0 == seed1 /\ seed0 == seed2 /\ seed0 == seed3
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x1_get_r:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r0:lbytes (2ul *! n)
-> r1:lbytes (2ul *! n)
-> r2:lbytes (2ul *! n)
-> r3:lbytes (2ul *! n)
-> i:size_t{v i < v n / 4}
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h r0 /\ live h r1 /\ live h r2 /\ live h r3 /\
loc_pairwise_disjoint [loc tmp_seed; loc r0; loc r1; loc r2; loc r3])
(ensures fun h0 _ h1 -> modifies (loc r0 |+| loc r1 |+| loc r2 |+| loc r3 |+| loc tmp_seed) h0 h1 /\
(as_seq h1 r0, as_seq h1 r1, as_seq h1 r2, as_seq h1 r3) ==
S.frodo_gen_matrix_shake_4x1_get_r (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed)
let frodo_gen_matrix_shake_4x1_get_r n tmp_seed r0 r1 r2 r3 i =
let tmp_seed0 = sub tmp_seed 0ul 18ul in
let tmp_seed1 = sub tmp_seed 18ul 18ul in
let tmp_seed2 = sub tmp_seed 36ul 18ul in
let tmp_seed3 = sub tmp_seed 54ul 18ul in
concat_ind_seed tmp_seed0 (4ul *! i +! 0ul);
concat_ind_seed tmp_seed1 (4ul *! i +! 1ul);
concat_ind_seed tmp_seed2 (4ul *! i +! 2ul);
concat_ind_seed tmp_seed3 (4ul *! i +! 3ul);
Hacl.Keccak.shake128_4x 18ul tmp_seed0 tmp_seed1 tmp_seed2 tmp_seed3 (size 2 *! n) r0 r1 r2 r3
inline_for_extraction noextract private
val frodo_gen_matrix_shake_4x1:
n:size_t{v n * v n <= max_size_t /\ v n <= maxint U16}
-> tmp_seed:lbytes (18ul *! 4ul)
-> r:lbytes (size 8 *! n)
-> i:size_t{v i < v n / 4}
-> res:matrix_t n n
-> Stack unit
(requires fun h -> tmp_seed4_pre h tmp_seed /\
live h tmp_seed /\ live h res /\ live h r /\
disjoint res tmp_seed /\ disjoint res r /\ disjoint r tmp_seed)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc r |+| loc tmp_seed) h0 h1 /\
as_matrix h1 res ==
S.frodo_gen_matrix_shake_4x1 (v n) (LSeq.sub (as_seq h0 tmp_seed) 2 16) (v i) (as_matrix h0 res) /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h1 tmp_seed) 2 16 /\ tmp_seed4_pre h1 tmp_seed)
let frodo_gen_matrix_shake_4x1 n tmp_seed r i res =
let r0 = sub r (size 0 *! n) (size 2 *! n) in
let r1 = sub r (size 2 *! n) (size 2 *! n) in
let r2 = sub r (size 4 *! n) (size 2 *! n) in
let r3 = sub r (size 6 *! n) (size 2 *! n) in
frodo_gen_matrix_shake_4x1_get_r n tmp_seed r0 r1 r2 r3 i;
[@inline_let]
let spec h0 = S.frodo_gen_matrix_shake_4x0 (v n) (v i)
(as_seq h0 r0) (as_seq h0 r1) (as_seq h0 r2) (as_seq h0 r3) in
let h0 = ST.get () in
loop1 h0 n res spec
(fun j ->
Loops.unfold_repeati (v n) (spec h0) (as_matrix h0 res) (v j);
frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res
)
val frodo_gen_matrix_shake_4x:
n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbytes 16ul
-> res:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h res /\ disjoint seed res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_matrix h1 res == S.frodo_gen_matrix_shake (v n) (as_seq h0 seed)) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"Spec.Frodo.Gen.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Keccak.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.AES128.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Gen.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.SHA3",
"short_module": "SHA3"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Gen",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v n /\ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\
Lib.IntTypes.v n <= Lib.IntTypes.maxint Lib.IntTypes.U16 /\ Lib.IntTypes.v n % 4 = 0 } ->
seed: Hacl.Impl.Matrix.lbytes 16ul ->
res: Hacl.Impl.Matrix.matrix_t n n
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.maxint",
"Lib.IntTypes.U16",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Hacl.Impl.Matrix.lbytes",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Matrix.matrix_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Spec.Frodo.Gen.frodo_gen_matrix_shake_4x_lemma",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Prims._assert",
"Prims.eq2",
"Spec.Matrix.matrix",
"Hacl.Impl.Matrix.as_matrix",
"Spec.Frodo.Gen.frodo_gen_matrix_shake_4x",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Loops.for",
"Lib.IntTypes.op_Slash_Dot",
"Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x1",
"Lib.LoopCombinators.unfold_repeati",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Prims.op_Division",
"Hacl.Impl.Matrix.elem",
"Lib.IntTypes.op_Star_Bang",
"Lib.LoopCombinators.eq_repeati0",
"Prims.nat",
"Prims.logical",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Prims.l_or",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.op_Addition",
"Prims.l_Forall",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub",
"Hacl.Impl.Frodo.Gen.tmp_seed4_pre",
"Lib.Sequence.seq",
"FStar.Seq.Base.length",
"Lib.LoopCombinators.repeati",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1",
"Lib.Sequence.eq_intro",
"Lib.Buffer.memset",
"Lib.IntTypes.u16",
"Lib.Buffer.copy",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.U8",
"FStar.UInt32.uint_to_t",
"Lib.Buffer.sub",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.mul",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.size",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let frodo_gen_matrix_shake_4x n seed res =
| push_frame ();
let r = create (size 8 *! n) (u8 0) in
let tmp_seed = create 72ul (u8 0) in
copy (sub tmp_seed 2ul 16ul) seed;
copy (sub tmp_seed 20ul 16ul) seed;
copy (sub tmp_seed 38ul 16ul) seed;
copy (sub tmp_seed 56ul 16ul) seed;
memset res (u16 0) (n *! n);
let h0 = ST.get () in
assert (tmp_seed4_pre h0 tmp_seed);
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v n * v n)) (as_seq h0 res);
[@@ inline_let ]let spec h0 = S.frodo_gen_matrix_shake_4x1 (v n) (as_seq h0 seed) in
[@@ inline_let ]let inv h (i: nat{i <= v n / 4}) =
modifies (loc res |+| loc r |+| loc tmp_seed) h0 h /\
LSeq.sub (as_seq h0 tmp_seed) 2 16 == LSeq.sub (as_seq h tmp_seed) 2 16 /\
tmp_seed4_pre h tmp_seed /\ as_seq h res == Loops.repeati i (spec h0) (as_seq h0 res)
in
Loops.eq_repeati0 (v n / 4) (spec h0) (as_seq h0 res);
Lib.Loops.for 0ul
(n /. 4ul)
inv
(fun i ->
Loops.unfold_repeati (v n / 4) (spec h0) (as_seq h0 res) (v i);
frodo_gen_matrix_shake_4x1 n tmp_seed r i res);
let h1 = ST.get () in
assert (as_matrix h1 res == S.frodo_gen_matrix_shake_4x (v n) (as_seq h0 seed));
S.frodo_gen_matrix_shake_4x_lemma (v n) (as_seq h0 seed);
pop_frame () | false |
Vale.Lib.Lists.fsti | Vale.Lib.Lists.from_list_be | val from_list_be (l: list bool) : int | val from_list_be (l: list bool) : int | let from_list_be (l:list bool) : int =
from_list_le (List.rev l) | {
"file_name": "vale/code/lib/collections/Vale.Lib.Lists.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 39,
"start_col": 0,
"start_line": 38
} | module Vale.Lib.Lists
open FStar.List.Tot
open FStar.Seq
open FStar.UInt
open FStar.Mul
module List = FStar.List.Tot
open FStar.List.Tot.Properties
val singleton_list_rev (#a:Type) (x:a) : Lemma
(List.rev [x] == [x])
val list_cons_is_append (#a:Type) (h:a) (t:list a) : Lemma
(h::t == [h] @ t)
val singleton_list_seq (#a:Type) (x:a) : Lemma
(seq_of_list [x] == create 1 x)
val list_append_length (#a:Type) (x y:list a) : Lemma
(List.length (x @ y) == List.length x + List.length y)
val list_append_index (#a:Type) (x y:list a) (i:nat) : Lemma
(requires i < List.length (x @ y))
(ensures (
let nx = List.length x in
(i >= nx ==> i - nx < List.length y) /\
List.index (x @ y) i == (if i < nx then List.index x i else List.index y (i - nx))
))
val append_list_seq (#a:Type) (x y:list a) : Lemma
(seq_of_list (x @ y) == append (seq_of_list x) (seq_of_list y))
let rec from_list_le (l:list bool) : int =
match l with
| [] -> 0
| h::t -> (if h then 1 else 0) + 2 * (from_list_le t) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.Properties.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Lib.Lists.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot.Properties",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.list Prims.bool -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Prims.bool",
"Vale.Lib.Lists.from_list_le",
"FStar.List.Tot.Base.rev",
"Prims.int"
] | [] | false | false | false | true | false | let from_list_be (l: list bool) : int =
| from_list_le (List.rev l) | false |
Vale.Lib.Lists.fsti | Vale.Lib.Lists.from_list_le | val from_list_le (l: list bool) : int | val from_list_le (l: list bool) : int | let rec from_list_le (l:list bool) : int =
match l with
| [] -> 0
| h::t -> (if h then 1 else 0) + 2 * (from_list_le t) | {
"file_name": "vale/code/lib/collections/Vale.Lib.Lists.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 36,
"start_col": 0,
"start_line": 33
} | module Vale.Lib.Lists
open FStar.List.Tot
open FStar.Seq
open FStar.UInt
open FStar.Mul
module List = FStar.List.Tot
open FStar.List.Tot.Properties
val singleton_list_rev (#a:Type) (x:a) : Lemma
(List.rev [x] == [x])
val list_cons_is_append (#a:Type) (h:a) (t:list a) : Lemma
(h::t == [h] @ t)
val singleton_list_seq (#a:Type) (x:a) : Lemma
(seq_of_list [x] == create 1 x)
val list_append_length (#a:Type) (x y:list a) : Lemma
(List.length (x @ y) == List.length x + List.length y)
val list_append_index (#a:Type) (x y:list a) (i:nat) : Lemma
(requires i < List.length (x @ y))
(ensures (
let nx = List.length x in
(i >= nx ==> i - nx < List.length y) /\
List.index (x @ y) i == (if i < nx then List.index x i else List.index y (i - nx))
))
val append_list_seq (#a:Type) (x y:list a) : Lemma
(seq_of_list (x @ y) == append (seq_of_list x) (seq_of_list y)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.Properties.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Lib.Lists.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot.Properties",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.list Prims.bool -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Prims.bool",
"Prims.op_Addition",
"Prims.int",
"FStar.Mul.op_Star",
"Vale.Lib.Lists.from_list_le"
] | [
"recursion"
] | false | false | false | true | false | let rec from_list_le (l: list bool) : int =
| match l with
| [] -> 0
| h :: t -> (if h then 1 else 0) + 2 * (from_list_le t) | false |
OPLSS2021.Vector.fst | OPLSS2021.Vector.nth | val nth (#a: _) (n: nat) (#m: nat{m > n}) (v: vector a m) : a | val nth (#a: _) (n: nat) (#m: nat{m > n}) (v: vector a m) : a | let rec nth #a (n:nat) (#m:nat{m > n}) (v:vector a m) : a =
let VCons x xs = v in // F* can prove that since m > n, m > 0, and so v <> VNil
if n = 0
then x
else nth (n-1) xs | {
"file_name": "examples/oplss2021/OPLSS2021.Vector.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 19,
"end_line": 27,
"start_col": 0,
"start_line": 23
} | module OPLSS2021.Vector
////////////////////////////////////////////////////////////////////////////////
// Vectors
////////////////////////////////////////////////////////////////////////////////
type vector (a:Type) : nat -> Type =
| VNil : vector a 0
| VCons : hd:a
-> #n:nat //implicit argument, you don't have to write it in applications or patterns
-> tl:vector a n
-> vector a (n + 1)
let head' (v:vector 'a 'n { (match v with VCons _ _ -> true | _ -> false) }) : 'a =
match v with
| VCons x xs -> x
//VCons? v is syntactic sugar for saying that v is in the VCons case
let head (v:vector 'a 'n { VCons? v }) : 'a =
match v with
| VCons x xs -> x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.Vector.fst"
} | [
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat -> v: OPLSS2021.Vector.vector a m -> a | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"OPLSS2021.Vector.vector",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"OPLSS2021.Vector.nth",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | false | false | false | false | let rec nth #a (n: nat) (#m: nat{m > n}) (v: vector a m) : a =
| let VCons x xs = v in
if n = 0 then x else nth (n - 1) xs | false |
OPLSS2021.Vector.fst | OPLSS2021.Vector.append | val append (#a #n1 #n2: _) (v1: vector a n1) (v2: vector a n2) : vector a (n1 + n2) | val append (#a #n1 #n2: _) (v1: vector a n1) (v2: vector a n2) : vector a (n1 + n2) | let rec append #a #n1 #n2 (v1:vector a n1) (v2:vector a n2)
: vector a (n1 + n2)
= match v1 with
| VNil -> v2
| VCons hd tl -> VCons hd (append tl v2) | {
"file_name": "examples/oplss2021/OPLSS2021.Vector.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 33,
"start_col": 0,
"start_line": 29
} | module OPLSS2021.Vector
////////////////////////////////////////////////////////////////////////////////
// Vectors
////////////////////////////////////////////////////////////////////////////////
type vector (a:Type) : nat -> Type =
| VNil : vector a 0
| VCons : hd:a
-> #n:nat //implicit argument, you don't have to write it in applications or patterns
-> tl:vector a n
-> vector a (n + 1)
let head' (v:vector 'a 'n { (match v with VCons _ _ -> true | _ -> false) }) : 'a =
match v with
| VCons x xs -> x
//VCons? v is syntactic sugar for saying that v is in the VCons case
let head (v:vector 'a 'n { VCons? v }) : 'a =
match v with
| VCons x xs -> x
let rec nth #a (n:nat) (#m:nat{m > n}) (v:vector a m) : a =
let VCons x xs = v in // F* can prove that since m > n, m > 0, and so v <> VNil
if n = 0
then x
else nth (n-1) xs | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.Vector.fst"
} | [
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v1: OPLSS2021.Vector.vector a n1 -> v2: OPLSS2021.Vector.vector a n2
-> OPLSS2021.Vector.vector a (n1 + n2) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"OPLSS2021.Vector.vector",
"OPLSS2021.Vector.VCons",
"Prims.op_Addition",
"OPLSS2021.Vector.append"
] | [
"recursion"
] | false | false | false | false | false | let rec append #a #n1 #n2 (v1: vector a n1) (v2: vector a n2) : vector a (n1 + n2) =
| match v1 with
| VNil -> v2
| VCons hd tl -> VCons hd (append tl v2) | false |
OPLSS2021.Vector.fst | OPLSS2021.Vector.fold_right | val fold_right (#a #b: _) (f: (a -> b -> b)) (#n: _) (v: vector a n) (acc: b) : b | val fold_right (#a #b: _) (f: (a -> b -> b)) (#n: _) (v: vector a n) (acc: b) : b | let rec fold_right #a #b (f: a -> b -> b) #n (v:vector a n) (acc: b)
: b
= match v with
| VNil -> acc
| VCons hd tl -> f hd (fold_right f tl acc) | {
"file_name": "examples/oplss2021/OPLSS2021.Vector.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 47,
"end_line": 51,
"start_col": 0,
"start_line": 47
} | module OPLSS2021.Vector
////////////////////////////////////////////////////////////////////////////////
// Vectors
////////////////////////////////////////////////////////////////////////////////
type vector (a:Type) : nat -> Type =
| VNil : vector a 0
| VCons : hd:a
-> #n:nat //implicit argument, you don't have to write it in applications or patterns
-> tl:vector a n
-> vector a (n + 1)
let head' (v:vector 'a 'n { (match v with VCons _ _ -> true | _ -> false) }) : 'a =
match v with
| VCons x xs -> x
//VCons? v is syntactic sugar for saying that v is in the VCons case
let head (v:vector 'a 'n { VCons? v }) : 'a =
match v with
| VCons x xs -> x
let rec nth #a (n:nat) (#m:nat{m > n}) (v:vector a m) : a =
let VCons x xs = v in // F* can prove that since m > n, m > 0, and so v <> VNil
if n = 0
then x
else nth (n-1) xs
let rec append #a #n1 #n2 (v1:vector a n1) (v2:vector a n2)
: vector a (n1 + n2)
= match v1 with
| VNil -> v2
| VCons hd tl -> VCons hd (append tl v2)
let rec reverse #a #n (v:vector a n)
: vector a n
= match v with
| VNil -> VNil
| VCons hd tl -> append (reverse tl) (VCons hd VNil)
let rec map #a #b (f:a -> b) #n (v:vector a n)
: vector b n
= match v with
| VNil -> VNil
| VCons hd tl -> VCons (f hd) (map f tl) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.Vector.fst"
} | [
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: (_: a -> _: b -> b) -> v: OPLSS2021.Vector.vector a n -> acc: b -> b | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"OPLSS2021.Vector.vector",
"OPLSS2021.Vector.fold_right"
] | [
"recursion"
] | false | false | false | false | false | let rec fold_right #a #b (f: (a -> b -> b)) #n (v: vector a n) (acc: b) : b =
| match v with
| VNil -> acc
| VCons hd tl -> f hd (fold_right f tl acc) | false |
OPLSS2021.Vector.fst | OPLSS2021.Vector.reverse | val reverse (#a #n: _) (v: vector a n) : vector a n | val reverse (#a #n: _) (v: vector a n) : vector a n | let rec reverse #a #n (v:vector a n)
: vector a n
= match v with
| VNil -> VNil
| VCons hd tl -> append (reverse tl) (VCons hd VNil) | {
"file_name": "examples/oplss2021/OPLSS2021.Vector.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 56,
"end_line": 39,
"start_col": 0,
"start_line": 35
} | module OPLSS2021.Vector
////////////////////////////////////////////////////////////////////////////////
// Vectors
////////////////////////////////////////////////////////////////////////////////
type vector (a:Type) : nat -> Type =
| VNil : vector a 0
| VCons : hd:a
-> #n:nat //implicit argument, you don't have to write it in applications or patterns
-> tl:vector a n
-> vector a (n + 1)
let head' (v:vector 'a 'n { (match v with VCons _ _ -> true | _ -> false) }) : 'a =
match v with
| VCons x xs -> x
//VCons? v is syntactic sugar for saying that v is in the VCons case
let head (v:vector 'a 'n { VCons? v }) : 'a =
match v with
| VCons x xs -> x
let rec nth #a (n:nat) (#m:nat{m > n}) (v:vector a m) : a =
let VCons x xs = v in // F* can prove that since m > n, m > 0, and so v <> VNil
if n = 0
then x
else nth (n-1) xs
let rec append #a #n1 #n2 (v1:vector a n1) (v2:vector a n2)
: vector a (n1 + n2)
= match v1 with
| VNil -> v2
| VCons hd tl -> VCons hd (append tl v2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.Vector.fst"
} | [
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: OPLSS2021.Vector.vector a n -> OPLSS2021.Vector.vector a n | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"OPLSS2021.Vector.vector",
"OPLSS2021.Vector.VNil",
"OPLSS2021.Vector.append",
"OPLSS2021.Vector.reverse",
"OPLSS2021.Vector.VCons"
] | [
"recursion"
] | false | false | false | false | false | let rec reverse #a #n (v: vector a n) : vector a n =
| match v with
| VNil -> VNil
| VCons hd tl -> append (reverse tl) (VCons hd VNil) | false |
OPLSS2021.Vector.fst | OPLSS2021.Vector.map | val map (#a #b: _) (f: (a -> b)) (#n: _) (v: vector a n) : vector b n | val map (#a #b: _) (f: (a -> b)) (#n: _) (v: vector a n) : vector b n | let rec map #a #b (f:a -> b) #n (v:vector a n)
: vector b n
= match v with
| VNil -> VNil
| VCons hd tl -> VCons (f hd) (map f tl) | {
"file_name": "examples/oplss2021/OPLSS2021.Vector.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 45,
"start_col": 0,
"start_line": 41
} | module OPLSS2021.Vector
////////////////////////////////////////////////////////////////////////////////
// Vectors
////////////////////////////////////////////////////////////////////////////////
type vector (a:Type) : nat -> Type =
| VNil : vector a 0
| VCons : hd:a
-> #n:nat //implicit argument, you don't have to write it in applications or patterns
-> tl:vector a n
-> vector a (n + 1)
let head' (v:vector 'a 'n { (match v with VCons _ _ -> true | _ -> false) }) : 'a =
match v with
| VCons x xs -> x
//VCons? v is syntactic sugar for saying that v is in the VCons case
let head (v:vector 'a 'n { VCons? v }) : 'a =
match v with
| VCons x xs -> x
let rec nth #a (n:nat) (#m:nat{m > n}) (v:vector a m) : a =
let VCons x xs = v in // F* can prove that since m > n, m > 0, and so v <> VNil
if n = 0
then x
else nth (n-1) xs
let rec append #a #n1 #n2 (v1:vector a n1) (v2:vector a n2)
: vector a (n1 + n2)
= match v1 with
| VNil -> v2
| VCons hd tl -> VCons hd (append tl v2)
let rec reverse #a #n (v:vector a n)
: vector a n
= match v with
| VNil -> VNil
| VCons hd tl -> append (reverse tl) (VCons hd VNil) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.Vector.fst"
} | [
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: (_: a -> b) -> v: OPLSS2021.Vector.vector a n -> OPLSS2021.Vector.vector b n | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"OPLSS2021.Vector.vector",
"OPLSS2021.Vector.VNil",
"OPLSS2021.Vector.VCons",
"OPLSS2021.Vector.map"
] | [
"recursion"
] | false | false | false | false | false | let rec map #a #b (f: (a -> b)) #n (v: vector a n) : vector b n =
| match v with
| VNil -> VNil
| VCons hd tl -> VCons (f hd) (map f tl) | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.aff_point_inv_seq | val aff_point_inv_seq : p: Hacl.Impl.P256.Point.aff_point_seq -> Prims.logical | let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 34,
"start_col": 0,
"start_line": 32
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.aff_point_seq -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.P256.Point.aff_point_seq",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Prims.logical",
"FStar.Pervasives.Native.tuple2",
"Hacl.Impl.P256.Point.as_aff_point_nat_seq"
] | [] | false | false | false | true | true | let aff_point_inv_seq (p: aff_point_seq) =
| let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.aff_point | val aff_point : Type0 | let aff_point = lbuffer uint64 8ul | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 38,
"start_col": 0,
"start_line": 38
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | true | let aff_point =
| lbuffer uint64 8ul | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.as_aff_point_nat | val as_aff_point_nat : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point
-> Prims.GTot (Prims.nat * Prims.nat) | let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 42,
"start_col": 0,
"start_line": 41
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point
-> Prims.GTot (Prims.nat * Prims.nat) | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Impl.P256.Point.as_aff_point_nat_seq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.tuple2",
"Prims.nat"
] | [] | false | false | false | false | false | let as_aff_point_nat (h: mem) (p: aff_point) =
| as_aff_point_nat_seq (as_seq h p) | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.aff_point_inv | val aff_point_inv : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.logical | let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 46,
"start_col": 0,
"start_line": 45
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Impl.P256.Point.aff_point_inv_seq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.logical"
] | [] | false | false | false | true | true | let aff_point_inv (h: mem) (p: aff_point) =
| aff_point_inv_seq (as_seq h p) | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.point_inv | val point_inv : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point -> Prims.logical | let point_inv (h:mem) (p:point) =
point_inv_seq (as_seq h p) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 93,
"start_col": 0,
"start_line": 92
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4)
let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime
inline_for_extraction noextract
let point = lbuffer uint64 12ul
noextract
let as_point_nat (h:mem) (p:point) =
as_point_nat_seq (as_seq h p) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Point.point_inv_seq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.logical"
] | [] | false | false | false | true | true | let point_inv (h: mem) (p: point) =
| point_inv_seq (as_seq h p) | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.point_inv_seq | val point_inv_seq : p: Hacl.Impl.P256.Point.point_seq -> Prims.logical | let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 81,
"start_col": 0,
"start_line": 79
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.point_seq -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.P256.Point.point_seq",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Prims.logical",
"FStar.Pervasives.Native.tuple3",
"Hacl.Impl.P256.Point.as_point_nat_seq"
] | [] | false | false | false | true | true | let point_inv_seq (p: point_seq) =
| let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.as_point_nat | val as_point_nat : h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point
-> Prims.GTot ((Prims.nat * Prims.nat) * Prims.nat) | let as_point_nat (h:mem) (p:point) =
as_point_nat_seq (as_seq h p) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 89,
"start_col": 0,
"start_line": 88
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4)
let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime
inline_for_extraction noextract
let point = lbuffer uint64 12ul | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point
-> Prims.GTot ((Prims.nat * Prims.nat) * Prims.nat) | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Point.as_point_nat_seq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.tuple3",
"Prims.nat"
] | [] | false | false | false | false | false | let as_point_nat (h: mem) (p: point) =
| as_point_nat_seq (as_seq h p) | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.point | val point : Type0 | let point = lbuffer uint64 12ul | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 85,
"start_col": 0,
"start_line": 85
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4)
let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | true | let point =
| lbuffer uint64 12ul | false |
|
Pulse.C.Types.Union.fsti | Pulse.C.Types.Union.union_t | val union_t
(#tf: Type0)
(n: string)
(#tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot Type0 | val union_t
(#tf: Type0)
(n: string)
(#tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot Type0 | let union_t (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= union_t0 tn #tf n fields | {
"file_name": "share/steel/examples/pulse/lib/c/Pulse.C.Types.Union.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 26,
"end_line": 17,
"start_col": 0,
"start_line": 16
} | module Pulse.C.Types.Union
open Pulse.Lib.Pervasives
include Pulse.C.Types.Fields
open Pulse.C.Typestring
[@@noextract_to "krml"] // primitive
val define_union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let define_union (n: string) (#tf: Type0) (#tn: Type0) (#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= define_union0 tn #tf n fields
// To be extracted as: union t
[@@noextract_to "krml"] // primitive
val union_t0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0 | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.Pervasives.fst.checked",
"Pulse.C.Typestring.fsti.checked",
"Pulse.C.Types.Fields.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.C.Types.Union.fsti"
} | [
{
"abbrev": false,
"full_module": "Pulse.C.Typestring",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.string -> fields: Pulse.C.Types.Fields.field_description_t tf -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.squash",
"FStar.Pervasives.norm",
"Pulse.C.Typestring.norm_typestring",
"Prims.eq2",
"Pulse.C.Typestring.mk_string_t",
"Pulse.C.Types.Fields.field_description_t",
"Pulse.C.Types.Union.union_t0"
] | [] | false | false | false | false | true | let union_t
(#tf: Type0)
(n: string)
(#tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot Type0 =
| union_t0 tn #tf n fields | false |
Pulse.C.Types.Union.fsti | Pulse.C.Types.Union.union | val union
(#tf: Type0)
(n: string)
(#tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot (typedef (union_t0 tn n fields)) | val union
(#tf: Type0)
(n: string)
(#tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot (typedef (union_t0 tn n fields)) | let union (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
= union0 tn #tf n fields | {
"file_name": "share/steel/examples/pulse/lib/c/Pulse.C.Types.Union.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 24,
"end_line": 79,
"start_col": 0,
"start_line": 78
} | module Pulse.C.Types.Union
open Pulse.Lib.Pervasives
include Pulse.C.Types.Fields
open Pulse.C.Typestring
[@@noextract_to "krml"] // primitive
val define_union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let define_union (n: string) (#tf: Type0) (#tn: Type0) (#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= define_union0 tn #tf n fields
// To be extracted as: union t
[@@noextract_to "krml"] // primitive
val union_t0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let union_t (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= union_t0 tn #tf n fields
val union_set_field (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) (f: field_t fields) (v: fields.fd_type f) : GTot (union_t0 tn n fields)
val union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
: GTot (option (field_t fields))
val union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
(field: field_t fields)
: Ghost (fields.fd_type field)
(requires (union_get_case u == Some field))
(ensures (fun _ -> True))
val union_get_field_same
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (~ (v == unknown (fields.fd_typedef field))))
(ensures (
let u = union_set_field tn n fields field v in
union_get_case u == Some field /\
union_get_field u field == v
))
[SMTPatOr [
[SMTPat (union_get_case (union_set_field tn n fields field v))];
[SMTPat (union_get_field (union_set_field tn n fields field v) field)];
]]
val union_set_field_same
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
union_set_field tn n fields field (union_get_field s field) == s
))
[SMTPat (union_set_field tn n fields (union_get_field s field))]
[@@noextract_to "krml"] // proof-only
val union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.Pervasives.fst.checked",
"Pulse.C.Typestring.fsti.checked",
"Pulse.C.Types.Fields.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.C.Types.Union.fsti"
} | [
{
"abbrev": false,
"full_module": "Pulse.C.Typestring",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.string -> fields: Pulse.C.Types.Fields.field_description_t tf
-> Pulse.C.Types.Base.typedef (Pulse.C.Types.Union.union_t0 tn n fields) | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.squash",
"FStar.Pervasives.norm",
"Pulse.C.Typestring.norm_typestring",
"Prims.eq2",
"Pulse.C.Typestring.mk_string_t",
"Pulse.C.Types.Fields.field_description_t",
"Pulse.C.Types.Union.union0",
"Pulse.C.Types.Base.typedef",
"Pulse.C.Types.Union.union_t0"
] | [] | false | false | false | false | false | let union
(#tf: Type0)
(n: string)
(#tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot (typedef (union_t0 tn n fields)) =
| union0 tn #tf n fields | false |
Pulse.C.Types.Union.fsti | Pulse.C.Types.Union.define_union | val define_union
(n: string)
(#tf #tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot Type0 | val define_union
(n: string)
(#tf #tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot Type0 | let define_union (n: string) (#tf: Type0) (#tn: Type0) (#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= define_union0 tn #tf n fields | {
"file_name": "share/steel/examples/pulse/lib/c/Pulse.C.Types.Union.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 31,
"end_line": 10,
"start_col": 0,
"start_line": 9
} | module Pulse.C.Types.Union
open Pulse.Lib.Pervasives
include Pulse.C.Types.Fields
open Pulse.C.Typestring
[@@noextract_to "krml"] // primitive
val define_union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0 | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.Pervasives.fst.checked",
"Pulse.C.Typestring.fsti.checked",
"Pulse.C.Types.Fields.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.C.Types.Union.fsti"
} | [
{
"abbrev": false,
"full_module": "Pulse.C.Typestring",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.string -> fields: Pulse.C.Types.Fields.field_description_t tf -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.squash",
"FStar.Pervasives.norm",
"Pulse.C.Typestring.norm_typestring",
"Prims.eq2",
"Pulse.C.Typestring.mk_string_t",
"Pulse.C.Types.Fields.field_description_t",
"Pulse.C.Types.Union.define_union0"
] | [] | false | false | false | false | true | let define_union
(n: string)
(#tf #tn: Type0)
(#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn)))
(fields: field_description_t tf)
: Tot Type0 =
| define_union0 tn #tf n fields | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.from_mont_point | val from_mont_point (a: tuple3 nat nat nat) : S.proj_point | val from_mont_point (a: tuple3 nat nat nat) : S.proj_point | let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 20,
"start_col": 0,
"start_line": 19
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: ((Prims.nat * Prims.nat) * Prims.nat) -> Spec.P256.PointOps.proj_point | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.tuple3",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple3",
"Hacl.Spec.P256.Montgomery.from_mont",
"Spec.P256.PointOps.proj_point"
] | [] | false | false | false | true | false | let from_mont_point (a: tuple3 nat nat nat) : S.proj_point =
| let x, y, z = a in
SM.from_mont x, SM.from_mont y, SM.from_mont z | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.as_aff_point_nat_seq | val as_aff_point_nat_seq : p: Hacl.Impl.P256.Point.aff_point_seq -> Prims.nat * Prims.nat | let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 30,
"start_col": 0,
"start_line": 28
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8 | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.aff_point_seq -> Prims.nat * Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.P256.Point.aff_point_seq",
"FStar.Pervasives.Native.Mktuple2",
"Prims.nat",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.IntTypes.U64",
"Lib.Sequence.sub",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | true | false | let as_aff_point_nat_seq (p: aff_point_seq) =
| BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4) | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.aff_point_seq | val aff_point_seq : Type0 | let aff_point_seq = LSeq.lseq uint64 8 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 26,
"start_col": 0,
"start_line": 26
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64"
] | [] | false | false | false | true | true | let aff_point_seq =
| LSeq.lseq uint64 8 | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.point_seq | val point_seq : Type0 | let point_seq = LSeq.lseq uint64 12 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 72,
"start_col": 0,
"start_line": 72
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64"
] | [] | false | false | false | true | true | let point_seq =
| LSeq.lseq uint64 12 | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.as_point_nat_seq | val as_point_nat_seq : p: Hacl.Impl.P256.Point.point_seq -> (Prims.nat * Prims.nat) * Prims.nat | let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 77,
"start_col": 0,
"start_line": 74
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12 | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.point_seq -> (Prims.nat * Prims.nat) * Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.P256.Point.point_seq",
"FStar.Pervasives.Native.Mktuple3",
"Prims.nat",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.IntTypes.U64",
"Lib.Sequence.sub",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.tuple3"
] | [] | false | false | false | true | false | let as_point_nat_seq (p: point_seq) =
| BD.bn_v (LSeq.sub p 0 4), BD.bn_v (LSeq.sub p 4 4), BD.bn_v (LSeq.sub p 8 4) | false |
|
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.aff_point_y_as_nat | val aff_point_y_as_nat (h: mem) (p: aff_point) : GTot nat | val aff_point_y_as_nat (h: mem) (p: aff_point) : GTot nat | let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 54,
"start_col": 0,
"start_line": 53
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.GTot Prims.nat | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Impl.P256.Bignum.as_nat",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.nat"
] | [] | false | false | false | false | false | let aff_point_y_as_nat (h: mem) (p: aff_point) : GTot nat =
| as_nat h (gsub p 4ul 4ul) | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.point_x_as_nat | val point_x_as_nat (h: mem) (p: point) : GTot nat | val point_x_as_nat (h: mem) (p: point) : GTot nat | let point_x_as_nat (h:mem) (p:point) : GTot nat =
as_nat h (gsub p 0ul 4ul) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 97,
"start_col": 0,
"start_line": 96
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4)
let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime
inline_for_extraction noextract
let point = lbuffer uint64 12ul
noextract
let as_point_nat (h:mem) (p:point) =
as_point_nat_seq (as_seq h p)
noextract
let point_inv (h:mem) (p:point) =
point_inv_seq (as_seq h p) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.point -> Prims.GTot Prims.nat | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Bignum.as_nat",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.nat"
] | [] | false | false | false | false | false | let point_x_as_nat (h: mem) (p: point) : GTot nat =
| as_nat h (gsub p 0ul 4ul) | false |
FStar.Seq.Base.fst | FStar.Seq.Base.length | val length: #a:Type -> seq a -> Tot nat | val length: #a:Type -> seq a -> Tot nat | let length #_ s = List.length (MkSeq?.l s) | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 26,
"start_col": 0,
"start_line": 26
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.__proj__MkSeq__item__l",
"Prims.nat"
] | [] | false | false | false | true | false | let length #_ s =
| List.length (MkSeq?.l s) | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.aff_point_x_as_nat | val aff_point_x_as_nat (h: mem) (p: aff_point) : GTot nat | val aff_point_x_as_nat (h: mem) (p: aff_point) : GTot nat | let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 50,
"start_col": 0,
"start_line": 49
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> p: Hacl.Impl.P256.Point.aff_point -> Prims.GTot Prims.nat | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Impl.P256.Bignum.as_nat",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.nat"
] | [] | false | false | false | false | false | let aff_point_x_as_nat (h: mem) (p: aff_point) : GTot nat =
| as_nat h (gsub p 0ul 4ul) | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.point_y_as_nat | val point_y_as_nat (h: mem) (e: point) : GTot nat | val point_y_as_nat (h: mem) (e: point) : GTot nat | let point_y_as_nat (h:mem) (e:point) : GTot nat =
as_nat h (gsub e 4ul 4ul) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 101,
"start_col": 0,
"start_line": 100
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4)
let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime
inline_for_extraction noextract
let point = lbuffer uint64 12ul
noextract
let as_point_nat (h:mem) (p:point) =
as_point_nat_seq (as_seq h p)
noextract
let point_inv (h:mem) (p:point) =
point_inv_seq (as_seq h p)
noextract
let point_x_as_nat (h:mem) (p:point) : GTot nat =
as_nat h (gsub p 0ul 4ul) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.Impl.P256.Point.point -> Prims.GTot Prims.nat | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Bignum.as_nat",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.nat"
] | [] | false | false | false | false | false | let point_y_as_nat (h: mem) (e: point) : GTot nat =
| as_nat h (gsub e 4ul 4ul) | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.aff_getx | val aff_getx (p: aff_point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) | val aff_getx (p: aff_point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) | let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 60,
"start_col": 0,
"start_line": 57
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.aff_point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.aff_point",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Impl.P256.Bignum.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.buffer_t",
"Prims.l_or",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let aff_getx (p: aff_point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) =
| sub p 0ul 4ul | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.point_z_as_nat | val point_z_as_nat (h: mem) (e: point) : GTot nat | val point_z_as_nat (h: mem) (e: point) : GTot nat | let point_z_as_nat (h:mem) (e:point) : GTot nat =
as_nat h (gsub e 8ul 4ul) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 105,
"start_col": 0,
"start_line": 104
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4)
let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime
inline_for_extraction noextract
let point = lbuffer uint64 12ul
noextract
let as_point_nat (h:mem) (p:point) =
as_point_nat_seq (as_seq h p)
noextract
let point_inv (h:mem) (p:point) =
point_inv_seq (as_seq h p)
noextract
let point_x_as_nat (h:mem) (p:point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let point_y_as_nat (h:mem) (e:point) : GTot nat =
as_nat h (gsub e 4ul 4ul) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.Impl.P256.Point.point -> Prims.GTot Prims.nat | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Bignum.as_nat",
"Lib.Buffer.gsub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.nat"
] | [] | false | false | false | false | false | let point_z_as_nat (h: mem) (e: point) : GTot nat =
| as_nat h (gsub e 8ul 4ul) | false |
FStar.Seq.Base.fst | FStar.Seq.Base._cons | val _cons (#a: Type) (x: a) (s: seq a) : Tot (seq a) | val _cons (#a: Type) (x: a) (s: seq a) : Tot (seq a) | let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s)) | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 75,
"end_line": 36,
"start_col": 0,
"start_line": 36
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> s: FStar.Seq.Base.seq a -> FStar.Seq.Base.seq a | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"FStar.Seq.Base.MkSeq",
"Prims.Cons",
"FStar.Seq.Base.__proj__MkSeq__item__l"
] | [] | false | false | false | true | false | let _cons (#a: Type) (x: a) (s: seq a) : Tot (seq a) =
| MkSeq (x :: (MkSeq?.l s)) | false |
FStar.Seq.Base.fst | FStar.Seq.Base.seq_to_list | val seq_to_list (#a:Type) (s:seq a) : Tot (l:list a{List.length l == length s}) | val seq_to_list (#a:Type) (s:seq a) : Tot (l:list a{List.length l == length s}) | let seq_to_list #_ s =
match s with
| MkSeq l -> l | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 16,
"end_line": 30,
"start_col": 0,
"start_line": 28
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a -> l: Prims.list a {FStar.List.Tot.Base.length l == FStar.Seq.Base.length s} | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Prims.list",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.length"
] | [] | false | false | false | false | false | let seq_to_list #_ s =
| match s with | MkSeq l -> l | false |
FStar.Seq.Base.fst | FStar.Seq.Base.seq_of_list | val seq_of_list (#a:Type) (l:list a) : Tot (s:seq a{List.length l == length s}) | val seq_of_list (#a:Type) (l:list a) : Tot (s:seq a{List.length l == length s}) | let seq_of_list #_ l = MkSeq l | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 32,
"start_col": 0,
"start_line": 32
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.list a -> s: FStar.Seq.Base.seq a {FStar.List.Tot.Base.length l == FStar.Seq.Base.length s} | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"FStar.Seq.Base.MkSeq",
"FStar.Seq.Base.seq",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.length"
] | [] | false | false | false | false | false | let seq_of_list #_ l =
| MkSeq l | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.aff_gety | val aff_gety (p: aff_point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) | val aff_gety (p: aff_point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) | let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 66,
"start_col": 0,
"start_line": 63
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.aff_point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.aff_point",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Impl.P256.Bignum.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.buffer_t",
"Prims.l_or",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let aff_gety (p: aff_point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) =
| sub p 4ul 4ul | false |
FStar.Seq.Base.fst | FStar.Seq.Base.index | val index: #a:Type -> s:seq a -> i:nat{i < length s} -> Tot a | val index: #a:Type -> s:seq a -> i:nat{i < length s} -> Tot a | let index #_ s i = List.index (MkSeq?.l s) i | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 34,
"start_col": 0,
"start_line": 34
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a -> i: Prims.nat{i < FStar.Seq.Base.length s} -> a | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"FStar.List.Tot.Base.index",
"FStar.Seq.Base.__proj__MkSeq__item__l"
] | [] | false | false | false | false | false | let index #_ s i =
| List.index (MkSeq?.l s) i | false |
Pulse.C.Types.Union.fsti | Pulse.C.Types.Union.full_union_set_field_intro | val full_union_set_field_intro
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires (full (fields.fd_typedef field) v))
(ensures (full (union0 tn n fields) (union_set_field tn n fields field v))) | val full_union_set_field_intro
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires (full (fields.fd_typedef field) v))
(ensures (full (union0 tn n fields) (union_set_field tn n fields field v))) | let full_union_set_field_intro
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (full (fields.fd_typedef field) v))
(ensures (
full (union0 tn n fields) (union_set_field tn n fields field v)
))
= full_union (union_set_field tn n fields field v) field | {
"file_name": "share/steel/examples/pulse/lib/c/Pulse.C.Types.Union.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 56,
"end_line": 191,
"start_col": 0,
"start_line": 179
} | module Pulse.C.Types.Union
open Pulse.Lib.Pervasives
include Pulse.C.Types.Fields
open Pulse.C.Typestring
[@@noextract_to "krml"] // primitive
val define_union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let define_union (n: string) (#tf: Type0) (#tn: Type0) (#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= define_union0 tn #tf n fields
// To be extracted as: union t
[@@noextract_to "krml"] // primitive
val union_t0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let union_t (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= union_t0 tn #tf n fields
val union_set_field (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) (f: field_t fields) (v: fields.fd_type f) : GTot (union_t0 tn n fields)
val union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
: GTot (option (field_t fields))
val union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
(field: field_t fields)
: Ghost (fields.fd_type field)
(requires (union_get_case u == Some field))
(ensures (fun _ -> True))
val union_get_field_same
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (~ (v == unknown (fields.fd_typedef field))))
(ensures (
let u = union_set_field tn n fields field v in
union_get_case u == Some field /\
union_get_field u field == v
))
[SMTPatOr [
[SMTPat (union_get_case (union_set_field tn n fields field v))];
[SMTPat (union_get_field (union_set_field tn n fields field v) field)];
]]
val union_set_field_same
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
union_set_field tn n fields field (union_get_field s field) == s
))
[SMTPat (union_set_field tn n fields (union_get_field s field))]
[@@noextract_to "krml"] // proof-only
val union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
inline_for_extraction
[@@noextract_to "krml"; norm_field_attr] // proof-only
let union (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
= union0 tn #tf n fields
val union_get_case_unknown
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
: Lemma
(union_get_case (unknown (union0 tn n fields)) == None)
[SMTPat (unknown (union0 tn n fields))]
val union_set_field_unknown
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
: Lemma
(union_set_field tn n fields field (unknown (fields.fd_typedef field)) == unknown (union0 tn n fields))
[SMTPat (union_set_field tn n fields field (unknown (fields.fd_typedef field)))]
val union_get_case_uninitialized
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
: Lemma
(union_get_case (uninitialized (union0 tn n fields)) == None)
[SMTPat (uninitialized (union0 tn n fields))]
val mk_fraction_union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(p: perm)
: Lemma
(requires (fractionable (union0 tn n fields) s))
(ensures (
union_get_case (mk_fraction (union0 tn n fields) s p) == union_get_case s
))
[SMTPat (union_get_case (mk_fraction (union0 tn n fields) s p))]
val fractionable_union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
fractionable (union0 tn n fields) s <==> fractionable (fields.fd_typedef field) (union_get_field s field)
))
[SMTPat (fractionable (union0 tn n fields) s); SMTPat (union_get_field s field)]
val mk_fraction_union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(p: perm)
(field: field_t fields)
: Lemma
(requires (fractionable (union0 tn n fields) s /\ union_get_case s == Some field))
(ensures (union_get_field (mk_fraction (union0 tn n fields) s p) field == mk_fraction (fields.fd_typedef field) (union_get_field s field) p))
[SMTPat (union_get_field (mk_fraction (union0 tn n fields) s p) field)]
val mk_fraction_union_set_field
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
(p: perm)
: Lemma
(requires (fractionable (fields.fd_typedef field) v))
(ensures (
fractionable (union0 tn n fields) (union_set_field tn n fields field v) /\
mk_fraction (union0 tn n fields) (union_set_field tn n fields field v) p == union_set_field tn n fields field (mk_fraction (fields.fd_typedef field) v p)
))
val full_union
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
full (union0 tn n fields) s <==> full (fields.fd_typedef field) (union_get_field s field)
))
[SMTPat (full (union0 tn n fields) s); SMTPat (union_get_field s field)] | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.Pervasives.fst.checked",
"Pulse.C.Typestring.fsti.checked",
"Pulse.C.Types.Fields.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.C.Types.Union.fsti"
} | [
{
"abbrev": false,
"full_module": "Pulse.C.Typestring",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | field: Pulse.C.Types.Fields.field_t fields -> v: Mkfield_description_t?.fd_type fields field
-> FStar.Pervasives.Lemma
(requires Pulse.C.Types.Base.full (Mkfield_description_t?.fd_typedef fields field) v)
(ensures
Pulse.C.Types.Base.full (Pulse.C.Types.Union.union0 tn n fields)
(Pulse.C.Types.Union.union_set_field tn n fields field v)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.string",
"Pulse.C.Types.Fields.field_description_t",
"Pulse.C.Types.Fields.field_t",
"Pulse.C.Types.Fields.__proj__Mkfield_description_t__item__fd_type",
"Pulse.C.Types.Union.full_union",
"Pulse.C.Types.Union.union_set_field",
"Prims.unit",
"Pulse.C.Types.Base.full",
"Pulse.C.Types.Fields.__proj__Mkfield_description_t__item__fd_typedef",
"Prims.squash",
"Pulse.C.Types.Union.union_t0",
"Pulse.C.Types.Union.union0",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let full_union_set_field_intro
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires (full (fields.fd_typedef field) v))
(ensures (full (union0 tn n fields) (union_set_field tn n fields field v))) =
| full_union (union_set_field tn n fields field v) field | false |
FStar.Seq.Base.fst | FStar.Seq.Base.hd | val hd (#a: Type) (s: seq a {length s > 0}) : Tot a | val hd (#a: Type) (s: seq a {length s > 0}) : Tot a | let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s) | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 71,
"end_line": 38,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a {FStar.Seq.Base.length s > 0} -> a | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"FStar.List.Tot.Base.hd",
"FStar.Seq.Base.__proj__MkSeq__item__l"
] | [] | false | false | false | false | false | let hd (#a: Type) (s: seq a {length s > 0}) : Tot a =
| List.hd (MkSeq?.l s) | false |
FStar.Seq.Base.fst | FStar.Seq.Base.init_aux | val init_aux (#a:Type) (len:nat) (k:nat{k < len}) (contents:(i:nat { i < len } -> Tot a))
:Tot (seq a) | val init_aux (#a:Type) (len:nat) (k:nat{k < len}) (contents:(i:nat { i < len } -> Tot a))
:Tot (seq a) | let init_aux = init_aux' | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 51,
"start_col": 0,
"start_line": 51
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s)
let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s))
let rec create #_ len v = if len = 0 then MkSeq [] else _cons v (create (len - 1) v)
private let rec init_aux' (#a:Type) (len:nat) (k:nat{k < len}) (contents: (i:nat{i < len} -> Tot a))
: Tot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux' len (k+1) contents) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Prims.nat -> k: Prims.nat{k < len} -> contents: (i: Prims.nat{i < len} -> a)
-> FStar.Seq.Base.seq a | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.init_aux'"
] | [] | false | false | false | false | false | let init_aux =
| init_aux' | false |
FStar.Seq.Base.fst | FStar.Seq.Base.tl | val tl (#a: Type) (s: seq a {length s > 0}) : Tot (seq a) | val tl (#a: Type) (s: seq a {length s > 0}) : Tot (seq a) | let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s)) | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 85,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a {FStar.Seq.Base.length s > 0} -> FStar.Seq.Base.seq a | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"FStar.Seq.Base.MkSeq",
"FStar.List.Tot.Base.tl",
"FStar.Seq.Base.__proj__MkSeq__item__l"
] | [] | false | false | false | false | false | let tl (#a: Type) (s: seq a {length s > 0}) : Tot (seq a) =
| MkSeq (List.tl (MkSeq?.l s)) | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.gety | val gety (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) | val gety (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) | let gety (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 118,
"start_col": 0,
"start_line": 115
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4)
let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime
inline_for_extraction noextract
let point = lbuffer uint64 12ul
noextract
let as_point_nat (h:mem) (p:point) =
as_point_nat_seq (as_seq h p)
noextract
let point_inv (h:mem) (p:point) =
point_inv_seq (as_seq h p)
noextract
let point_x_as_nat (h:mem) (p:point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let point_y_as_nat (h:mem) (e:point) : GTot nat =
as_nat h (gsub e 4ul 4ul)
noextract
let point_z_as_nat (h:mem) (e:point) : GTot nat =
as_nat h (gsub e 8ul 4ul)
inline_for_extraction noextract
let getx (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Impl.P256.Bignum.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.buffer_t",
"Prims.l_or",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let gety (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1) =
| sub p 4ul 4ul | false |
Pulse.C.Types.Union.fsti | Pulse.C.Types.Union.full_union_set_field_elim | val full_union_set_field_elim
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires (full (union0 tn n fields) (union_set_field tn n fields field v)))
(ensures (full (fields.fd_typedef field) v)) | val full_union_set_field_elim
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires (full (union0 tn n fields) (union_set_field tn n fields field v)))
(ensures (full (fields.fd_typedef field) v)) | let full_union_set_field_elim
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (
full (union0 tn n fields) (union_set_field tn n fields field v)
))
(ensures (
full (fields.fd_typedef field) v
))
= full_union (union_set_field tn n fields field v) field | {
"file_name": "share/steel/examples/pulse/lib/c/Pulse.C.Types.Union.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 56,
"end_line": 207,
"start_col": 0,
"start_line": 193
} | module Pulse.C.Types.Union
open Pulse.Lib.Pervasives
include Pulse.C.Types.Fields
open Pulse.C.Typestring
[@@noextract_to "krml"] // primitive
val define_union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let define_union (n: string) (#tf: Type0) (#tn: Type0) (#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= define_union0 tn #tf n fields
// To be extracted as: union t
[@@noextract_to "krml"] // primitive
val union_t0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let union_t (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= union_t0 tn #tf n fields
val union_set_field (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) (f: field_t fields) (v: fields.fd_type f) : GTot (union_t0 tn n fields)
val union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
: GTot (option (field_t fields))
val union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
(field: field_t fields)
: Ghost (fields.fd_type field)
(requires (union_get_case u == Some field))
(ensures (fun _ -> True))
val union_get_field_same
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (~ (v == unknown (fields.fd_typedef field))))
(ensures (
let u = union_set_field tn n fields field v in
union_get_case u == Some field /\
union_get_field u field == v
))
[SMTPatOr [
[SMTPat (union_get_case (union_set_field tn n fields field v))];
[SMTPat (union_get_field (union_set_field tn n fields field v) field)];
]]
val union_set_field_same
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
union_set_field tn n fields field (union_get_field s field) == s
))
[SMTPat (union_set_field tn n fields (union_get_field s field))]
[@@noextract_to "krml"] // proof-only
val union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
inline_for_extraction
[@@noextract_to "krml"; norm_field_attr] // proof-only
let union (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
= union0 tn #tf n fields
val union_get_case_unknown
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
: Lemma
(union_get_case (unknown (union0 tn n fields)) == None)
[SMTPat (unknown (union0 tn n fields))]
val union_set_field_unknown
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
: Lemma
(union_set_field tn n fields field (unknown (fields.fd_typedef field)) == unknown (union0 tn n fields))
[SMTPat (union_set_field tn n fields field (unknown (fields.fd_typedef field)))]
val union_get_case_uninitialized
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
: Lemma
(union_get_case (uninitialized (union0 tn n fields)) == None)
[SMTPat (uninitialized (union0 tn n fields))]
val mk_fraction_union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(p: perm)
: Lemma
(requires (fractionable (union0 tn n fields) s))
(ensures (
union_get_case (mk_fraction (union0 tn n fields) s p) == union_get_case s
))
[SMTPat (union_get_case (mk_fraction (union0 tn n fields) s p))]
val fractionable_union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
fractionable (union0 tn n fields) s <==> fractionable (fields.fd_typedef field) (union_get_field s field)
))
[SMTPat (fractionable (union0 tn n fields) s); SMTPat (union_get_field s field)]
val mk_fraction_union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(p: perm)
(field: field_t fields)
: Lemma
(requires (fractionable (union0 tn n fields) s /\ union_get_case s == Some field))
(ensures (union_get_field (mk_fraction (union0 tn n fields) s p) field == mk_fraction (fields.fd_typedef field) (union_get_field s field) p))
[SMTPat (union_get_field (mk_fraction (union0 tn n fields) s p) field)]
val mk_fraction_union_set_field
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
(p: perm)
: Lemma
(requires (fractionable (fields.fd_typedef field) v))
(ensures (
fractionable (union0 tn n fields) (union_set_field tn n fields field v) /\
mk_fraction (union0 tn n fields) (union_set_field tn n fields field v) p == union_set_field tn n fields field (mk_fraction (fields.fd_typedef field) v p)
))
val full_union
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
full (union0 tn n fields) s <==> full (fields.fd_typedef field) (union_get_field s field)
))
[SMTPat (full (union0 tn n fields) s); SMTPat (union_get_field s field)]
let full_union_set_field_intro
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (full (fields.fd_typedef field) v))
(ensures (
full (union0 tn n fields) (union_set_field tn n fields field v)
))
= full_union (union_set_field tn n fields field v) field | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.Pervasives.fst.checked",
"Pulse.C.Typestring.fsti.checked",
"Pulse.C.Types.Fields.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.C.Types.Union.fsti"
} | [
{
"abbrev": false,
"full_module": "Pulse.C.Typestring",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | field: Pulse.C.Types.Fields.field_t fields -> v: Mkfield_description_t?.fd_type fields field
-> FStar.Pervasives.Lemma
(requires
Pulse.C.Types.Base.full (Pulse.C.Types.Union.union0 tn n fields)
(Pulse.C.Types.Union.union_set_field tn n fields field v))
(ensures Pulse.C.Types.Base.full (Mkfield_description_t?.fd_typedef fields field) v) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.string",
"Pulse.C.Types.Fields.field_description_t",
"Pulse.C.Types.Fields.field_t",
"Pulse.C.Types.Fields.__proj__Mkfield_description_t__item__fd_type",
"Pulse.C.Types.Union.full_union",
"Pulse.C.Types.Union.union_set_field",
"Prims.unit",
"Pulse.C.Types.Base.full",
"Pulse.C.Types.Union.union_t0",
"Pulse.C.Types.Union.union0",
"Prims.squash",
"Pulse.C.Types.Fields.__proj__Mkfield_description_t__item__fd_typedef",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let full_union_set_field_elim
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires (full (union0 tn n fields) (union_set_field tn n fields field v)))
(ensures (full (fields.fd_typedef field) v)) =
| full_union (union_set_field tn n fields field v) field | false |
FStar.Seq.Base.fst | FStar.Seq.Base.init_aux_ghost | val init_aux_ghost (#a:Type) (len:nat) (k:nat{k < len}) (contents:(i:nat { i < len } -> GTot a))
: GTot (seq a) | val init_aux_ghost (#a:Type) (len:nat) (k:nat{k < len}) (contents:(i:nat { i < len } -> GTot a))
: GTot (seq a) | let init_aux_ghost = init_aux_ghost' | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 62,
"start_col": 0,
"start_line": 62
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s)
let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s))
let rec create #_ len v = if len = 0 then MkSeq [] else _cons v (create (len - 1) v)
private let rec init_aux' (#a:Type) (len:nat) (k:nat{k < len}) (contents: (i:nat{i < len} -> Tot a))
: Tot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux' len (k+1) contents)
let init_aux = init_aux'
let init #_ len contents = if len = 0 then MkSeq [] else init_aux len 0 contents
private let rec init_aux_ghost' (#a:Type) (len:nat) (k:nat{k < len}) (contents:(i:nat { i < len } -> GTot a))
: GTot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux_ghost' len (k+1) contents) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Prims.nat -> k: Prims.nat{k < len} -> contents: (i: Prims.nat{i < len} -> Prims.GTot a)
-> Prims.GTot (FStar.Seq.Base.seq a) | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Seq.Base.init_aux_ghost'"
] | [] | false | false | false | false | false | let init_aux_ghost =
| init_aux_ghost' | false |
FStar.Seq.Base.fst | FStar.Seq.Base.create | val create: #a:Type -> nat -> a -> Tot (seq a) | val create: #a:Type -> nat -> a -> Tot (seq a) | let rec create #_ len v = if len = 0 then MkSeq [] else _cons v (create (len - 1) v) | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 84,
"end_line": 42,
"start_col": 0,
"start_line": 42
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s)
let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Prims.nat -> v: a -> FStar.Seq.Base.seq a | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.MkSeq",
"Prims.Nil",
"Prims.bool",
"FStar.Seq.Base._cons",
"FStar.Seq.Base.create",
"Prims.op_Subtraction",
"FStar.Seq.Base.seq"
] | [
"recursion"
] | false | false | false | true | false | let rec create #_ len v =
| if len = 0 then MkSeq [] else _cons v (create (len - 1) v) | false |
FStar.Seq.Base.fst | FStar.Seq.Base.init_aux' | val init_aux' (#a: Type) (len: nat) (k: nat{k < len}) (contents: (i: nat{i < len} -> Tot a))
: Tot (seq a) (decreases (len - k)) | val init_aux' (#a: Type) (len: nat) (k: nat{k < len}) (contents: (i: nat{i < len} -> Tot a))
: Tot (seq a) (decreases (len - k)) | let rec init_aux' (#a:Type) (len:nat) (k:nat{k < len}) (contents: (i:nat{i < len} -> Tot a))
: Tot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux' len (k+1) contents) | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 49,
"start_col": 8,
"start_line": 44
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s)
let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s))
let rec create #_ len v = if len = 0 then MkSeq [] else _cons v (create (len - 1) v) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Prims.nat -> k: Prims.nat{k < len} -> contents: (i: Prims.nat{i < len} -> a)
-> Prims.Tot (FStar.Seq.Base.seq a) | Prims.Tot | [
"total",
""
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Addition",
"FStar.Seq.Base.MkSeq",
"Prims.Cons",
"Prims.Nil",
"Prims.bool",
"FStar.Seq.Base._cons",
"FStar.Seq.Base.init_aux'",
"FStar.Seq.Base.seq"
] | [
"recursion"
] | false | false | false | false | false | let rec init_aux' (#a: Type) (len: nat) (k: nat{k < len}) (contents: (i: nat{i < len} -> Tot a))
: Tot (seq a) (decreases (len - k)) =
| if k + 1 = len then MkSeq [contents k] else _cons (contents k) (init_aux' len (k + 1) contents) | false |
Pulse.C.Types.Union.fsti | Pulse.C.Types.Union.full_union_set_field | val full_union_set_field
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires True)
(ensures
(full (union0 tn n fields) (union_set_field tn n fields field v) <==>
full (fields.fd_typedef field) v))
[SMTPat (full (union0 tn n fields) (union_set_field tn n fields field v))] | val full_union_set_field
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires True)
(ensures
(full (union0 tn n fields) (union_set_field tn n fields field v) <==>
full (fields.fd_typedef field) v))
[SMTPat (full (union0 tn n fields) (union_set_field tn n fields field v))] | let full_union_set_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires True)
(ensures (
full (union0 tn n fields) (union_set_field tn n fields field v) <==> full (fields.fd_typedef field) v
))
[SMTPat (full (union0 tn n fields) (union_set_field tn n fields field v))]
= Classical.move_requires (full_union_set_field_intro #tn #tf #n #fields field) v;
Classical.move_requires (full_union_set_field_elim #tn #tf #n #fields field) v | {
"file_name": "share/steel/examples/pulse/lib/c/Pulse.C.Types.Union.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 80,
"end_line": 223,
"start_col": 0,
"start_line": 209
} | module Pulse.C.Types.Union
open Pulse.Lib.Pervasives
include Pulse.C.Types.Fields
open Pulse.C.Typestring
[@@noextract_to "krml"] // primitive
val define_union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let define_union (n: string) (#tf: Type0) (#tn: Type0) (#[solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= define_union0 tn #tf n fields
// To be extracted as: union t
[@@noextract_to "krml"] // primitive
val union_t0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot Type0
inline_for_extraction [@@noextract_to "krml"]
let union_t (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot Type0
= union_t0 tn #tf n fields
val union_set_field (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) (f: field_t fields) (v: fields.fd_type f) : GTot (union_t0 tn n fields)
val union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
: GTot (option (field_t fields))
val union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(u: union_t0 tn n fields)
(field: field_t fields)
: Ghost (fields.fd_type field)
(requires (union_get_case u == Some field))
(ensures (fun _ -> True))
val union_get_field_same
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (~ (v == unknown (fields.fd_typedef field))))
(ensures (
let u = union_set_field tn n fields field v in
union_get_case u == Some field /\
union_get_field u field == v
))
[SMTPatOr [
[SMTPat (union_get_case (union_set_field tn n fields field v))];
[SMTPat (union_get_field (union_set_field tn n fields field v) field)];
]]
val union_set_field_same
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
union_set_field tn n fields field (union_get_field s field) == s
))
[SMTPat (union_set_field tn n fields (union_get_field s field))]
[@@noextract_to "krml"] // proof-only
val union0 (tn: Type0) (#tf: Type0) (n: string) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
inline_for_extraction
[@@noextract_to "krml"; norm_field_attr] // proof-only
let union (#tf: Type0) (n: string) (#tn: Type0) (# [solve_mk_string_t ()] prf: squash (norm norm_typestring (mk_string_t n == tn))) (fields: field_description_t tf) : Tot (typedef (union_t0 tn n fields))
= union0 tn #tf n fields
val union_get_case_unknown
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
: Lemma
(union_get_case (unknown (union0 tn n fields)) == None)
[SMTPat (unknown (union0 tn n fields))]
val union_set_field_unknown
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
: Lemma
(union_set_field tn n fields field (unknown (fields.fd_typedef field)) == unknown (union0 tn n fields))
[SMTPat (union_set_field tn n fields field (unknown (fields.fd_typedef field)))]
val union_get_case_uninitialized
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
: Lemma
(union_get_case (uninitialized (union0 tn n fields)) == None)
[SMTPat (uninitialized (union0 tn n fields))]
val mk_fraction_union_get_case
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(p: perm)
: Lemma
(requires (fractionable (union0 tn n fields) s))
(ensures (
union_get_case (mk_fraction (union0 tn n fields) s p) == union_get_case s
))
[SMTPat (union_get_case (mk_fraction (union0 tn n fields) s p))]
val fractionable_union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
fractionable (union0 tn n fields) s <==> fractionable (fields.fd_typedef field) (union_get_field s field)
))
[SMTPat (fractionable (union0 tn n fields) s); SMTPat (union_get_field s field)]
val mk_fraction_union_get_field
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(p: perm)
(field: field_t fields)
: Lemma
(requires (fractionable (union0 tn n fields) s /\ union_get_case s == Some field))
(ensures (union_get_field (mk_fraction (union0 tn n fields) s p) field == mk_fraction (fields.fd_typedef field) (union_get_field s field) p))
[SMTPat (union_get_field (mk_fraction (union0 tn n fields) s p) field)]
val mk_fraction_union_set_field
(tn: Type0)
(#tf: Type0)
(n: string)
(fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
(p: perm)
: Lemma
(requires (fractionable (fields.fd_typedef field) v))
(ensures (
fractionable (union0 tn n fields) (union_set_field tn n fields field v) /\
mk_fraction (union0 tn n fields) (union_set_field tn n fields field v) p == union_set_field tn n fields field (mk_fraction (fields.fd_typedef field) v p)
))
val full_union
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(s: union_t0 tn n fields)
(field: field_t fields)
: Lemma
(requires (union_get_case s == Some field))
(ensures (
full (union0 tn n fields) s <==> full (fields.fd_typedef field) (union_get_field s field)
))
[SMTPat (full (union0 tn n fields) s); SMTPat (union_get_field s field)]
let full_union_set_field_intro
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (full (fields.fd_typedef field) v))
(ensures (
full (union0 tn n fields) (union_set_field tn n fields field v)
))
= full_union (union_set_field tn n fields field v) field
let full_union_set_field_elim
(#tn: Type0)
(#tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma
(requires (
full (union0 tn n fields) (union_set_field tn n fields field v)
))
(ensures (
full (fields.fd_typedef field) v
))
= full_union (union_set_field tn n fields field v) field | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.Pervasives.fst.checked",
"Pulse.C.Typestring.fsti.checked",
"Pulse.C.Types.Fields.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.C.Types.Union.fsti"
} | [
{
"abbrev": false,
"full_module": "Pulse.C.Typestring",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | field: Pulse.C.Types.Fields.field_t fields -> v: Mkfield_description_t?.fd_type fields field
-> FStar.Pervasives.Lemma
(ensures
Pulse.C.Types.Base.full (Pulse.C.Types.Union.union0 tn n fields)
(Pulse.C.Types.Union.union_set_field tn n fields field v) <==>
Pulse.C.Types.Base.full (Mkfield_description_t?.fd_typedef fields field) v)
[
SMTPat (Pulse.C.Types.Base.full (Pulse.C.Types.Union.union0 tn n fields)
(Pulse.C.Types.Union.union_set_field tn n fields field v))
] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.string",
"Pulse.C.Types.Fields.field_description_t",
"Pulse.C.Types.Fields.field_t",
"Pulse.C.Types.Fields.__proj__Mkfield_description_t__item__fd_type",
"FStar.Classical.move_requires",
"Pulse.C.Types.Base.full",
"Pulse.C.Types.Union.union_t0",
"Pulse.C.Types.Union.union0",
"Pulse.C.Types.Union.union_set_field",
"Pulse.C.Types.Fields.__proj__Mkfield_description_t__item__fd_typedef",
"Pulse.C.Types.Union.full_union_set_field_elim",
"Prims.unit",
"Pulse.C.Types.Union.full_union_set_field_intro",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.prop",
"Prims.Nil"
] | [] | false | false | true | false | false | let full_union_set_field
(#tn #tf: Type0)
(#n: string)
(#fields: field_description_t tf)
(field: field_t fields)
(v: fields.fd_type field)
: Lemma (requires True)
(ensures
(full (union0 tn n fields) (union_set_field tn n fields field v) <==>
full (fields.fd_typedef field) v))
[SMTPat (full (union0 tn n fields) (union_set_field tn n fields field v))] =
| Classical.move_requires (full_union_set_field_intro #tn #tf #n #fields field) v;
Classical.move_requires (full_union_set_field_elim #tn #tf #n #fields field) v | false |
FStar.Seq.Base.fst | FStar.Seq.Base.upd | val upd: #a:Type -> s:seq a -> n:nat{n < length s} -> a -> Tot (seq a) | val upd: #a:Type -> s:seq a -> n:nat{n < length s} -> a -> Tot (seq a) | let upd = upd' | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 75,
"start_col": 0,
"start_line": 75
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s)
let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s))
let rec create #_ len v = if len = 0 then MkSeq [] else _cons v (create (len - 1) v)
private let rec init_aux' (#a:Type) (len:nat) (k:nat{k < len}) (contents: (i:nat{i < len} -> Tot a))
: Tot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux' len (k+1) contents)
let init_aux = init_aux'
let init #_ len contents = if len = 0 then MkSeq [] else init_aux len 0 contents
private let rec init_aux_ghost' (#a:Type) (len:nat) (k:nat{k < len}) (contents:(i:nat { i < len } -> GTot a))
: GTot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux_ghost' len (k+1) contents)
let init_aux_ghost = init_aux_ghost'
let init_ghost #_ len contents = if len = 0 then MkSeq [] else init_aux_ghost len 0 contents
let empty #_ = MkSeq []
let lemma_empty #_ _ = ()
private let rec upd' (#a:Type) (s:seq a) (n:nat{n < length s}) (v:a)
: Tot (seq a)
(decreases (length s))
= if n = 0 then _cons v (tl s) else _cons (hd s) (upd' (tl s) (n - 1) v) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a -> n: Prims.nat{n < FStar.Seq.Base.length s} -> _: a -> FStar.Seq.Base.seq a | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.upd'"
] | [] | false | false | false | false | false | let upd =
| upd' | false |
FStar.Seq.Base.fst | FStar.Seq.Base.append | val append: #a:Type -> seq a -> seq a -> Tot (seq a) | val append: #a:Type -> seq a -> seq a -> Tot (seq a) | let append #_ s1 s2 = MkSeq (List.append (MkSeq?.l s1) (MkSeq?.l s2)) | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 69,
"end_line": 77,
"start_col": 0,
"start_line": 77
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s)
let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s))
let rec create #_ len v = if len = 0 then MkSeq [] else _cons v (create (len - 1) v)
private let rec init_aux' (#a:Type) (len:nat) (k:nat{k < len}) (contents: (i:nat{i < len} -> Tot a))
: Tot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux' len (k+1) contents)
let init_aux = init_aux'
let init #_ len contents = if len = 0 then MkSeq [] else init_aux len 0 contents
private let rec init_aux_ghost' (#a:Type) (len:nat) (k:nat{k < len}) (contents:(i:nat { i < len } -> GTot a))
: GTot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux_ghost' len (k+1) contents)
let init_aux_ghost = init_aux_ghost'
let init_ghost #_ len contents = if len = 0 then MkSeq [] else init_aux_ghost len 0 contents
let empty #_ = MkSeq []
let lemma_empty #_ _ = ()
private let rec upd' (#a:Type) (s:seq a) (n:nat{n < length s}) (v:a)
: Tot (seq a)
(decreases (length s))
= if n = 0 then _cons v (tl s) else _cons (hd s) (upd' (tl s) (n - 1) v)
let upd = upd' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> FStar.Seq.Base.seq a | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"FStar.Seq.Base.MkSeq",
"FStar.List.Tot.Base.append",
"FStar.Seq.Base.__proj__MkSeq__item__l"
] | [] | false | false | false | true | false | let append #_ s1 s2 =
| MkSeq (List.append (MkSeq?.l s1) (MkSeq?.l s2)) | false |
FStar.Seq.Base.fst | FStar.Seq.Base.slice | val slice: #a:Type -> s:seq a -> i:nat -> j:nat{i <= j && j <= length s} -> Tot (seq a) | val slice: #a:Type -> s:seq a -> i:nat -> j:nat{i <= j && j <= length s} -> Tot (seq a) | let slice = slice' | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 86,
"start_col": 0,
"start_line": 86
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s)
let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s))
let rec create #_ len v = if len = 0 then MkSeq [] else _cons v (create (len - 1) v)
private let rec init_aux' (#a:Type) (len:nat) (k:nat{k < len}) (contents: (i:nat{i < len} -> Tot a))
: Tot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux' len (k+1) contents)
let init_aux = init_aux'
let init #_ len contents = if len = 0 then MkSeq [] else init_aux len 0 contents
private let rec init_aux_ghost' (#a:Type) (len:nat) (k:nat{k < len}) (contents:(i:nat { i < len } -> GTot a))
: GTot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux_ghost' len (k+1) contents)
let init_aux_ghost = init_aux_ghost'
let init_ghost #_ len contents = if len = 0 then MkSeq [] else init_aux_ghost len 0 contents
let empty #_ = MkSeq []
let lemma_empty #_ _ = ()
private let rec upd' (#a:Type) (s:seq a) (n:nat{n < length s}) (v:a)
: Tot (seq a)
(decreases (length s))
= if n = 0 then _cons v (tl s) else _cons (hd s) (upd' (tl s) (n - 1) v)
let upd = upd'
let append #_ s1 s2 = MkSeq (List.append (MkSeq?.l s1) (MkSeq?.l s2))
private let rec slice' (#a:Type) (s:seq a) (i:nat) (j:nat{i <= j && j <= length s})
: Tot (seq a)
(decreases (length s))
= if i > 0 then slice' #a (tl s) (i - 1) (j - 1)
else if j = 0 then MkSeq []
else _cons (hd s) (slice' #a (tl s) i (j - 1)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a -> i: Prims.nat -> j: Prims.nat{i <= j && j <= FStar.Seq.Base.length s}
-> FStar.Seq.Base.seq a | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.slice'"
] | [] | false | false | false | false | false | let slice =
| slice' | false |
Hacl.Impl.P256.Point.fsti | Hacl.Impl.P256.Point.getx | val getx (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) | val getx (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) | let getx (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 112,
"start_col": 0,
"start_line": 109
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module LSeq = Lib.Sequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
let from_mont_point (a:tuple3 nat nat nat) : S.proj_point =
let x, y, z = a in SM.from_mont x, SM.from_mont y, SM.from_mont z
/// Affine coordinates
inline_for_extraction noextract
let aff_point_seq = LSeq.lseq uint64 8
let as_aff_point_nat_seq (p:aff_point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4)
let aff_point_inv_seq (p:aff_point_seq) =
let x, y = as_aff_point_nat_seq p in
x < S.prime /\ y < S.prime
inline_for_extraction noextract
let aff_point = lbuffer uint64 8ul
noextract
let as_aff_point_nat (h:mem) (p:aff_point) =
as_aff_point_nat_seq (as_seq h p)
noextract
let aff_point_inv (h:mem) (p:aff_point) =
aff_point_inv_seq (as_seq h p)
noextract
let aff_point_x_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let aff_point_y_as_nat (h:mem) (p:aff_point) : GTot nat =
as_nat h (gsub p 4ul 4ul)
inline_for_extraction noextract
let aff_getx (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1)
= sub p 0ul 4ul
inline_for_extraction noextract
let aff_gety (p:aff_point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 4ul 4ul /\ h0 == h1)
= sub p 4ul 4ul
/// Projective coordinates
inline_for_extraction noextract
let point_seq = LSeq.lseq uint64 12
let as_point_nat_seq (p:point_seq) =
BD.bn_v (LSeq.sub p 0 4),
BD.bn_v (LSeq.sub p 4 4),
BD.bn_v (LSeq.sub p 8 4)
let point_inv_seq (p:point_seq) =
let x, y, z = as_point_nat_seq p in
x < S.prime /\ y < S.prime /\ z < S.prime
inline_for_extraction noextract
let point = lbuffer uint64 12ul
noextract
let as_point_nat (h:mem) (p:point) =
as_point_nat_seq (as_seq h p)
noextract
let point_inv (h:mem) (p:point) =
point_inv_seq (as_seq h p)
noextract
let point_x_as_nat (h:mem) (p:point) : GTot nat =
as_nat h (gsub p 0ul 4ul)
noextract
let point_y_as_nat (h:mem) (e:point) : GTot nat =
as_nat h (gsub e 4ul 4ul)
noextract
let point_z_as_nat (h:mem) (e:point) : GTot nat =
as_nat h (gsub e 8ul 4ul) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Point.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Hacl.Impl.P256.Bignum.felem | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Impl.P256.Bignum.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.buffer_t",
"Prims.l_or",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let getx (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 4ul /\ h0 == h1) =
| sub p 0ul 4ul | false |
FStar.Seq.Base.fst | FStar.Seq.Base.init | val init: #a:Type -> len:nat -> contents: (i:nat { i < len } -> Tot a) -> Tot (seq a) | val init: #a:Type -> len:nat -> contents: (i:nat { i < len } -> Tot a) -> Tot (seq a) | let init #_ len contents = if len = 0 then MkSeq [] else init_aux len 0 contents | {
"file_name": "ulib/FStar.Seq.Base.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 80,
"end_line": 53,
"start_col": 0,
"start_line": 53
} | (*
Copyright 2008-2014 Nikhil Swamy and 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.
*)
(* A logical theory of sequences indexed by natural numbers in [0, n) *)
module FStar.Seq.Base
//#set-options "--initial_fuel 0 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1"
module List = FStar.List.Tot
type seq (a:Type u#a) :Type u#a =
| MkSeq: l:list a -> seq a
let length #_ s = List.length (MkSeq?.l s)
let seq_to_list #_ s =
match s with
| MkSeq l -> l
let seq_of_list #_ l = MkSeq l
let index #_ s i = List.index (MkSeq?.l s) i
let _cons (#a:Type) (x:a) (s:seq a) : Tot (seq a) = MkSeq (x::(MkSeq?.l s))
let hd (#a:Type) (s:seq a{length s > 0}) : Tot a = List.hd (MkSeq?.l s)
let tl (#a:Type) (s:seq a{length s > 0}) : Tot (seq a) = MkSeq (List.tl (MkSeq?.l s))
let rec create #_ len v = if len = 0 then MkSeq [] else _cons v (create (len - 1) v)
private let rec init_aux' (#a:Type) (len:nat) (k:nat{k < len}) (contents: (i:nat{i < len} -> Tot a))
: Tot (seq a)
(decreases (len - k))
= if k + 1 = len
then MkSeq [contents k]
else _cons (contents k) (init_aux' len (k+1) contents)
let init_aux = init_aux' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Seq.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Prims.nat -> contents: (i: Prims.nat{i < len} -> a) -> FStar.Seq.Base.seq a | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.MkSeq",
"Prims.Nil",
"Prims.bool",
"FStar.Seq.Base.init_aux",
"FStar.Seq.Base.seq"
] | [] | false | false | false | false | false | let init #_ len contents =
| if len = 0 then MkSeq [] else init_aux len 0 contents | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.