effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.Pervasives.Lemma | val modifies_remove_fresh_frame (h1 h2 h3: HS.mem) (l: loc)
: Lemma
(requires
(HS.fresh_frame h1 h2 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h2)) l) h2 h3))
(ensures (modifies l h1 h3))
[SMTPat (modifies l h1 h3); SMTPat (HS.fresh_frame h1 h2)] | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_remove_fresh_frame (h1 h2 h3:HS.mem) (l:loc)
: Lemma (requires (HS.fresh_frame h1 h2 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h2)) l) h2 h3))
(ensures (modifies l h1 h3))
[SMTPat (modifies l h1 h3); SMTPat (HS.fresh_frame h1 h2)]
= loc_regions_unused_in h1 (HS.mod_set (Set.singleton (HS.get_tip h2)));
modifies_only_not_unused_in l h1 h3 | val modifies_remove_fresh_frame (h1 h2 h3: HS.mem) (l: loc)
: Lemma
(requires
(HS.fresh_frame h1 h2 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h2)) l) h2 h3))
(ensures (modifies l h1 h3))
[SMTPat (modifies l h1 h3); SMTPat (HS.fresh_frame h1 h2)]
let modifies_remove_fresh_frame (h1 h2 h3: HS.mem) (l: loc)
: Lemma
(requires
(HS.fresh_frame h1 h2 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h2)) l) h2 h3))
(ensures (modifies l h1 h3))
[SMTPat (modifies l h1 h3); SMTPat (HS.fresh_frame h1 h2)] = | false | null | true | loc_regions_unused_in h1 (HS.mod_set (Set.singleton (HS.get_tip h2)));
modifies_only_not_unused_in l h1 h3 | {
"checked_file": "LowStar.Monotonic.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [
"lemma"
] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.loc",
"LowStar.Monotonic.Buffer.modifies_only_not_unused_in",
"Prims.unit",
"LowStar.Monotonic.Buffer.loc_regions_unused_in",
"FStar.Monotonic.HyperHeap.mod_set",
"FStar.Set.singleton",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Monotonic.HyperStack.get_tip",
"Prims.l_and",
"FStar.Monotonic.HyperStack.fresh_frame",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_all_regions_from",
"Prims.squash",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.logical",
"Prims.Nil"
] | [] | (*
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 LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b
let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b
/// For functional correctness, buffers are reflected at the proof
/// level using sequences, via ``as_seq b h``, which returns the
/// contents of a given buffer ``b`` in a given heap ``h``. If ``b`` is not
/// live in ``h``, then the result is unspecified.
(* TODO: why not return a lseq and remove length_as_seq lemma? *)
val as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot (Seq.seq a)
/// The contents of a buffer ``b`` has the same length as ``b`` itself.
val length_as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (Seq.length (as_seq h b) == length b)
[SMTPat (Seq.length (as_seq h b))]
/// ``get`` is an often-convenient shorthand to index the value of a
/// given buffer in a given heap, for proof purposes.
let get (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (p:mbuffer a rrel rel) (i:nat)
:Ghost a (requires (i < length p)) (ensures (fun _ -> True))
= Seq.index (as_seq h p) i
/// Injectivity in the first preorder
val mbuffer_injectivity_in_first_preorder (_:unit)
: Lemma (forall (a:Type0) (rrel1 rrel2 rel1 rel2:srel a)
(b1:mbuffer a rrel1 rel1)
(b2:mbuffer a rrel2 rel2).
rrel1 =!= rrel2 ==> ~ (b1 === b2))
/// Before defining sub-buffer related API, we need to define the notion of "compatibility"
///
///
/// Sub-buffers can be taken at a different preorder than their parent buffers
/// But we need to ensure that the changes to the sub-buffer are compatible with the preorder
/// of the parent buffer, and vice versa.
(*
* The quantifiers are fiercely guarded, so if you are working directly with them,
* you may have to write additional asserts as triggers
*)
[@@"opaque_to_smt"]
unfold let compatible_sub
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t{U32.v i + U32.v len <= length b}) (sub_rel:srel a)
= compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel
/// ``gsub`` is the way to carve a sub-buffer out of a given
/// buffer. ``gsub b i len`` return the sub-buffer of ``b`` starting from
/// offset ``i`` within ``b``, and with length ``len``. Of course ``i`` and
/// ``len`` must fit within the length of ``b``.
///
/// Further the clients can attach a preorder with the subbuffer (sub_rel),
/// provided it is compatible
///
/// ``gsub`` is the ghost version, for proof purposes. Its stateful
/// counterpart is ``sub``, see below.
val mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Ghost (mbuffer a rrel sub_rel)
(requires (U32.v i + U32.v len <= length b))
(ensures (fun _ -> True))
// goffset
/// A buffer is live exactly at the same time as all of its sub-buffers.
val live_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b /\ compatible_sub b i len sub_rel))
(ensures (live h b <==> (live h (mgsub sub_rel b i len) /\ (exists h0 . {:pattern (live h0 b)} live h0 b))))
[SMTPatOr [
[SMTPat (live h (mgsub sub_rel b i len))];
[SMTPat (live h b); SMTPat (mgsub sub_rel b i len);]
]]
val gsub_is_null (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (g_is_null (mgsub sub_rel b i len) <==> g_is_null b))
[SMTPat (g_is_null (mgsub sub_rel b i len))]
/// The length of a sub-buffer is exactly the one provided at ``gsub``.
val len_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len':U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len' <= length b))
(ensures (len (mgsub sub_rel b i len') == len'))
[SMTPatOr [
[SMTPat (len (mgsub sub_rel b i len'))];
[SMTPat (length (mgsub sub_rel b i len'))];
]]
val frameOf_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (frameOf (mgsub sub_rel b i len) == frameOf b))
[SMTPat (frameOf (mgsub sub_rel b i len))]
val as_addr_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_addr (mgsub sub_rel b i len) == as_addr b))
[SMTPat (as_addr (mgsub sub_rel b i len))]
val mgsub_inj (#a:Type0) (#rrel #rel:srel a) (sub_rel1 sub_rel2:srel a)
(b1 b2:mbuffer a rrel rel)
(i1 i2:U32.t)
(len1 len2:U32.t)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b1 /\
U32.v i2 + U32.v len2 <= length b2 /\
mgsub sub_rel1 b1 i1 len1 === mgsub sub_rel2 b2 i2 len2))
(ensures (len1 == len2 /\ (b1 == b2 ==> i1 == i2) /\ ((i1 == i2 /\ length b1 == length b2) ==> b1 == b2)))
/// Nesting two ``gsub`` collapses into one ``gsub``, transitively.
val gsub_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i1:U32.t) (len1:U32.t) (sub_rel1:srel a)
(i2: U32.t) (len2: U32.t) (sub_rel2:srel a)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b /\
U32.v i2 + U32.v len2 <= U32.v len1))
(ensures (((compatible_sub b i1 len1 sub_rel1 /\ compatible_sub (mgsub sub_rel1 b i1 len1) i2 len2 sub_rel2) ==> compatible_sub b (U32.add i1 i2) len2 sub_rel2) /\
mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2 == mgsub sub_rel2 b (U32.add i1 i2) len2))
[SMTPat (mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2)]
/// A buffer ``b`` is equal to its "largest" sub-buffer, at index 0 and
/// length ``len b``.
val gsub_zero_length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (compatible_sub b 0ul (len b) rel /\ b == mgsub rel b 0ul (len b))
/// The contents of a sub-buffer is the corresponding slice of the
/// contents of its enclosing buffer.
val as_seq_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_seq h (mgsub sub_rel b i len) == Seq.slice (as_seq h b) (U32.v i) (U32.v i + U32.v len)))
[SMTPat (as_seq h (mgsub sub_rel b i len))]
/// Two live non-null buffers having the same region and address have
/// their elements of the same type.
val live_same_addresses_equal_types_and_preorders
(#a1 #a2: Type0)
(#rrel1 #rel1: srel a1)
(#rrel2 #rel2: srel a2)
(b1: mbuffer a1 rrel1 rel1)
(b2: mbuffer a2 rrel2 rel2)
(h: HS.mem)
: Lemma
((frameOf b1 == frameOf b2 /\ as_addr b1 == as_addr b2 /\ live h b1 /\ live h b2 /\ (~ (g_is_null b1 /\ g_is_null b2))) ==> (a1 == a2 /\ rrel1 == rrel2))
/// # The modifies clause
///
/// The modifies clause for regions, references and buffers.
/// ==========================================================
///
/// This module presents the modifies clause, a way to track the set
/// of memory locations modified by a stateful Low* (or even F*)
/// program. The basic principle of modifies clauses is that any
/// location that is disjoint from a set of memory locations modified
/// by an operation is preserved by that operation.
///
/// We start by specifying a monoid of sets of memory locations. From
/// a rough high-level view, ``loc`` is the type of sets of memory
/// locations, equipped with an identity element ``loc_none``,
/// representing the empty set, and an associative and commutative
/// operator, ``loc_union``, representing the union of two sets of
/// memory locations.
///
/// Moreover, ``loc_union`` is idempotent, which is useful to cut SMT
/// matching loops with ``modifies_trans`` and ``modifies_refl`` below.
val loc : Type0
val loc_none: loc
val loc_union
(s1 s2: loc)
: GTot loc
val loc_union_idem
(s: loc)
: Lemma
(loc_union s s == s)
[SMTPat (loc_union s s)]
val loc_union_comm
(s1 s2: loc)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
[SMTPat (loc_union s1 s2)]
val loc_union_assoc
(s1 s2 s3: loc)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
let loc_union_idem_1
(s1 s2: loc)
: Lemma
(loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))]
= loc_union_assoc s1 s1 s2
let loc_union_idem_2
(s1 s2: loc)
: Lemma
(loc_union (loc_union s1 s2) s2 == loc_union s1 s2)
[SMTPat (loc_union (loc_union s1 s2) s2)]
= loc_union_assoc s1 s2 s2
val loc_union_loc_none_l
(s: loc)
: Lemma
(loc_union loc_none s == s)
[SMTPat (loc_union loc_none s)]
val loc_union_loc_none_r
(s: loc)
: Lemma
(loc_union s loc_none == s)
[SMTPat (loc_union s loc_none)]
/// ``loc_buffer b`` is the set of memory locations associated to a buffer ``b``.
val loc_buffer_from_to (#a:Type0) (#rrel #rel:srel a) (b: mbuffer a rrel rel) (from to: U32.t) : GTot loc
val loc_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc
val loc_buffer_eq (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) : Lemma
(loc_buffer b == loc_buffer_from_to b 0ul (len b))
val loc_buffer_from_to_high (#a: Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (length b <= U32.v to))
(ensures (loc_buffer_from_to b from to == loc_buffer_from_to b from (len b)))
val loc_buffer_from_to_none (#a: Type) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (g_is_null b \/ length b < U32.v from \/ U32.v to < U32.v from))
(ensures (loc_buffer_from_to b from to == loc_none))
val loc_buffer_from_to_mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
(from to: U32.t)
: Lemma
(requires (
U32.v i + U32.v len <= length b /\
U32.v from <= U32.v to /\ U32.v to <= U32.v len
))
(ensures (
loc_buffer_from_to (mgsub sub_rel b i len) from to == loc_buffer_from_to b (i `U32.add` from) (i `U32.add` to)
))
val loc_buffer_mgsub_eq (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub sub_rel b i len) == loc_buffer_from_to b i (i `U32.add` len)))
val loc_buffer_null (a:Type0) (rrel rel:srel a)
:Lemma (loc_buffer (mnull #a #rrel #rel) == loc_none)
[SMTPat (loc_buffer (mnull #a #rrel #rel))]
val loc_buffer_from_to_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(from to: U32.t)
: Lemma
(requires (U32.v from <= U32.v to /\ U32.v to <= length b))
(ensures (loc_buffer_from_to b from to == loc_buffer (mgsub rel b from (to `U32.sub` from))))
[SMTPat (loc_buffer_from_to b from to)]
val loc_buffer_mgsub_rel_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(rel1 rel2: srel a)
(i len: U32.t)
: Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub rel1 b i len) == loc_buffer (mgsub rel2 b i len)))
[SMTPat (loc_buffer (mgsub rel1 b i len)); SMTPat (loc_buffer (mgsub rel2 b i len))]
/// ``loc_addresses r n`` is the set of memory locations associated to a
/// set of addresses ``n`` in a given region ``r``.
val loc_addresses
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot loc
unfold let loc_addr_of_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc =
loc_addresses false (frameOf b) (Set.singleton (as_addr b))
/// ``loc_regions r`` is the set of memory locations associated to a set
/// ``r`` of regions.
val loc_regions
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot loc
/// ``loc_mreference b`` is the set of memory locations associated to a
/// reference ``b``, which is actually the set of memory locations
/// associated to the address of ``b``.
unfold
let loc_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
unfold
let loc_freed_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
/// ``loc_region_only r`` is the set of memory locations associated to a
/// region ``r`` but not any region ``r'`` that extends ``r`` (in the sense
/// of ``FStar.HyperStack.extends``.)
unfold
let loc_region_only
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (Set.singleton r)
/// ``loc_all_regions_from r`` is the set of all memory locations
/// associated to a region ``r`` and any region ``r'`` that transitively
/// extends ``r`` (in the sense of ``FStar.HyperStack.extends``,
/// e.g. nested stack frames.)
unfold
let loc_all_regions_from
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (HS.mod_set (Set.singleton r))
/// We equip the ``loc`` monoid of sets of memory locations with an
/// inclusion relation, ``loc_includes``, which is a preorder compatible
/// with ``loc_union``. Although we consider sets of memory locations,
/// we do not specify them using any F* set library such as
/// ``FStar.Set``, ``FStar.TSet`` or ``FStar.GSet``, because ``loc_includes``
/// encompasses more than just set-theoretic inclusion.
val loc_includes
(s1 s2: loc)
: GTot Type0
val loc_includes_refl
(s: loc)
: Lemma
(loc_includes s s)
[SMTPat (loc_includes s s)]
val loc_includes_trans
(s1 s2 s3: loc)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
let loc_includes_trans_backwards
(s1 s2 s3: loc)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
[SMTPat (loc_includes s1 s3); SMTPat (loc_includes s2 s3)]
= loc_includes_trans s1 s2 s3
val loc_includes_union_r
(s s1 s2: loc)
: Lemma
(requires (loc_includes s s1 /\ loc_includes s s2))
(ensures (loc_includes s (loc_union s1 s2)))
val loc_includes_union_l
(s1 s2 s: loc)
: Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
let loc_includes_union_l'
(s1 s2 s: loc)
: Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
[SMTPat (loc_includes (loc_union s1 s2) s)]
= loc_includes_union_l s1 s2 s
let loc_includes_union_r'
(s s1 s2: loc)
: Lemma
(loc_includes s (loc_union s1 s2) <==> (loc_includes s s1 /\ loc_includes s s2))
[SMTPat (loc_includes s (loc_union s1 s2))]
= Classical.move_requires (loc_includes_union_r s s1) s2;
Classical.move_requires (loc_includes_union_l s1 s2) s1;
Classical.move_requires (loc_includes_union_l s1 s2) s2;
Classical.move_requires (loc_includes_trans s (loc_union s1 s2)) s1;
Classical.move_requires (loc_includes_trans s (loc_union s1 s2)) s2
val loc_includes_none
(s: loc)
: Lemma
(loc_includes s loc_none)
[SMTPat (loc_includes s loc_none)]
/// If a buffer ``b1`` includes a buffer ``b2`` in the sense of the buffer
/// theory (see ``LowStar.Buffer.includes``), then so are their
/// corresponding sets of memory locations.
val loc_includes_gsub_buffer_r
(l:loc)
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:UInt32.t) (len:UInt32.t) (sub_rel:srel a)
: Lemma (requires (UInt32.v i + UInt32.v len <= (length b) /\
loc_includes l (loc_buffer b)))
(ensures (loc_includes l (loc_buffer (mgsub sub_rel b i len))))
[SMTPat (loc_includes l (loc_buffer (mgsub sub_rel b i len)))]
let loc_includes_gsub_buffer_r' (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:UInt32.t) (len:UInt32.t) (sub_rel:srel a)
:Lemma (requires (UInt32.v i + UInt32.v len <= (length b)))
(ensures (loc_includes (loc_buffer b) (loc_buffer (mgsub sub_rel b i len))))
[SMTPat (mgsub sub_rel b i len)]
= ()
val loc_includes_gsub_buffer_l (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
(i1:UInt32.t) (len1:UInt32.t) (sub_rel1:srel a)
(i2:UInt32.t) (len2:UInt32.t) (sub_rel2:srel a)
:Lemma (requires (UInt32.v i1 + UInt32.v len1 <= (length b) /\
UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1
))
(ensures (loc_includes (loc_buffer (mgsub sub_rel1 b i1 len1)) (loc_buffer (mgsub sub_rel2 b i2 len2))))
[SMTPat (mgsub sub_rel1 b i1 len1); SMTPat (mgsub sub_rel2 b i2 len2)]
val loc_includes_loc_buffer_loc_buffer_from_to
(#a: _) (#rrel #rel: _)
(b: mbuffer a rrel rel)
(from to: U32.t)
: Lemma
(loc_includes (loc_buffer b) (loc_buffer_from_to b from to))
val loc_includes_loc_buffer_from_to
(#a: _) (#rrel #rel: _)
(b: mbuffer a rrel rel)
(from1 to1 from2 to2: U32.t)
: Lemma
(requires (U32.v from1 <= U32.v from2 /\ U32.v to2 <= U32.v to1))
(ensures (loc_includes (loc_buffer_from_to b from1 to1) (loc_buffer_from_to b from2 to2)))
/// If the contents of a buffer are equal in two given heaps, then so
/// are the contents of any of its sub-buffers.
val loc_includes_as_seq (#a:Type0) (#rrel #rel1 #rel2:srel a)
(h1 h2:HS.mem) (larger:mbuffer a rrel rel1) (smaller:mbuffer a rrel rel2)
:Lemma (requires (loc_includes (loc_buffer larger) (loc_buffer smaller) /\
as_seq h1 larger == as_seq h2 larger /\
(live h1 larger \/ live h1 smaller) /\ (live h2 larger \/ live h2 smaller)))
(ensures (as_seq h1 smaller == as_seq h2 smaller))
/// Given a buffer ``b``, if its address is in a set ``s`` of addresses in
/// the region of ``b``, then the set of memory locations corresponding
/// to ``b`` is included in the set of memory locations corresponding to
/// the addresses in ``s`` in region ``r``.
///
/// In particular, the set of memory locations corresponding to a
/// buffer is included in the set of memory locations corresponding to
/// its region and address.
val loc_includes_addresses_buffer (#a:Type0) (#rrel #rel:srel a)
(preserve_liveness:bool) (r:HS.rid) (s:Set.set nat) (p:mbuffer a rrel rel)
:Lemma (requires (frameOf p == r /\ Set.mem (as_addr p) s))
(ensures (loc_includes (loc_addresses preserve_liveness r s) (loc_buffer p)))
[SMTPat (loc_includes (loc_addresses preserve_liveness r s) (loc_buffer p))]
let loc_includes_addresses_buffer' (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (loc_includes (loc_addresses true (frameOf b) (Set.singleton (as_addr b))) (loc_buffer b))
[SMTPat (loc_buffer b)]
= ()
/// The set of memory locations corresponding to a buffer is included
/// in the set of memory locations corresponding to its region.
val loc_includes_region_buffer (#a:Type0) (#rrel #rel:srel a)
(preserve_liveness:bool) (s:Set.set HS.rid) (b:mbuffer a rrel rel)
:Lemma (requires (Set.mem (frameOf b) s))
(ensures (loc_includes (loc_regions preserve_liveness s) (loc_buffer b)))
[SMTPat (loc_includes (loc_regions preserve_liveness s) (loc_buffer b))]
let loc_includes_region_buffer' (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (loc_includes (loc_regions true (Set.singleton (frameOf b))) (loc_buffer b))
[SMTPat (loc_buffer b)]
= ()
/// If a region ``r`` is in a set of regions ``s``, then the set of memory
/// locations corresponding to a set of addresses ``a`` in ``r`` is
/// included in the set of memory locations corresponding to the
/// regions in ``s``.
///
/// In particular, the the set of memory locations corresponding to a
/// set of addresses ``a`` in a given region ``r`` is included in the set
/// of memory locations corresponding to region ``r``.
val loc_includes_region_addresses
(preserve_liveness1: bool)
(preserve_liveness2: bool)
(s: Set.set HS.rid)
(r: HS.rid)
(a: Set.set nat)
: Lemma
(requires (Set.mem r s))
(ensures (loc_includes (loc_regions preserve_liveness1 s) (loc_addresses preserve_liveness2 r a)))
[SMTPat (loc_includes (loc_regions preserve_liveness1 s) (loc_addresses preserve_liveness2 r a))]
let loc_includes_region_addresses'
(preserve_liveness: bool)
(r: HS.rid)
(a: Set.set nat)
: Lemma
(loc_includes (loc_regions true (Set.singleton r)) (loc_addresses preserve_liveness r a))
[SMTPat (loc_addresses preserve_liveness r a)]
= ()
/// If a set of region identifiers ``s1`` includes a set of region
/// identifiers ``s2``, then so are their corresponding sets of memory
/// locations.
val loc_includes_region_region
(preserve_liveness1: bool)
(preserve_liveness2: bool)
(s1 s2: Set.set HS.rid)
: Lemma
(requires ((preserve_liveness1 ==> preserve_liveness2) /\ Set.subset s2 s1))
(ensures (loc_includes (loc_regions preserve_liveness1 s1) (loc_regions preserve_liveness2 s2)))
[SMTPat (loc_includes (loc_regions preserve_liveness1 s1) (loc_regions preserve_liveness2 s2))]
let loc_includes_region_region'
(preserve_liveness: bool)
(s: Set.set HS.rid)
: Lemma
(loc_includes (loc_regions false s) (loc_regions preserve_liveness s))
[SMTPat (loc_regions preserve_liveness s)]
= ()
/// The following lemma can act as a cut when reasoning with sets of
/// memory locations corresponding to sets of regions.
val loc_includes_region_union_l
(preserve_liveness: bool)
(l: loc)
(s1 s2: Set.set HS.rid)
: Lemma
(requires (loc_includes l (loc_regions preserve_liveness (Set.intersect s2 (Set.complement s1)))))
(ensures (loc_includes (loc_union (loc_regions preserve_liveness s1) l) (loc_regions preserve_liveness s2)))
[SMTPat (loc_includes (loc_union (loc_regions preserve_liveness s1) l) (loc_regions preserve_liveness s2))]
/// If a set of addresses ``s1`` includes a set of addresses ``s2``,
/// then so are their corresponding memory locations
val loc_includes_addresses_addresses
(preserve_liveness1 preserve_liveness2: bool)
(r: HS.rid)
(s1 s2: Set.set nat)
: Lemma
(requires ((preserve_liveness1 ==> preserve_liveness2) /\ Set.subset s2 s1))
(ensures (loc_includes (loc_addresses preserve_liveness1 r s1) (loc_addresses preserve_liveness2 r s2)))
let loc_includes_addresses_addresses_1
(preserve_liveness1 preserve_liveness2: bool)
(r1 r2: HS.rid)
(s1 s2: Set.set nat)
: Lemma
(requires (r1 == r2 /\ (preserve_liveness1 ==> preserve_liveness2) /\ Set.subset s2 s1))
(ensures (loc_includes (loc_addresses preserve_liveness1 r1 s1) (loc_addresses preserve_liveness2 r2 s2)))
[SMTPat (loc_includes (loc_addresses preserve_liveness1 r1 s1) (loc_addresses preserve_liveness2 r2 s2))]
= loc_includes_addresses_addresses preserve_liveness1 preserve_liveness2 r1 s1 s2
let loc_includes_addresses_addresses_2
(preserve_liveness: bool)
(r: HS.rid)
(s: Set.set nat)
: Lemma
(loc_includes (loc_addresses false r s) (loc_addresses preserve_liveness r s))
[SMTPat (loc_addresses preserve_liveness r s)]
= ()
/// Patterns with loc_includes, union on the left
let loc_includes_union_l_buffer
(s1 s2:loc)
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
:Lemma (requires (loc_includes s1 (loc_buffer b) \/ loc_includes s2 (loc_buffer b)))
(ensures (loc_includes (loc_union s1 s2) (loc_buffer b)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_buffer b))]
= loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_union_l_addresses
(s1 s2: loc)
(prf: bool)
(r: HS.rid)
(a: Set.set nat)
: Lemma
(requires (loc_includes s1 (loc_addresses prf r a) \/ loc_includes s2 (loc_addresses prf r a)))
(ensures (loc_includes (loc_union s1 s2) (loc_addresses prf r a)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_addresses prf r a))]
= loc_includes_union_l s1 s2 (loc_addresses prf r a)
let loc_includes_union_l_regions
(s1 s2: loc)
(prf: bool)
(r: Set.set HS.rid)
: Lemma
(requires (loc_includes s1 (loc_regions prf r) \/ loc_includes s2 (loc_regions prf r)))
(ensures (loc_includes (loc_union s1 s2) (loc_regions prf r)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_regions prf r))]
= loc_includes_union_l s1 s2 (loc_regions prf r)
/// Since inclusion encompasses more than just set-theoretic
/// inclusion, we also need to specify disjointness accordingly, as a
/// symmetric relation compatible with union.
val loc_disjoint
(s1 s2: loc)
: GTot Type0
val loc_disjoint_sym
(s1 s2: loc)
: Lemma
(requires (loc_disjoint s1 s2))
(ensures (loc_disjoint s2 s1))
let loc_disjoint_sym'
(s1 s2: loc)
: Lemma
(loc_disjoint s1 s2 <==> loc_disjoint s2 s1)
[SMTPat (loc_disjoint s1 s2)]
= Classical.move_requires (loc_disjoint_sym s1) s2;
Classical.move_requires (loc_disjoint_sym s2) s1
val loc_disjoint_none_r
(s: loc)
: Lemma
(ensures (loc_disjoint s loc_none))
[SMTPat (loc_disjoint s loc_none)]
val loc_disjoint_union_r
(s s1 s2: loc)
: Lemma
(requires (loc_disjoint s s1 /\ loc_disjoint s s2))
(ensures (loc_disjoint s (loc_union s1 s2)))
/// If two sets of memory locations are disjoint, then so are any two
/// included sets of memory locations.
val loc_disjoint_includes
(p1 p2 p1' p2' : loc)
: Lemma
(requires (loc_includes p1 p1' /\ loc_includes p2 p2' /\ loc_disjoint p1 p2))
(ensures (loc_disjoint p1' p2'))
let loc_disjoint_union_r'
(s s1 s2: loc)
: Lemma
(ensures (loc_disjoint s (loc_union s1 s2) <==> (loc_disjoint s s1 /\ loc_disjoint s s2)))
[SMTPat (loc_disjoint s (loc_union s1 s2))]
= Classical.move_requires (loc_disjoint_union_r s s1) s2;
loc_includes_union_l s1 s2 s1;
loc_includes_union_l s1 s2 s2;
Classical.move_requires (loc_disjoint_includes s (loc_union s1 s2) s) s1;
Classical.move_requires (loc_disjoint_includes s (loc_union s1 s2) s) s2
let loc_disjoint_includes_r (b1 : loc) (b2 b2': loc) : Lemma
(requires (loc_includes b2 b2' /\ loc_disjoint b1 b2))
(ensures (loc_disjoint b1 b2'))
[SMTPat (loc_disjoint b1 b2'); SMTPat (loc_includes b2 b2')]
= loc_disjoint_includes b1 b2 b1 b2'
val loc_disjoint_gsub_buffer (#a:Type0) (#rrel:srel a) (#rel:srel a)
(b:mbuffer a rrel rel)
(i1:UInt32.t) (len1:UInt32.t) (sub_rel1:srel a)
(i2:UInt32.t) (len2:UInt32.t) (sub_rel2:srel a)
:Lemma (requires (UInt32.v i1 + UInt32.v len1 <= (length b) /\
UInt32.v i2 + UInt32.v len2 <= (length b) /\
(UInt32.v i1 + UInt32.v len1 <= UInt32.v i2 \/
UInt32.v i2 + UInt32.v len2 <= UInt32.v i1)))
(ensures (loc_disjoint (loc_buffer (mgsub sub_rel1 b i1 len1)) (loc_buffer (mgsub sub_rel2 b i2 len2))))
[SMTPat (mgsub sub_rel1 b i1 len1); SMTPat (mgsub sub_rel2 b i2 len2)]
val loc_disjoint_loc_buffer_from_to
(#a: _) (#rrel #rel: _)
(b: mbuffer a rrel rel)
(from1 to1 from2 to2: U32.t)
: Lemma
(requires (U32.v to1 <= U32.v from2 \/ U32.v to2 <= U32.v from1))
(ensures (loc_disjoint (loc_buffer_from_to b from1 to1) (loc_buffer_from_to b from2 to2)))
/// If two sets of addresses correspond to different regions or are
/// disjoint, then their corresponding sets of memory locations are
/// disjoint.
val loc_disjoint_addresses
(preserve_liveness1 preserve_liveness2: bool)
(r1 r2: HS.rid)
(n1 n2: Set.set nat)
: Lemma
(requires (r1 <> r2 \/ Set.subset (Set.intersect n1 n2) Set.empty))
(ensures (loc_disjoint (loc_addresses preserve_liveness1 r1 n1) (loc_addresses preserve_liveness2 r2 n2)))
[SMTPat (loc_disjoint (loc_addresses preserve_liveness1 r1 n1) (loc_addresses preserve_liveness2 r2 n2))]
/// If two sets of region identifiers are disjoint, then so are their
/// corresponding sets of memory locations.
val loc_disjoint_regions
(preserve_liveness1: bool)
(preserve_liveness2: bool)
(rs1 rs2: Set.set HS.rid)
: Lemma
(requires (Set.subset (Set.intersect rs1 rs2) Set.empty))
(ensures (loc_disjoint (loc_regions preserve_liveness1 rs1) (loc_regions preserve_liveness2 rs2)))
[SMTPat (loc_disjoint (loc_regions preserve_liveness1 rs1) (loc_regions preserve_liveness2 rs2))]
/// Some utilities to work with lists of buffers and locs
(* buf_t is a `buffer` at some type `a` *)
let buf_t = a:Type0 & rrel:srel a & rel:srel a & mbuffer a rrel rel
(* A convenience to construct a buf_t *)
[@@BigOps.__reduce__]
let buf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) : buf_t = (|a, rrel, rel, b|)
(* A conjunction of liveness conditions on the buffers in `l`
Implicitly reduced at typechecking time *)
[@@"opaque_to_smt"]
unfold
let all_live (h:HS.mem) (l:list buf_t) : Type0 =
BigOps.big_and #buf_t (fun (| _, _, _, b |) -> live h b) l
(* Pairwise disjointness of locations;
Implicitly reduced at typechecking time *)
[@@"opaque_to_smt"]
unfold
let all_disjoint (l:list loc) : Type0 =
BigOps.pairwise_and loc_disjoint l
(* Union of a list of locations;
Implicitly reduced at typechecking time *)
[@@"opaque_to_smt"]
unfold
let loc_union_l (l:list loc) =
BigOps.normal (List.Tot.fold_right_gtot l loc_union loc_none)
(*
* Same as all_disjoint, retaining for backward compatibility
*)
[@@"opaque_to_smt"]
unfold
let loc_pairwise_disjoint (l:list loc) :Type0 = BigOps.pairwise_and loc_disjoint l
/// The modifies clauses proper.
///
/// Let ``s`` be a set of memory locations, and ``h1`` and ``h2`` be two
/// memory states. Then, ``s`` is modified from ``h1`` to ``h2`` only if,
/// any memory location disjoint from ``s`` is preserved from ``h1`` into
/// ``h2``. Elimination lemmas illustrating this principle follow.
val modifies
(s: loc)
(h1 h2: HS.mem)
: GTot Type0
/// If a region ``r`` is disjoint from a set ``s`` of memory locations
/// which is modified, then its liveness is preserved.
val modifies_live_region
(s: loc)
(h1 h2: HS.mem)
(r: HS.rid)
: Lemma
(requires (modifies s h1 h2 /\ loc_disjoint s (loc_region_only false r) /\ HS.live_region h1 r))
(ensures (HS.live_region h2 r))
[SMTPatOr [
[SMTPat (modifies s h1 h2); SMTPat (HS.live_region h1 r)];
[SMTPat (modifies s h1 h2); SMTPat (HS.live_region h2 r)];
]]
/// If a reference ``b`` is disjoint from a set ``p`` of memory locations
/// which is modified, then its liveness and contents are preserved.
val modifies_mreference_elim
(#t: Type)
(#pre: Preorder.preorder t)
(b: HS.mreference t pre)
(p: loc)
(h h': HS.mem)
: Lemma
(requires (
loc_disjoint (loc_mreference b) p /\
HS.contains h b /\
modifies p h h'
))
(ensures (
HS.contains h' b /\
HS.sel h b == HS.sel h' b
))
[SMTPatOr [
[ SMTPat (modifies p h h'); SMTPat (HS.sel h b) ] ;
[ SMTPat (modifies p h h'); SMTPat (HS.contains h b) ];
[ SMTPat (modifies p h h'); SMTPat (HS.sel h' b) ] ;
[ SMTPat (modifies p h h'); SMTPat (HS.contains h' b) ]
] ]
/// If a buffer ``b`` is disjoint from a set ``p`` of
/// memory locations which is modified, then its liveness and contents
/// are preserved.
val modifies_buffer_elim (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (p:loc) (h h':HS.mem)
:Lemma (requires (loc_disjoint (loc_buffer b) p /\ live h b /\ modifies p h h'))
(ensures (live h' b /\ (as_seq h b == as_seq h' b)))
[SMTPatOr [
[ SMTPat (modifies p h h'); SMTPat (as_seq h b) ] ;
[ SMTPat (modifies p h h'); SMTPat (live h b) ];
[ SMTPat (modifies p h h'); SMTPat (as_seq h' b) ] ;
[ SMTPat (modifies p h h'); SMTPat (live h' b) ]
]]
val modifies_buffer_from_to_elim (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (from to: U32.t) (p:loc) (h h':HS.mem)
:Lemma (requires (loc_disjoint (loc_buffer_from_to b from to) p /\ live h b /\ modifies p h h' /\ U32.v from <= U32.v to /\ U32.v to <= length b))
(ensures (live h' b /\ Seq.slice (as_seq h b) (U32.v from) (U32.v to) == Seq.slice (as_seq h' b) (U32.v from) (U32.v to)))
/// If the memory state does not change, then any memory location is
/// modified (and, in particular, the empty set, ``loc_none``.)
val modifies_refl
(s: loc)
(h: HS.mem)
: Lemma
(modifies s h h)
[SMTPat (modifies s h h)]
/// If a set ``s2`` of memory locations is modified, then so is any set
/// ``s1`` that includes ``s2``. In other words, it is always possible to
/// weaken a modifies clause by widening its set of memory locations.
val modifies_loc_includes
(s1: loc)
(h h': HS.mem)
(s2: loc)
: Lemma
(requires (modifies s2 h h' /\ loc_includes s1 s2))
(ensures (modifies s1 h h'))
[SMTPat (modifies s1 h h'); SMTPat (modifies s2 h h')]
/// Some memory locations are tagged as liveness-insensitive: the
/// liveness preservation of a memory location only depends on its
/// disjointness from the liveness-sensitive memory locations of a
/// modifies clause.
val address_liveness_insensitive_locs: loc
val region_liveness_insensitive_locs: loc
val address_liveness_insensitive_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (address_liveness_insensitive_locs `loc_includes` (loc_buffer b))
[SMTPat (address_liveness_insensitive_locs `loc_includes` (loc_buffer b))]
val address_liveness_insensitive_addresses (r: HS.rid) (a: Set.set nat) : Lemma
(address_liveness_insensitive_locs `loc_includes` (loc_addresses true r a))
[SMTPat (address_liveness_insensitive_locs `loc_includes` (loc_addresses true r a))]
val region_liveness_insensitive_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (region_liveness_insensitive_locs `loc_includes` (loc_buffer b))
[SMTPat (region_liveness_insensitive_locs `loc_includes` (loc_buffer b))]
val region_liveness_insensitive_addresses (preserve_liveness: bool) (r: HS.rid) (a: Set.set nat) : Lemma
(region_liveness_insensitive_locs `loc_includes` (loc_addresses preserve_liveness r a))
[SMTPat (region_liveness_insensitive_locs `loc_includes` (loc_addresses preserve_liveness r a))]
val region_liveness_insensitive_regions (rs: Set.set HS.rid) : Lemma
(region_liveness_insensitive_locs `loc_includes` (loc_regions true rs))
[SMTPat (region_liveness_insensitive_locs `loc_includes` (loc_regions true rs))]
val region_liveness_insensitive_address_liveness_insensitive:
squash (region_liveness_insensitive_locs `loc_includes` address_liveness_insensitive_locs)
val modifies_liveness_insensitive_mreference
(l1 l2 : loc)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(x: HS.mreference t pre)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ loc_disjoint l1 (loc_mreference x) /\ address_liveness_insensitive_locs `loc_includes` l2 /\ h `HS.contains` x))
(ensures (h' `HS.contains` x))
[SMTPatOr [
[SMTPat (h `HS.contains` x); SMTPat (modifies (loc_union l1 l2) h h');];
[SMTPat (h' `HS.contains` x); SMTPat (modifies (loc_union l1 l2) h h');];
]]
(* TODO: pattern *)
val modifies_liveness_insensitive_buffer
(l1 l2:loc)
(h h':HS.mem)
(#a:Type0) (#rrel #rel:srel a)
(x:mbuffer a rrel rel)
:Lemma (requires (modifies (loc_union l1 l2) h h' /\
loc_disjoint l1 (loc_buffer x) /\
address_liveness_insensitive_locs `loc_includes` l2 /\
live h x))
(ensures (live h' x))
[SMTPatOr [
[SMTPat (live h x); SMTPat (modifies (loc_union l1 l2) h h');];
[SMTPat (live h' x); SMTPat (modifies (loc_union l1 l2) h h');];
]]
let modifies_liveness_insensitive_mreference_weak
(l : loc)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(x: HS.mreference t pre)
: Lemma (requires (modifies l h h' /\
address_liveness_insensitive_locs `loc_includes` l /\
h `HS.contains` x))
(ensures (h' `HS.contains` x))
[SMTPatOr [
[SMTPat (h `HS.contains` x); SMTPat (modifies l h h');];
[SMTPat (h' `HS.contains` x); SMTPat (modifies l h h');];
]]
= modifies_liveness_insensitive_mreference loc_none l h h' x
let modifies_liveness_insensitive_buffer_weak
(l:loc)
(h h':HS.mem)
(#a:Type0) (#rrel #rel:srel a)
(x:mbuffer a rrel rel)
:Lemma (requires (modifies l h h' /\ address_liveness_insensitive_locs `loc_includes` l /\ live h x))
(ensures (live h' x))
[SMTPatOr [
[SMTPat (live h x); SMTPat (modifies l h h');];
[SMTPat (live h' x); SMTPat (modifies l h h');];
]]
= modifies_liveness_insensitive_buffer loc_none l h h' x
val modifies_liveness_insensitive_region
(l1 l2 : loc)
(h h' : HS.mem)
(x: HS.rid)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ loc_disjoint l1 (loc_region_only false x) /\ region_liveness_insensitive_locs `loc_includes` l2 /\ HS.live_region h x))
(ensures (HS.live_region h' x))
[SMTPatOr [
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h x)];
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h' x)];
]]
val modifies_liveness_insensitive_region_mreference
(l1 l2 : loc)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(x: HS.mreference t pre)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ loc_disjoint l1 (loc_mreference x) /\ region_liveness_insensitive_locs `loc_includes` l2 /\ HS.live_region h (HS.frameOf x)))
(ensures (HS.live_region h' (HS.frameOf x)))
[SMTPatOr [
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h (HS.frameOf x))];
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h' (HS.frameOf x))];
]]
val modifies_liveness_insensitive_region_buffer
(l1 l2:loc)
(h h':HS.mem)
(#a:Type0) (#rrel #rel:srel a)
(x:mbuffer a rrel rel)
:Lemma (requires (modifies (loc_union l1 l2) h h' /\ loc_disjoint l1 (loc_buffer x) /\ region_liveness_insensitive_locs `loc_includes` l2 /\ HS.live_region h (frameOf x)))
(ensures (HS.live_region h' (frameOf x)))
[SMTPatOr [
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h (frameOf x))];
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h' (frameOf x))];
]]
let modifies_liveness_insensitive_region_weak
(l2 : loc)
(h h' : HS.mem)
(x: HS.rid)
: Lemma
(requires (modifies l2 h h' /\ region_liveness_insensitive_locs `loc_includes` l2 /\ HS.live_region h x))
(ensures (HS.live_region h' x))
[SMTPatOr [
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h x)];
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h' x)];
]]
= modifies_liveness_insensitive_region loc_none l2 h h' x
let modifies_liveness_insensitive_region_mreference_weak
(l2 : loc)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(x: HS.mreference t pre)
: Lemma (requires (modifies l2 h h' /\
region_liveness_insensitive_locs `loc_includes` l2 /\
HS.live_region h (HS.frameOf x)))
(ensures (HS.live_region h' (HS.frameOf x)))
[SMTPatOr [
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h (HS.frameOf x))];
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h' (HS.frameOf x))];
]]
= modifies_liveness_insensitive_region_mreference loc_none l2 h h' x
let modifies_liveness_insensitive_region_buffer_weak
(l2:loc)
(h h':HS.mem)
(#a:Type0) (#rrel #rel:srel a)
(x:mbuffer a rrel rel)
:Lemma (requires (modifies l2 h h' /\
region_liveness_insensitive_locs `loc_includes` l2 /\
HS.live_region h (frameOf x)))
(ensures (HS.live_region h' (frameOf x)))
[SMTPatOr [
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h (frameOf x))];
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h' (frameOf x))];
]]
= modifies_liveness_insensitive_region_buffer loc_none l2 h h' x
/// Modifies clauses are transitive. This lemma is the most general
/// one.
val modifies_trans
(s12: loc)
(h1 h2: HS.mem)
(s23: loc)
(h3: HS.mem)
: Lemma
(requires (modifies s12 h1 h2 /\ modifies s23 h2 h3))
(ensures (modifies (loc_union s12 s23) h1 h3))
let modifies_trans_linear (l l_goal:loc) (h1 h2 h3:HS.mem)
: Lemma (requires (modifies l h1 h2 /\ modifies l_goal h2 h3 /\ l_goal `loc_includes` l))
(ensures (modifies l_goal h1 h3))
[SMTPat (modifies l h1 h2); SMTPat (modifies l_goal h1 h3)]
= modifies_trans l h1 h2 l_goal h3
/// Regions that are not live can be removed from sets of memory
/// locations that are modified.
val modifies_only_live_regions
(rs: Set.set HS.rid)
(l: loc)
(h h' : HS.mem)
: Lemma
(requires (
modifies (loc_union (loc_regions false rs) l) h h' /\
(forall r . Set.mem r rs ==> (~ (HS.live_region h r)))
))
(ensures (modifies l h h'))
/// As a consequence, fresh regions can be removed from modifies
/// clauses.
val no_upd_fresh_region: r:HS.rid -> l:loc -> h0:HS.mem -> h1:HS.mem -> Lemma
(requires (HS.fresh_region r h0 h1 /\ modifies (loc_union (loc_all_regions_from false r) l) h0 h1))
(ensures (modifies l h0 h1))
[SMTPat (HS.fresh_region r h0 h1); SMTPat (modifies l h0 h1)]
val new_region_modifies (m0: HS.mem) (r0: HS.rid) (col: option int) : Lemma
(requires (HST.is_eternal_region r0 /\ HS.live_region m0 r0 /\ (None? col \/ HS.is_heap_color (Some?.v col))))
(ensures (
let (_, m1) = HS.new_eternal_region m0 r0 col in
modifies loc_none m0 m1
))
[SMTPat (HS.new_eternal_region m0 r0 col)]
/// Stack discipline: any stack frame (and all its transitively
/// extending regions) that is pushed, modified and popped can be
/// removed from a modifies clause.
/// AR: 01/29/2019: Removing the smt pattern from this lemma.
/// Clients are no longer expected to call it explicitly,
/// if you are having to, please raise an issue.
val modifies_fresh_frame_popped
(h0 h1: HS.mem)
(s: loc)
(h2 h3: HS.mem)
: Lemma
(requires (
HS.fresh_frame h0 h1 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h1)) s) h1 h2 /\
(HS.get_tip h2) == (HS.get_tip h1) /\
HS.popped h2 h3
))
(ensures (
modifies s h0 h3 /\
(HS.get_tip h3) == HS.get_tip h0
))
/// Compatibility lemmas to rescue modifies clauses specified in the
/// standard F* HyperStack library.
val modifies_loc_regions_intro
(rs: Set.set HS.rid)
(h1 h2: HS.mem)
: Lemma
(requires (HS.modifies rs h1 h2))
(ensures (modifies (loc_regions true rs) h1 h2))
val modifies_loc_addresses_intro
(r: HS.rid)
(a: Set.set nat)
(l: loc)
(h1 h2: HS.mem)
: Lemma
(requires (
HS.live_region h2 r /\
modifies (loc_union (loc_region_only false r) l) h1 h2 /\
HS.modifies_ref r a h1 h2
))
(ensures (modifies (loc_union (loc_addresses true r a) l) h1 h2))
/// Modifies clauses for allocating a reference: nothing is
/// modified. (In particular, a modifies clause does not track
/// memory locations that are created.)
val modifies_ralloc_post
(#a: Type)
(#rel: Preorder.preorder a)
(i: HS.rid)
(init: a)
(h: HS.mem)
(x: HST.mreference a rel)
(h' : HS.mem)
: Lemma
(requires (HST.ralloc_post i init h x h'))
(ensures (modifies loc_none h h'))
[SMTPat (HST.ralloc_post i init h x h')]
val modifies_salloc_post
(#a: Type)
(#rel: Preorder.preorder a)
(init: a)
(h: HS.mem)
(x: HST.mreference a rel { HS.is_stack_region (HS.frameOf x) } )
(h' : HS.mem)
: Lemma
(requires (HST.salloc_post init h x h'))
(ensures (modifies loc_none h h'))
[SMTPat (HST.salloc_post init h x h')]
/// Modifies clause for freeing a reference: the address is modified.
val modifies_free
(#a: Type)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel { HS.is_mm r } )
(m: HS.mem { m `HS.contains` r } )
: Lemma
(modifies (loc_freed_mreference r) m (HS.free r m))
[SMTPat (HS.free r m)]
/// Another compatibility lemma
val modifies_none_modifies
(h1 h2: HS.mem)
: Lemma
(requires (HST.modifies_none h1 h2))
(ensures (modifies loc_none h1 h2))
[SMTPat (HST.modifies_none h1 h2)]
/// Compatibility with HS.upd
val modifies_upd
(#t: Type) (#pre: Preorder.preorder t)
(r: HS.mreference t pre)
(v: t)
(h: HS.mem)
: Lemma
(requires (HS.contains h r))
(ensures (modifies (loc_mreference r) h (HS.upd h r v)))
[SMTPat (HS.upd h r v)]
/// Introduction lemma for modifying loc_buffer_from_to
val modifies_loc_buffer_from_to_intro
(#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
(from to: U32.t)
(l: loc) (h h' : HS.mem)
: Lemma
(requires (
let s = as_seq h b in
let s' = as_seq h' b in
live h b /\
modifies (loc_union l (loc_buffer b)) h h' /\
U32.v from <= U32.v to /\
U32.v to <= length b /\
Seq.slice s 0 (U32.v from) `Seq.equal` Seq.slice s' 0 (U32.v from) /\
Seq.slice s (U32.v to) (length b) `Seq.equal` Seq.slice s' (U32.v to) (length b)
))
(ensures (modifies (loc_union l (loc_buffer_from_to b from to)) h h'))
/// A memory ``h`` does not contain address ``a`` in region ``r``, denoted
/// ``does_not_contain_addr h (r, a)``, only if, either region ``r`` is
/// not live, or address ``a`` is unused in region ``r``.
(* BEGIN TODO: move to FStar.Monotonic.HyperStack *)
val does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: GTot Type0
val not_live_region_does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: Lemma
(requires (~ (HS.live_region h (fst ra))))
(ensures (h `does_not_contain_addr` ra))
val unused_in_does_not_contain_addr
(h: HS.mem)
(#a: Type)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
: Lemma
(requires (r `HS.unused_in` h))
(ensures (h `does_not_contain_addr` (HS.frameOf r, HS.as_addr r)))
val addr_unused_in_does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: Lemma
(requires (HS.live_region h (fst ra) ==> snd ra `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (fst ra))))
(ensures (h `does_not_contain_addr` ra))
val free_does_not_contain_addr
(#a: Type0)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
(m: HS.mem)
(x: HS.rid * nat)
: Lemma
(requires (
HS.is_mm r /\
m `HS.contains` r /\
fst x == HS.frameOf r /\
snd x == HS.as_addr r
))
(ensures (
HS.free r m `does_not_contain_addr` x
))
[SMTPat (HS.free r m `does_not_contain_addr` x)]
val does_not_contain_addr_elim
(#a: Type0)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
(m: HS.mem)
(x: HS.rid * nat)
: Lemma
(requires (
m `does_not_contain_addr` x /\
HS.frameOf r == fst x /\
HS.as_addr r == snd x
))
(ensures (~ (m `HS.contains` r)))
(** END TODO *)
/// Addresses that have not been allocated yet can be removed from
/// modifies clauses.
val modifies_only_live_addresses
(r: HS.rid)
(a: Set.set nat)
(l: loc)
(h h' : HS.mem)
: Lemma
(requires (
modifies (loc_union (loc_addresses false r a) l) h h' /\
(forall x . Set.mem x a ==> h `does_not_contain_addr` (r, x))
))
(ensures (modifies l h h'))
(* Generic way to ensure that a buffer just allocated is disjoint from
any other object, however the latter's liveness is defined. *)
val loc_not_unused_in (h: HS.mem) : GTot loc
val loc_unused_in (h: HS.mem) : GTot loc
(* Shortcut notations with more handy names *)
let loc_in (l: loc) (h: HS.mem) =
loc_not_unused_in h `loc_includes` l
let loc_not_in (l: loc) (h: HS.mem) =
loc_unused_in h `loc_includes` l
val loc_regions_unused_in (h: HS.mem) (rs: Set.set HS.rid) : Lemma
(requires (forall r . Set.mem r rs ==> (~ (HS.live_region h r))))
(ensures (loc_unused_in h `loc_includes` loc_regions false rs))
val loc_unused_in_not_unused_in_disjoint (h: HS.mem) : Lemma
(loc_disjoint (loc_unused_in h) (loc_not_unused_in h))
val not_live_region_loc_not_unused_in_disjoint
(h0: HS.mem)
(r: HS.rid)
: Lemma
(requires (~ (HS.live_region h0 r)))
(ensures (loc_disjoint (loc_region_only false r) (loc_not_unused_in h0)))
let fresh_frame_loc_not_unused_in_disjoint
(h0 h1: HS.mem)
: Lemma
(requires (HS.fresh_frame h0 h1))
(ensures (loc_disjoint (loc_region_only false (HS.get_tip h1)) (loc_not_unused_in h0)))
[SMTPat (HS.fresh_frame h0 h1)]
= not_live_region_loc_not_unused_in_disjoint h0 (HS.get_tip h1)
val live_loc_not_unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (requires (live h b))
(ensures (loc_not_unused_in h `loc_includes` loc_addr_of_buffer b))
[SMTPat (live h b)]
val unused_in_loc_unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (requires (unused_in b h))
(ensures (loc_unused_in h `loc_includes` loc_addr_of_buffer b))
[SMTPat (unused_in b h)]
val modifies_address_liveness_insensitive_unused_in
(h h' : HS.mem)
: Lemma
(requires (modifies (address_liveness_insensitive_locs) h h'))
(ensures (loc_not_unused_in h' `loc_includes` loc_not_unused_in h /\ loc_unused_in h `loc_includes` loc_unused_in h'))
/// Addresses that have not been allocated yet can be removed from
/// modifies clauses.
val modifies_only_not_unused_in
(l: loc)
(h h' : HS.mem)
: Lemma
(requires (modifies (loc_union (loc_unused_in h) l) h h'))
(ensures (modifies l h h'))
val mreference_live_loc_not_unused_in
(#t: Type)
(#pre: Preorder.preorder t)
(h: HS.mem)
(r: HS.mreference t pre)
: Lemma
(requires (h `HS.contains` r))
(ensures (loc_not_unused_in h `loc_includes` loc_freed_mreference r /\ loc_not_unused_in h `loc_includes` loc_mreference r))
[SMTPatOr [
[SMTPat (HS.contains h r)];
[SMTPat (loc_not_unused_in h `loc_includes` loc_mreference r)];
[SMTPat (loc_not_unused_in h `loc_includes` loc_freed_mreference r)];
]]
val mreference_unused_in_loc_unused_in
(#t: Type)
(#pre: Preorder.preorder t)
(h: HS.mem)
(r: HS.mreference t pre)
: Lemma
(requires (r `HS.unused_in` h))
(ensures (loc_unused_in h `loc_includes` loc_freed_mreference r /\ loc_unused_in h `loc_includes` loc_mreference r))
[SMTPatOr [
[SMTPat (HS.unused_in r h)];
[SMTPat (loc_unused_in h `loc_includes` loc_mreference r)];
[SMTPat (loc_unused_in h `loc_includes` loc_freed_mreference r)];
]]
let unused_in_not_unused_in_disjoint_2
(l1 l2 l1' l2': loc)
(h: HS.mem)
: Lemma
(requires (loc_unused_in h `loc_includes` l1 /\ loc_not_unused_in h `loc_includes` l2 /\ l1 `loc_includes` l1' /\ l2 `loc_includes` l2' ))
(ensures (loc_disjoint l1' l2' ))
[SMTPat (loc_disjoint l1' l2'); SMTPat (loc_unused_in h `loc_includes` l1); SMTPat (loc_not_unused_in h `loc_includes` l2)]
= loc_includes_trans (loc_unused_in h) l1 l1' ;
loc_includes_trans (loc_not_unused_in h) l2 l2' ;
loc_unused_in_not_unused_in_disjoint h ;
loc_disjoint_includes (loc_unused_in h) (loc_not_unused_in h) l1' l2'
val modifies_loc_unused_in
(l: loc)
(h1 h2: HS.mem)
(l' : loc)
: Lemma
(requires (
modifies l h1 h2 /\
address_liveness_insensitive_locs `loc_includes` l /\
loc_unused_in h2 `loc_includes` l'
))
(ensures (loc_unused_in h1 `loc_includes` l'))
[SMTPatOr [
[SMTPat (modifies l h1 h2); SMTPat (loc_unused_in h2 `loc_includes` l')];
[SMTPat (modifies l h1 h2); SMTPat (loc_unused_in h1 `loc_includes` l')];
]]
/// Shorthand: freshness
let fresh_loc (l: loc) (h h' : HS.mem) : GTot Type0 =
loc_unused_in h `loc_includes` l /\
loc_not_unused_in h' `loc_includes` l
let ralloc_post_fresh_loc (#a:Type) (#rel:Preorder.preorder a) (i: HS.rid) (init:a) (m0: HS.mem)
(x: HST.mreference a rel{HST.is_eternal_region (HS.frameOf x)}) (m1: HS.mem) : Lemma
(requires (HST.ralloc_post i init m0 x m1))
(ensures (fresh_loc (loc_freed_mreference x) m0 m1))
[SMTPat (HST.ralloc_post i init m0 x m1)]
= ()
//AR: this is needed for liveness across fresh_frame
val fresh_frame_modifies (h0 h1: HS.mem) : Lemma
(requires (HS.fresh_frame h0 h1))
(ensures (modifies loc_none h0 h1))
[SMTPat (HS.fresh_frame h0 h1)]
val popped_modifies (h0 h1: HS.mem) : Lemma
(requires (HS.popped h0 h1))
(ensures (modifies (loc_region_only false (HS.get_tip h0)) h0 h1))
[SMTPat (HS.popped h0 h1)]
val modifies_remove_new_locs (l_fresh l_aux l_goal:loc) (h1 h2 h3:HS.mem)
: Lemma (requires (fresh_loc l_fresh h1 h2 /\
modifies l_aux h1 h2 /\
l_goal `loc_includes` l_aux /\
modifies (loc_union l_fresh l_goal) h2 h3))
(ensures (modifies l_goal h1 h3))
[SMTPat (fresh_loc l_fresh h1 h2);
SMTPat (modifies l_aux h1 h2);
SMTPat (modifies l_goal h1 h3)]
(*
* AR: this lemma is framing the modifies clause across a fresh frame
* one way to do it would have been to reuse the lemma modifies_remove_new_locs,
* treating the fresh frame as another new location
* however, the way library is set up, loc_region in any form cannot be considered
* a fresh loc
* so, we have a special lemma for fresh_frame
*)
let modifies_remove_fresh_frame (h1 h2 h3:HS.mem) (l:loc)
: Lemma (requires (HS.fresh_frame h1 h2 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h2)) l) h2 h3))
(ensures (modifies l h1 h3)) | false | false | LowStar.Monotonic.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_remove_fresh_frame (h1 h2 h3: HS.mem) (l: loc)
: Lemma
(requires
(HS.fresh_frame h1 h2 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h2)) l) h2 h3))
(ensures (modifies l h1 h3))
[SMTPat (modifies l h1 h3); SMTPat (HS.fresh_frame h1 h2)] | [] | LowStar.Monotonic.Buffer.modifies_remove_fresh_frame | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem ->
h3: FStar.Monotonic.HyperStack.mem ->
l: LowStar.Monotonic.Buffer.loc
-> FStar.Pervasives.Lemma
(requires
FStar.Monotonic.HyperStack.fresh_frame h1 h2 /\
LowStar.Monotonic.Buffer.modifies (LowStar.Monotonic.Buffer.loc_union (LowStar.Monotonic.Buffer.loc_all_regions_from
false
(FStar.Monotonic.HyperStack.get_tip h2))
l)
h2
h3)
(ensures LowStar.Monotonic.Buffer.modifies l h1 h3)
[
SMTPat (LowStar.Monotonic.Buffer.modifies l h1 h3);
SMTPat (FStar.Monotonic.HyperStack.fresh_frame h1 h2)
] | {
"end_col": 39,
"end_line": 1720,
"start_col": 4,
"start_line": 1719
} |
FStar.HyperStack.ST.Stack | val upd (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (i: U32.t) (v: a)
: HST.Stack unit
(requires
(fun h ->
live h b /\ U32.v i < length b /\ rel (as_seq h b) (Seq.upd (as_seq h b) (U32.v i) v)))
(ensures
(fun h _ h' ->
(not (g_is_null b)) /\ modifies (loc_buffer b) h h' /\ live h' b /\
as_seq h' b == Seq.upd (as_seq h b) (U32.v i) v)) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let upd
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i:U32.t)
(v:a)
: HST.Stack unit (requires (fun h -> live h b /\ U32.v i < length b /\
rel (as_seq h b) (Seq.upd (as_seq h b) (U32.v i) v)))
(ensures (fun h _ h' -> (not (g_is_null b)) /\
modifies (loc_buffer b) h h' /\
live h' b /\
as_seq h' b == Seq.upd (as_seq h b) (U32.v i) v))
= let h = HST.get () in
upd' b i v;
g_upd_seq_as_seq b (Seq.upd (as_seq h b) (U32.v i) v) h | val upd (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (i: U32.t) (v: a)
: HST.Stack unit
(requires
(fun h ->
live h b /\ U32.v i < length b /\ rel (as_seq h b) (Seq.upd (as_seq h b) (U32.v i) v)))
(ensures
(fun h _ h' ->
(not (g_is_null b)) /\ modifies (loc_buffer b) h h' /\ live h' b /\
as_seq h' b == Seq.upd (as_seq h b) (U32.v i) v))
let upd (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (i: U32.t) (v: a)
: HST.Stack unit
(requires
(fun h ->
live h b /\ U32.v i < length b /\ rel (as_seq h b) (Seq.upd (as_seq h b) (U32.v i) v)))
(ensures
(fun h _ h' ->
(not (g_is_null b)) /\ modifies (loc_buffer b) h h' /\ live h' b /\
as_seq h' b == Seq.upd (as_seq h b) (U32.v i) v)) = | true | null | false | let h = HST.get () in
upd' b i v;
g_upd_seq_as_seq b (Seq.upd (as_seq h b) (U32.v i) v) h | {
"checked_file": "LowStar.Monotonic.Buffer.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.ModifiesGen.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Monotonic.Buffer.fsti"
} | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.g_upd_seq_as_seq",
"FStar.Seq.Base.upd",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.UInt32.v",
"Prims.unit",
"LowStar.Monotonic.Buffer.upd'",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Prims.b2t",
"Prims.op_LessThan",
"LowStar.Monotonic.Buffer.length",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.eq2",
"FStar.Seq.Base.seq"
] | [] | (*
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 LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(* Most comments are taken from the Low* tutorial at:
https://fstarlang.github.io/lowstar/html/LowStar.html
*)
(* Shorthand for preorder over sequences *)
unfold let srel (a:Type0) = Preorder.preorder (Seq.seq a)
(*
* A compatibility relation between preorders of a sequence and its subsequence
*)
[@@"opaque_to_smt"]
unfold
let compatible_subseq_preorder (#a:Type0)
(len:nat) (rel:srel a) (i:nat) (j:nat{i <= j /\ j <= len}) (sub_rel:srel a)
= (forall (s1 s2:Seq.seq a). {:pattern (rel s1 s2); (sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))} //for any two sequences s1 and s2
(Seq.length s1 == len /\ Seq.length s2 == len /\ rel s1 s2) ==> //of length len, and related by rel
(sub_rel (Seq.slice s1 i j) (Seq.slice s2 i j))) /\ //their slices [i, j) are related by sub_rel
(forall (s s2:Seq.seq a). {:pattern (sub_rel (Seq.slice s i j) s2); (rel s (Seq.replace_subseq s i j s2))} //for any two sequences s and s2
(Seq.length s == len /\ Seq.length s2 == j - i /\ sub_rel (Seq.slice s i j) s2) ==> //such that s has length len and s2 has length (j - i), and the slice [i, j) of s is related to s2 by sub_rel
(rel s (Seq.replace_subseq s i j s2))) //if we replace the slice [i, j) in s by s2, then s and the resulting buffer are related by rel
/// Low* buffers
/// ==============
///
/// The workhorse of Low*, this module allows modeling C arrays on the
/// stack and in the heap. At compilation time, KaRaMeL implements
/// buffers using C arrays, i.e. if Low* type ``t`` is translated into C
/// type ``u``, then Low* type ``buffer t`` is translated to C type ``u*``.
///
/// The type is indexed by two preorders:
/// rrel is the preorder with which the buffer is initially created
/// rel is the preorder of the current buffer (which could be a sub-buffer of the original one)
///
/// The buffer contents are constrained to evolve according to rel
(*
* rrel is part of the type for technical reasons
* If we make it part of the implementation of the buffer type,
* it bumps up the universe of buffer itself by one,
* which is too restrictive (e.g. no buffers of buffers)
*
* We expect that clients will rarely work with this directly
* Most of the times, they will use wrappers such as buffer, immutable buffer etc.
*)
val mbuffer (a:Type0) (rrel rel:srel a) :Tot Type0
/// The C ``NULL`` pointer is represented as the Low* ``null`` buffer. For
/// any given type, there is exactly one ``null`` buffer of this type,
/// just like there is exactly one C ``NULL`` pointer of any given type.
///
/// The nullity test ``g_is_null`` is ghost, for proof purposes
/// only. The corresponding stateful nullity test is ``is_null``, see
/// below.
(* FIXME: The nullity test for proof purposes is currently expressed
as a ghost predicate, `g_is_null`, but it is scheduled to be
replaced with equality with `null` *)
val g_is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot bool
val mnull (#a:Type0) (#rrel #rel:srel a) :Tot (b:mbuffer a rrel rel {g_is_null b})
val null_unique (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Lemma (g_is_null b <==> b == mnull)
/// ``unused_in b h`` holds only if buffer ``b`` has not been allocated
/// yet.
val unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem) :GTot Type0
/// ``live h b`` holds if, and only if, buffer ``b`` is currently
/// allocated in ``h`` and has not been deallocated yet.
///
/// This predicate corresponds to the C notion of "lifetime", and as
/// such, is a prerequisite for all stateful operations on buffers
/// (see below), per the C standard:
///
/// If an object is referred to outside of its lifetime, the
/// behavior is undefined.
///
/// -- ISO/IEC 9899:2011, Section 6.2.4 paragraph 2
///
/// By contrast, it is not required for the ghost versions of those
/// operators.
val live (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot Type0
/// The null pointer is always live.
val live_null (a:Type0) (rrel rel:srel a) (h:HS.mem) :Lemma (live h (mnull #a #rrel #rel))
let live_is_null (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true))
(ensures (live h b))
[SMTPat (live h b)]
= null_unique b;
live_null a rrel rel h
/// A live buffer has already been allocated.
val live_not_unused_in (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h)) (ensures False)
/// If two memories have equal domains, then liveness in one implies liveness in the other
val lemma_live_equal_mem_domains (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h0 h1:HS.mem)
:Lemma (requires (HST.equal_domains h0 h1 /\ live h0 b))
(ensures (live h1 b))
[SMTPat (HST.equal_domains h0 h1); SMTPat (live h1 b)]
(* FIXME: the following definition is necessary to isolate the pattern
because of unification. In other words, if we attached the pattern
to `live_not_unused_in`, then we would not be able to use
`FStar.Classical.forall_intro_`n and
`FStar.Classical.move_requires` due to unification issues. Anyway,
we plan to isolate patterns in a separate module to clean up the Z3
context.
*)
let live_not_unused_in' (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b /\ b `unused_in` h))
(ensures False)
[SMTPat (live h b); SMTPat (b `unused_in` h)]
= live_not_unused_in h b
/// Buffers live in the HyperStack model, which is an extension of
/// the HyperHeap model, a hierarchical memory model that divides the
/// heap into a tree of regions. This coarse-grained separation
/// allows the programmer to state modifies clauses at the level of
/// regions, rather than on individual buffers.
///
/// The HyperHeap memory model is described:
/// - in the 2016 POPL paper: https://www.fstar-lang.org/papers/mumon/
/// - in the relevant section of the F* tutorial: http://www.fstar-lang.org/tutorial/
///
/// ``frameOf b`` returns the identifier of the region in which the
/// buffer ``b`` lives.
val frameOf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :Tot HS.rid
/// ``as_addr b`` returns the abstract address of the buffer in its
/// region, as an allocation unit: two buffers that are allocated
/// separately in the same region will actually have different
/// addresses, but a sub-buffer of a buffer will actually have the
/// same address as its enclosing buffer.
val as_addr (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat
/// A buffer is unused if, and only if, its address is unused.
val unused_in_equiv (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (unused_in b h <==>
(HS.live_region h (frameOf b) ==> as_addr b `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (frameOf b))))
/// If a buffer is live, then so is its region.
val live_region_frameOf (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (requires (live h b))
(ensures (HS.live_region h (frameOf b)))
[SMTPatOr [
[SMTPat (live h b)];
[SMTPat (HS.live_region h (frameOf b))];
]]
/// The length of a buffer ``b`` is available as a machine integer ``len
/// b`` or as a mathematical integer ``length b``, but both in ghost
/// (proof) code only: just like in C, one cannot compute the length
/// of a buffer at run-time.
val len (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot U32.t
let length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot nat = U32.v (len b)
/// The null pointer has length 0.
val len_null (a:Type0) (rrel rel:srel a) :Lemma (len (mnull #a #rrel #rel) == 0ul)
let length_null_1 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (length b =!= 0)) (ensures (g_is_null b == false))
[SMTPat (length b)]
= len_null a rrel rel;
null_unique b
let length_null_2 (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (requires (g_is_null b == true)) (ensures (length b == 0))
[SMTPat (g_is_null b)]
= len_null a rrel rel;
null_unique b
/// For functional correctness, buffers are reflected at the proof
/// level using sequences, via ``as_seq b h``, which returns the
/// contents of a given buffer ``b`` in a given heap ``h``. If ``b`` is not
/// live in ``h``, then the result is unspecified.
(* TODO: why not return a lseq and remove length_as_seq lemma? *)
val as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel) :GTot (Seq.seq a)
/// The contents of a buffer ``b`` has the same length as ``b`` itself.
val length_as_seq (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (b:mbuffer a rrel rel)
:Lemma (Seq.length (as_seq h b) == length b)
[SMTPat (Seq.length (as_seq h b))]
/// ``get`` is an often-convenient shorthand to index the value of a
/// given buffer in a given heap, for proof purposes.
let get (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (p:mbuffer a rrel rel) (i:nat)
:Ghost a (requires (i < length p)) (ensures (fun _ -> True))
= Seq.index (as_seq h p) i
/// Injectivity in the first preorder
val mbuffer_injectivity_in_first_preorder (_:unit)
: Lemma (forall (a:Type0) (rrel1 rrel2 rel1 rel2:srel a)
(b1:mbuffer a rrel1 rel1)
(b2:mbuffer a rrel2 rel2).
rrel1 =!= rrel2 ==> ~ (b1 === b2))
/// Before defining sub-buffer related API, we need to define the notion of "compatibility"
///
///
/// Sub-buffers can be taken at a different preorder than their parent buffers
/// But we need to ensure that the changes to the sub-buffer are compatible with the preorder
/// of the parent buffer, and vice versa.
(*
* The quantifiers are fiercely guarded, so if you are working directly with them,
* you may have to write additional asserts as triggers
*)
[@@"opaque_to_smt"]
unfold let compatible_sub
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t{U32.v i + U32.v len <= length b}) (sub_rel:srel a)
= compatible_subseq_preorder (length b) rel (U32.v i) (U32.v i + U32.v len) sub_rel
/// ``gsub`` is the way to carve a sub-buffer out of a given
/// buffer. ``gsub b i len`` return the sub-buffer of ``b`` starting from
/// offset ``i`` within ``b``, and with length ``len``. Of course ``i`` and
/// ``len`` must fit within the length of ``b``.
///
/// Further the clients can attach a preorder with the subbuffer (sub_rel),
/// provided it is compatible
///
/// ``gsub`` is the ghost version, for proof purposes. Its stateful
/// counterpart is ``sub``, see below.
val mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Ghost (mbuffer a rrel sub_rel)
(requires (U32.v i + U32.v len <= length b))
(ensures (fun _ -> True))
// goffset
/// A buffer is live exactly at the same time as all of its sub-buffers.
val live_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b /\ compatible_sub b i len sub_rel))
(ensures (live h b <==> (live h (mgsub sub_rel b i len) /\ (exists h0 . {:pattern (live h0 b)} live h0 b))))
[SMTPatOr [
[SMTPat (live h (mgsub sub_rel b i len))];
[SMTPat (live h b); SMTPat (mgsub sub_rel b i len);]
]]
val gsub_is_null (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (g_is_null (mgsub sub_rel b i len) <==> g_is_null b))
[SMTPat (g_is_null (mgsub sub_rel b i len))]
/// The length of a sub-buffer is exactly the one provided at ``gsub``.
val len_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len':U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len' <= length b))
(ensures (len (mgsub sub_rel b i len') == len'))
[SMTPatOr [
[SMTPat (len (mgsub sub_rel b i len'))];
[SMTPat (length (mgsub sub_rel b i len'))];
]]
val frameOf_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (frameOf (mgsub sub_rel b i len) == frameOf b))
[SMTPat (frameOf (mgsub sub_rel b i len))]
val as_addr_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_addr (mgsub sub_rel b i len) == as_addr b))
[SMTPat (as_addr (mgsub sub_rel b i len))]
val mgsub_inj (#a:Type0) (#rrel #rel:srel a) (sub_rel1 sub_rel2:srel a)
(b1 b2:mbuffer a rrel rel)
(i1 i2:U32.t)
(len1 len2:U32.t)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b1 /\
U32.v i2 + U32.v len2 <= length b2 /\
mgsub sub_rel1 b1 i1 len1 === mgsub sub_rel2 b2 i2 len2))
(ensures (len1 == len2 /\ (b1 == b2 ==> i1 == i2) /\ ((i1 == i2 /\ length b1 == length b2) ==> b1 == b2)))
/// Nesting two ``gsub`` collapses into one ``gsub``, transitively.
val gsub_gsub (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i1:U32.t) (len1:U32.t) (sub_rel1:srel a)
(i2: U32.t) (len2: U32.t) (sub_rel2:srel a)
:Lemma (requires (U32.v i1 + U32.v len1 <= length b /\
U32.v i2 + U32.v len2 <= U32.v len1))
(ensures (((compatible_sub b i1 len1 sub_rel1 /\ compatible_sub (mgsub sub_rel1 b i1 len1) i2 len2 sub_rel2) ==> compatible_sub b (U32.add i1 i2) len2 sub_rel2) /\
mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2 == mgsub sub_rel2 b (U32.add i1 i2) len2))
[SMTPat (mgsub sub_rel2 (mgsub sub_rel1 b i1 len1) i2 len2)]
/// A buffer ``b`` is equal to its "largest" sub-buffer, at index 0 and
/// length ``len b``.
val gsub_zero_length (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (compatible_sub b 0ul (len b) rel /\ b == mgsub rel b 0ul (len b))
/// The contents of a sub-buffer is the corresponding slice of the
/// contents of its enclosing buffer.
val as_seq_gsub (#a:Type0) (#rrel #rel:srel a)
(h:HS.mem) (b:mbuffer a rrel rel) (i:U32.t) (len:U32.t) (sub_rel:srel a)
:Lemma (requires (U32.v i + U32.v len <= length b))
(ensures (as_seq h (mgsub sub_rel b i len) == Seq.slice (as_seq h b) (U32.v i) (U32.v i + U32.v len)))
[SMTPat (as_seq h (mgsub sub_rel b i len))]
/// Two live non-null buffers having the same region and address have
/// their elements of the same type.
val live_same_addresses_equal_types_and_preorders
(#a1 #a2: Type0)
(#rrel1 #rel1: srel a1)
(#rrel2 #rel2: srel a2)
(b1: mbuffer a1 rrel1 rel1)
(b2: mbuffer a2 rrel2 rel2)
(h: HS.mem)
: Lemma
((frameOf b1 == frameOf b2 /\ as_addr b1 == as_addr b2 /\ live h b1 /\ live h b2 /\ (~ (g_is_null b1 /\ g_is_null b2))) ==> (a1 == a2 /\ rrel1 == rrel2))
/// # The modifies clause
///
/// The modifies clause for regions, references and buffers.
/// ==========================================================
///
/// This module presents the modifies clause, a way to track the set
/// of memory locations modified by a stateful Low* (or even F*)
/// program. The basic principle of modifies clauses is that any
/// location that is disjoint from a set of memory locations modified
/// by an operation is preserved by that operation.
///
/// We start by specifying a monoid of sets of memory locations. From
/// a rough high-level view, ``loc`` is the type of sets of memory
/// locations, equipped with an identity element ``loc_none``,
/// representing the empty set, and an associative and commutative
/// operator, ``loc_union``, representing the union of two sets of
/// memory locations.
///
/// Moreover, ``loc_union`` is idempotent, which is useful to cut SMT
/// matching loops with ``modifies_trans`` and ``modifies_refl`` below.
val loc : Type0
val loc_none: loc
val loc_union
(s1 s2: loc)
: GTot loc
val loc_union_idem
(s: loc)
: Lemma
(loc_union s s == s)
[SMTPat (loc_union s s)]
val loc_union_comm
(s1 s2: loc)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
[SMTPat (loc_union s1 s2)]
val loc_union_assoc
(s1 s2 s3: loc)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
let loc_union_idem_1
(s1 s2: loc)
: Lemma
(loc_union s1 (loc_union s1 s2) == loc_union s1 s2)
[SMTPat (loc_union s1 (loc_union s1 s2))]
= loc_union_assoc s1 s1 s2
let loc_union_idem_2
(s1 s2: loc)
: Lemma
(loc_union (loc_union s1 s2) s2 == loc_union s1 s2)
[SMTPat (loc_union (loc_union s1 s2) s2)]
= loc_union_assoc s1 s2 s2
val loc_union_loc_none_l
(s: loc)
: Lemma
(loc_union loc_none s == s)
[SMTPat (loc_union loc_none s)]
val loc_union_loc_none_r
(s: loc)
: Lemma
(loc_union s loc_none == s)
[SMTPat (loc_union s loc_none)]
/// ``loc_buffer b`` is the set of memory locations associated to a buffer ``b``.
val loc_buffer_from_to (#a:Type0) (#rrel #rel:srel a) (b: mbuffer a rrel rel) (from to: U32.t) : GTot loc
val loc_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc
val loc_buffer_eq (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) : Lemma
(loc_buffer b == loc_buffer_from_to b 0ul (len b))
val loc_buffer_from_to_high (#a: Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (length b <= U32.v to))
(ensures (loc_buffer_from_to b from to == loc_buffer_from_to b from (len b)))
val loc_buffer_from_to_none (#a: Type) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (from to: U32.t)
: Lemma
(requires (g_is_null b \/ length b < U32.v from \/ U32.v to < U32.v from))
(ensures (loc_buffer_from_to b from to == loc_none))
val loc_buffer_from_to_mgsub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
(from to: U32.t)
: Lemma
(requires (
U32.v i + U32.v len <= length b /\
U32.v from <= U32.v to /\ U32.v to <= U32.v len
))
(ensures (
loc_buffer_from_to (mgsub sub_rel b i len) from to == loc_buffer_from_to b (i `U32.add` from) (i `U32.add` to)
))
val loc_buffer_mgsub_eq (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a)
(b:mbuffer a rrel rel) (i:U32.t) (len:U32.t)
:Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub sub_rel b i len) == loc_buffer_from_to b i (i `U32.add` len)))
val loc_buffer_null (a:Type0) (rrel rel:srel a)
:Lemma (loc_buffer (mnull #a #rrel #rel) == loc_none)
[SMTPat (loc_buffer (mnull #a #rrel #rel))]
val loc_buffer_from_to_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(from to: U32.t)
: Lemma
(requires (U32.v from <= U32.v to /\ U32.v to <= length b))
(ensures (loc_buffer_from_to b from to == loc_buffer (mgsub rel b from (to `U32.sub` from))))
[SMTPat (loc_buffer_from_to b from to)]
val loc_buffer_mgsub_rel_eq
(#a:Type0) (#rrel #rel:srel a)
(b: mbuffer a rrel rel)
(rel1 rel2: srel a)
(i len: U32.t)
: Lemma
(requires (U32.v i + U32.v len <= length b))
(ensures (loc_buffer (mgsub rel1 b i len) == loc_buffer (mgsub rel2 b i len)))
[SMTPat (loc_buffer (mgsub rel1 b i len)); SMTPat (loc_buffer (mgsub rel2 b i len))]
/// ``loc_addresses r n`` is the set of memory locations associated to a
/// set of addresses ``n`` in a given region ``r``.
val loc_addresses
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot loc
unfold let loc_addr_of_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) :GTot loc =
loc_addresses false (frameOf b) (Set.singleton (as_addr b))
/// ``loc_regions r`` is the set of memory locations associated to a set
/// ``r`` of regions.
val loc_regions
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot loc
/// ``loc_mreference b`` is the set of memory locations associated to a
/// reference ``b``, which is actually the set of memory locations
/// associated to the address of ``b``.
unfold
let loc_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
unfold
let loc_freed_mreference
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot loc
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
/// ``loc_region_only r`` is the set of memory locations associated to a
/// region ``r`` but not any region ``r'`` that extends ``r`` (in the sense
/// of ``FStar.HyperStack.extends``.)
unfold
let loc_region_only
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (Set.singleton r)
/// ``loc_all_regions_from r`` is the set of all memory locations
/// associated to a region ``r`` and any region ``r'`` that transitively
/// extends ``r`` (in the sense of ``FStar.HyperStack.extends``,
/// e.g. nested stack frames.)
unfold
let loc_all_regions_from
(preserve_liveness: bool)
(r: HS.rid)
: GTot loc
= loc_regions preserve_liveness (HS.mod_set (Set.singleton r))
/// We equip the ``loc`` monoid of sets of memory locations with an
/// inclusion relation, ``loc_includes``, which is a preorder compatible
/// with ``loc_union``. Although we consider sets of memory locations,
/// we do not specify them using any F* set library such as
/// ``FStar.Set``, ``FStar.TSet`` or ``FStar.GSet``, because ``loc_includes``
/// encompasses more than just set-theoretic inclusion.
val loc_includes
(s1 s2: loc)
: GTot Type0
val loc_includes_refl
(s: loc)
: Lemma
(loc_includes s s)
[SMTPat (loc_includes s s)]
val loc_includes_trans
(s1 s2 s3: loc)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
let loc_includes_trans_backwards
(s1 s2 s3: loc)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
[SMTPat (loc_includes s1 s3); SMTPat (loc_includes s2 s3)]
= loc_includes_trans s1 s2 s3
val loc_includes_union_r
(s s1 s2: loc)
: Lemma
(requires (loc_includes s s1 /\ loc_includes s s2))
(ensures (loc_includes s (loc_union s1 s2)))
val loc_includes_union_l
(s1 s2 s: loc)
: Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
let loc_includes_union_l'
(s1 s2 s: loc)
: Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
[SMTPat (loc_includes (loc_union s1 s2) s)]
= loc_includes_union_l s1 s2 s
let loc_includes_union_r'
(s s1 s2: loc)
: Lemma
(loc_includes s (loc_union s1 s2) <==> (loc_includes s s1 /\ loc_includes s s2))
[SMTPat (loc_includes s (loc_union s1 s2))]
= Classical.move_requires (loc_includes_union_r s s1) s2;
Classical.move_requires (loc_includes_union_l s1 s2) s1;
Classical.move_requires (loc_includes_union_l s1 s2) s2;
Classical.move_requires (loc_includes_trans s (loc_union s1 s2)) s1;
Classical.move_requires (loc_includes_trans s (loc_union s1 s2)) s2
val loc_includes_none
(s: loc)
: Lemma
(loc_includes s loc_none)
[SMTPat (loc_includes s loc_none)]
/// If a buffer ``b1`` includes a buffer ``b2`` in the sense of the buffer
/// theory (see ``LowStar.Buffer.includes``), then so are their
/// corresponding sets of memory locations.
val loc_includes_gsub_buffer_r
(l:loc)
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:UInt32.t) (len:UInt32.t) (sub_rel:srel a)
: Lemma (requires (UInt32.v i + UInt32.v len <= (length b) /\
loc_includes l (loc_buffer b)))
(ensures (loc_includes l (loc_buffer (mgsub sub_rel b i len))))
[SMTPat (loc_includes l (loc_buffer (mgsub sub_rel b i len)))]
let loc_includes_gsub_buffer_r' (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (i:UInt32.t) (len:UInt32.t) (sub_rel:srel a)
:Lemma (requires (UInt32.v i + UInt32.v len <= (length b)))
(ensures (loc_includes (loc_buffer b) (loc_buffer (mgsub sub_rel b i len))))
[SMTPat (mgsub sub_rel b i len)]
= ()
val loc_includes_gsub_buffer_l (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
(i1:UInt32.t) (len1:UInt32.t) (sub_rel1:srel a)
(i2:UInt32.t) (len2:UInt32.t) (sub_rel2:srel a)
:Lemma (requires (UInt32.v i1 + UInt32.v len1 <= (length b) /\
UInt32.v i1 <= UInt32.v i2 /\ UInt32.v i2 + UInt32.v len2 <= UInt32.v i1 + UInt32.v len1
))
(ensures (loc_includes (loc_buffer (mgsub sub_rel1 b i1 len1)) (loc_buffer (mgsub sub_rel2 b i2 len2))))
[SMTPat (mgsub sub_rel1 b i1 len1); SMTPat (mgsub sub_rel2 b i2 len2)]
val loc_includes_loc_buffer_loc_buffer_from_to
(#a: _) (#rrel #rel: _)
(b: mbuffer a rrel rel)
(from to: U32.t)
: Lemma
(loc_includes (loc_buffer b) (loc_buffer_from_to b from to))
val loc_includes_loc_buffer_from_to
(#a: _) (#rrel #rel: _)
(b: mbuffer a rrel rel)
(from1 to1 from2 to2: U32.t)
: Lemma
(requires (U32.v from1 <= U32.v from2 /\ U32.v to2 <= U32.v to1))
(ensures (loc_includes (loc_buffer_from_to b from1 to1) (loc_buffer_from_to b from2 to2)))
/// If the contents of a buffer are equal in two given heaps, then so
/// are the contents of any of its sub-buffers.
val loc_includes_as_seq (#a:Type0) (#rrel #rel1 #rel2:srel a)
(h1 h2:HS.mem) (larger:mbuffer a rrel rel1) (smaller:mbuffer a rrel rel2)
:Lemma (requires (loc_includes (loc_buffer larger) (loc_buffer smaller) /\
as_seq h1 larger == as_seq h2 larger /\
(live h1 larger \/ live h1 smaller) /\ (live h2 larger \/ live h2 smaller)))
(ensures (as_seq h1 smaller == as_seq h2 smaller))
/// Given a buffer ``b``, if its address is in a set ``s`` of addresses in
/// the region of ``b``, then the set of memory locations corresponding
/// to ``b`` is included in the set of memory locations corresponding to
/// the addresses in ``s`` in region ``r``.
///
/// In particular, the set of memory locations corresponding to a
/// buffer is included in the set of memory locations corresponding to
/// its region and address.
val loc_includes_addresses_buffer (#a:Type0) (#rrel #rel:srel a)
(preserve_liveness:bool) (r:HS.rid) (s:Set.set nat) (p:mbuffer a rrel rel)
:Lemma (requires (frameOf p == r /\ Set.mem (as_addr p) s))
(ensures (loc_includes (loc_addresses preserve_liveness r s) (loc_buffer p)))
[SMTPat (loc_includes (loc_addresses preserve_liveness r s) (loc_buffer p))]
let loc_includes_addresses_buffer' (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (loc_includes (loc_addresses true (frameOf b) (Set.singleton (as_addr b))) (loc_buffer b))
[SMTPat (loc_buffer b)]
= ()
/// The set of memory locations corresponding to a buffer is included
/// in the set of memory locations corresponding to its region.
val loc_includes_region_buffer (#a:Type0) (#rrel #rel:srel a)
(preserve_liveness:bool) (s:Set.set HS.rid) (b:mbuffer a rrel rel)
:Lemma (requires (Set.mem (frameOf b) s))
(ensures (loc_includes (loc_regions preserve_liveness s) (loc_buffer b)))
[SMTPat (loc_includes (loc_regions preserve_liveness s) (loc_buffer b))]
let loc_includes_region_buffer' (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (loc_includes (loc_regions true (Set.singleton (frameOf b))) (loc_buffer b))
[SMTPat (loc_buffer b)]
= ()
/// If a region ``r`` is in a set of regions ``s``, then the set of memory
/// locations corresponding to a set of addresses ``a`` in ``r`` is
/// included in the set of memory locations corresponding to the
/// regions in ``s``.
///
/// In particular, the the set of memory locations corresponding to a
/// set of addresses ``a`` in a given region ``r`` is included in the set
/// of memory locations corresponding to region ``r``.
val loc_includes_region_addresses
(preserve_liveness1: bool)
(preserve_liveness2: bool)
(s: Set.set HS.rid)
(r: HS.rid)
(a: Set.set nat)
: Lemma
(requires (Set.mem r s))
(ensures (loc_includes (loc_regions preserve_liveness1 s) (loc_addresses preserve_liveness2 r a)))
[SMTPat (loc_includes (loc_regions preserve_liveness1 s) (loc_addresses preserve_liveness2 r a))]
let loc_includes_region_addresses'
(preserve_liveness: bool)
(r: HS.rid)
(a: Set.set nat)
: Lemma
(loc_includes (loc_regions true (Set.singleton r)) (loc_addresses preserve_liveness r a))
[SMTPat (loc_addresses preserve_liveness r a)]
= ()
/// If a set of region identifiers ``s1`` includes a set of region
/// identifiers ``s2``, then so are their corresponding sets of memory
/// locations.
val loc_includes_region_region
(preserve_liveness1: bool)
(preserve_liveness2: bool)
(s1 s2: Set.set HS.rid)
: Lemma
(requires ((preserve_liveness1 ==> preserve_liveness2) /\ Set.subset s2 s1))
(ensures (loc_includes (loc_regions preserve_liveness1 s1) (loc_regions preserve_liveness2 s2)))
[SMTPat (loc_includes (loc_regions preserve_liveness1 s1) (loc_regions preserve_liveness2 s2))]
let loc_includes_region_region'
(preserve_liveness: bool)
(s: Set.set HS.rid)
: Lemma
(loc_includes (loc_regions false s) (loc_regions preserve_liveness s))
[SMTPat (loc_regions preserve_liveness s)]
= ()
/// The following lemma can act as a cut when reasoning with sets of
/// memory locations corresponding to sets of regions.
val loc_includes_region_union_l
(preserve_liveness: bool)
(l: loc)
(s1 s2: Set.set HS.rid)
: Lemma
(requires (loc_includes l (loc_regions preserve_liveness (Set.intersect s2 (Set.complement s1)))))
(ensures (loc_includes (loc_union (loc_regions preserve_liveness s1) l) (loc_regions preserve_liveness s2)))
[SMTPat (loc_includes (loc_union (loc_regions preserve_liveness s1) l) (loc_regions preserve_liveness s2))]
/// If a set of addresses ``s1`` includes a set of addresses ``s2``,
/// then so are their corresponding memory locations
val loc_includes_addresses_addresses
(preserve_liveness1 preserve_liveness2: bool)
(r: HS.rid)
(s1 s2: Set.set nat)
: Lemma
(requires ((preserve_liveness1 ==> preserve_liveness2) /\ Set.subset s2 s1))
(ensures (loc_includes (loc_addresses preserve_liveness1 r s1) (loc_addresses preserve_liveness2 r s2)))
let loc_includes_addresses_addresses_1
(preserve_liveness1 preserve_liveness2: bool)
(r1 r2: HS.rid)
(s1 s2: Set.set nat)
: Lemma
(requires (r1 == r2 /\ (preserve_liveness1 ==> preserve_liveness2) /\ Set.subset s2 s1))
(ensures (loc_includes (loc_addresses preserve_liveness1 r1 s1) (loc_addresses preserve_liveness2 r2 s2)))
[SMTPat (loc_includes (loc_addresses preserve_liveness1 r1 s1) (loc_addresses preserve_liveness2 r2 s2))]
= loc_includes_addresses_addresses preserve_liveness1 preserve_liveness2 r1 s1 s2
let loc_includes_addresses_addresses_2
(preserve_liveness: bool)
(r: HS.rid)
(s: Set.set nat)
: Lemma
(loc_includes (loc_addresses false r s) (loc_addresses preserve_liveness r s))
[SMTPat (loc_addresses preserve_liveness r s)]
= ()
/// Patterns with loc_includes, union on the left
let loc_includes_union_l_buffer
(s1 s2:loc)
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
:Lemma (requires (loc_includes s1 (loc_buffer b) \/ loc_includes s2 (loc_buffer b)))
(ensures (loc_includes (loc_union s1 s2) (loc_buffer b)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_buffer b))]
= loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_union_l_addresses
(s1 s2: loc)
(prf: bool)
(r: HS.rid)
(a: Set.set nat)
: Lemma
(requires (loc_includes s1 (loc_addresses prf r a) \/ loc_includes s2 (loc_addresses prf r a)))
(ensures (loc_includes (loc_union s1 s2) (loc_addresses prf r a)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_addresses prf r a))]
= loc_includes_union_l s1 s2 (loc_addresses prf r a)
let loc_includes_union_l_regions
(s1 s2: loc)
(prf: bool)
(r: Set.set HS.rid)
: Lemma
(requires (loc_includes s1 (loc_regions prf r) \/ loc_includes s2 (loc_regions prf r)))
(ensures (loc_includes (loc_union s1 s2) (loc_regions prf r)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_regions prf r))]
= loc_includes_union_l s1 s2 (loc_regions prf r)
/// Since inclusion encompasses more than just set-theoretic
/// inclusion, we also need to specify disjointness accordingly, as a
/// symmetric relation compatible with union.
val loc_disjoint
(s1 s2: loc)
: GTot Type0
val loc_disjoint_sym
(s1 s2: loc)
: Lemma
(requires (loc_disjoint s1 s2))
(ensures (loc_disjoint s2 s1))
let loc_disjoint_sym'
(s1 s2: loc)
: Lemma
(loc_disjoint s1 s2 <==> loc_disjoint s2 s1)
[SMTPat (loc_disjoint s1 s2)]
= Classical.move_requires (loc_disjoint_sym s1) s2;
Classical.move_requires (loc_disjoint_sym s2) s1
val loc_disjoint_none_r
(s: loc)
: Lemma
(ensures (loc_disjoint s loc_none))
[SMTPat (loc_disjoint s loc_none)]
val loc_disjoint_union_r
(s s1 s2: loc)
: Lemma
(requires (loc_disjoint s s1 /\ loc_disjoint s s2))
(ensures (loc_disjoint s (loc_union s1 s2)))
/// If two sets of memory locations are disjoint, then so are any two
/// included sets of memory locations.
val loc_disjoint_includes
(p1 p2 p1' p2' : loc)
: Lemma
(requires (loc_includes p1 p1' /\ loc_includes p2 p2' /\ loc_disjoint p1 p2))
(ensures (loc_disjoint p1' p2'))
let loc_disjoint_union_r'
(s s1 s2: loc)
: Lemma
(ensures (loc_disjoint s (loc_union s1 s2) <==> (loc_disjoint s s1 /\ loc_disjoint s s2)))
[SMTPat (loc_disjoint s (loc_union s1 s2))]
= Classical.move_requires (loc_disjoint_union_r s s1) s2;
loc_includes_union_l s1 s2 s1;
loc_includes_union_l s1 s2 s2;
Classical.move_requires (loc_disjoint_includes s (loc_union s1 s2) s) s1;
Classical.move_requires (loc_disjoint_includes s (loc_union s1 s2) s) s2
let loc_disjoint_includes_r (b1 : loc) (b2 b2': loc) : Lemma
(requires (loc_includes b2 b2' /\ loc_disjoint b1 b2))
(ensures (loc_disjoint b1 b2'))
[SMTPat (loc_disjoint b1 b2'); SMTPat (loc_includes b2 b2')]
= loc_disjoint_includes b1 b2 b1 b2'
val loc_disjoint_gsub_buffer (#a:Type0) (#rrel:srel a) (#rel:srel a)
(b:mbuffer a rrel rel)
(i1:UInt32.t) (len1:UInt32.t) (sub_rel1:srel a)
(i2:UInt32.t) (len2:UInt32.t) (sub_rel2:srel a)
:Lemma (requires (UInt32.v i1 + UInt32.v len1 <= (length b) /\
UInt32.v i2 + UInt32.v len2 <= (length b) /\
(UInt32.v i1 + UInt32.v len1 <= UInt32.v i2 \/
UInt32.v i2 + UInt32.v len2 <= UInt32.v i1)))
(ensures (loc_disjoint (loc_buffer (mgsub sub_rel1 b i1 len1)) (loc_buffer (mgsub sub_rel2 b i2 len2))))
[SMTPat (mgsub sub_rel1 b i1 len1); SMTPat (mgsub sub_rel2 b i2 len2)]
val loc_disjoint_loc_buffer_from_to
(#a: _) (#rrel #rel: _)
(b: mbuffer a rrel rel)
(from1 to1 from2 to2: U32.t)
: Lemma
(requires (U32.v to1 <= U32.v from2 \/ U32.v to2 <= U32.v from1))
(ensures (loc_disjoint (loc_buffer_from_to b from1 to1) (loc_buffer_from_to b from2 to2)))
/// If two sets of addresses correspond to different regions or are
/// disjoint, then their corresponding sets of memory locations are
/// disjoint.
val loc_disjoint_addresses
(preserve_liveness1 preserve_liveness2: bool)
(r1 r2: HS.rid)
(n1 n2: Set.set nat)
: Lemma
(requires (r1 <> r2 \/ Set.subset (Set.intersect n1 n2) Set.empty))
(ensures (loc_disjoint (loc_addresses preserve_liveness1 r1 n1) (loc_addresses preserve_liveness2 r2 n2)))
[SMTPat (loc_disjoint (loc_addresses preserve_liveness1 r1 n1) (loc_addresses preserve_liveness2 r2 n2))]
/// If two sets of region identifiers are disjoint, then so are their
/// corresponding sets of memory locations.
val loc_disjoint_regions
(preserve_liveness1: bool)
(preserve_liveness2: bool)
(rs1 rs2: Set.set HS.rid)
: Lemma
(requires (Set.subset (Set.intersect rs1 rs2) Set.empty))
(ensures (loc_disjoint (loc_regions preserve_liveness1 rs1) (loc_regions preserve_liveness2 rs2)))
[SMTPat (loc_disjoint (loc_regions preserve_liveness1 rs1) (loc_regions preserve_liveness2 rs2))]
/// Some utilities to work with lists of buffers and locs
(* buf_t is a `buffer` at some type `a` *)
let buf_t = a:Type0 & rrel:srel a & rel:srel a & mbuffer a rrel rel
(* A convenience to construct a buf_t *)
[@@BigOps.__reduce__]
let buf (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) : buf_t = (|a, rrel, rel, b|)
(* A conjunction of liveness conditions on the buffers in `l`
Implicitly reduced at typechecking time *)
[@@"opaque_to_smt"]
unfold
let all_live (h:HS.mem) (l:list buf_t) : Type0 =
BigOps.big_and #buf_t (fun (| _, _, _, b |) -> live h b) l
(* Pairwise disjointness of locations;
Implicitly reduced at typechecking time *)
[@@"opaque_to_smt"]
unfold
let all_disjoint (l:list loc) : Type0 =
BigOps.pairwise_and loc_disjoint l
(* Union of a list of locations;
Implicitly reduced at typechecking time *)
[@@"opaque_to_smt"]
unfold
let loc_union_l (l:list loc) =
BigOps.normal (List.Tot.fold_right_gtot l loc_union loc_none)
(*
* Same as all_disjoint, retaining for backward compatibility
*)
[@@"opaque_to_smt"]
unfold
let loc_pairwise_disjoint (l:list loc) :Type0 = BigOps.pairwise_and loc_disjoint l
/// The modifies clauses proper.
///
/// Let ``s`` be a set of memory locations, and ``h1`` and ``h2`` be two
/// memory states. Then, ``s`` is modified from ``h1`` to ``h2`` only if,
/// any memory location disjoint from ``s`` is preserved from ``h1`` into
/// ``h2``. Elimination lemmas illustrating this principle follow.
val modifies
(s: loc)
(h1 h2: HS.mem)
: GTot Type0
/// If a region ``r`` is disjoint from a set ``s`` of memory locations
/// which is modified, then its liveness is preserved.
val modifies_live_region
(s: loc)
(h1 h2: HS.mem)
(r: HS.rid)
: Lemma
(requires (modifies s h1 h2 /\ loc_disjoint s (loc_region_only false r) /\ HS.live_region h1 r))
(ensures (HS.live_region h2 r))
[SMTPatOr [
[SMTPat (modifies s h1 h2); SMTPat (HS.live_region h1 r)];
[SMTPat (modifies s h1 h2); SMTPat (HS.live_region h2 r)];
]]
/// If a reference ``b`` is disjoint from a set ``p`` of memory locations
/// which is modified, then its liveness and contents are preserved.
val modifies_mreference_elim
(#t: Type)
(#pre: Preorder.preorder t)
(b: HS.mreference t pre)
(p: loc)
(h h': HS.mem)
: Lemma
(requires (
loc_disjoint (loc_mreference b) p /\
HS.contains h b /\
modifies p h h'
))
(ensures (
HS.contains h' b /\
HS.sel h b == HS.sel h' b
))
[SMTPatOr [
[ SMTPat (modifies p h h'); SMTPat (HS.sel h b) ] ;
[ SMTPat (modifies p h h'); SMTPat (HS.contains h b) ];
[ SMTPat (modifies p h h'); SMTPat (HS.sel h' b) ] ;
[ SMTPat (modifies p h h'); SMTPat (HS.contains h' b) ]
] ]
/// If a buffer ``b`` is disjoint from a set ``p`` of
/// memory locations which is modified, then its liveness and contents
/// are preserved.
val modifies_buffer_elim (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (p:loc) (h h':HS.mem)
:Lemma (requires (loc_disjoint (loc_buffer b) p /\ live h b /\ modifies p h h'))
(ensures (live h' b /\ (as_seq h b == as_seq h' b)))
[SMTPatOr [
[ SMTPat (modifies p h h'); SMTPat (as_seq h b) ] ;
[ SMTPat (modifies p h h'); SMTPat (live h b) ];
[ SMTPat (modifies p h h'); SMTPat (as_seq h' b) ] ;
[ SMTPat (modifies p h h'); SMTPat (live h' b) ]
]]
val modifies_buffer_from_to_elim (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (from to: U32.t) (p:loc) (h h':HS.mem)
:Lemma (requires (loc_disjoint (loc_buffer_from_to b from to) p /\ live h b /\ modifies p h h' /\ U32.v from <= U32.v to /\ U32.v to <= length b))
(ensures (live h' b /\ Seq.slice (as_seq h b) (U32.v from) (U32.v to) == Seq.slice (as_seq h' b) (U32.v from) (U32.v to)))
/// If the memory state does not change, then any memory location is
/// modified (and, in particular, the empty set, ``loc_none``.)
val modifies_refl
(s: loc)
(h: HS.mem)
: Lemma
(modifies s h h)
[SMTPat (modifies s h h)]
/// If a set ``s2`` of memory locations is modified, then so is any set
/// ``s1`` that includes ``s2``. In other words, it is always possible to
/// weaken a modifies clause by widening its set of memory locations.
val modifies_loc_includes
(s1: loc)
(h h': HS.mem)
(s2: loc)
: Lemma
(requires (modifies s2 h h' /\ loc_includes s1 s2))
(ensures (modifies s1 h h'))
[SMTPat (modifies s1 h h'); SMTPat (modifies s2 h h')]
/// Some memory locations are tagged as liveness-insensitive: the
/// liveness preservation of a memory location only depends on its
/// disjointness from the liveness-sensitive memory locations of a
/// modifies clause.
val address_liveness_insensitive_locs: loc
val region_liveness_insensitive_locs: loc
val address_liveness_insensitive_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (address_liveness_insensitive_locs `loc_includes` (loc_buffer b))
[SMTPat (address_liveness_insensitive_locs `loc_includes` (loc_buffer b))]
val address_liveness_insensitive_addresses (r: HS.rid) (a: Set.set nat) : Lemma
(address_liveness_insensitive_locs `loc_includes` (loc_addresses true r a))
[SMTPat (address_liveness_insensitive_locs `loc_includes` (loc_addresses true r a))]
val region_liveness_insensitive_buffer (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:Lemma (region_liveness_insensitive_locs `loc_includes` (loc_buffer b))
[SMTPat (region_liveness_insensitive_locs `loc_includes` (loc_buffer b))]
val region_liveness_insensitive_addresses (preserve_liveness: bool) (r: HS.rid) (a: Set.set nat) : Lemma
(region_liveness_insensitive_locs `loc_includes` (loc_addresses preserve_liveness r a))
[SMTPat (region_liveness_insensitive_locs `loc_includes` (loc_addresses preserve_liveness r a))]
val region_liveness_insensitive_regions (rs: Set.set HS.rid) : Lemma
(region_liveness_insensitive_locs `loc_includes` (loc_regions true rs))
[SMTPat (region_liveness_insensitive_locs `loc_includes` (loc_regions true rs))]
val region_liveness_insensitive_address_liveness_insensitive:
squash (region_liveness_insensitive_locs `loc_includes` address_liveness_insensitive_locs)
val modifies_liveness_insensitive_mreference
(l1 l2 : loc)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(x: HS.mreference t pre)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ loc_disjoint l1 (loc_mreference x) /\ address_liveness_insensitive_locs `loc_includes` l2 /\ h `HS.contains` x))
(ensures (h' `HS.contains` x))
[SMTPatOr [
[SMTPat (h `HS.contains` x); SMTPat (modifies (loc_union l1 l2) h h');];
[SMTPat (h' `HS.contains` x); SMTPat (modifies (loc_union l1 l2) h h');];
]]
(* TODO: pattern *)
val modifies_liveness_insensitive_buffer
(l1 l2:loc)
(h h':HS.mem)
(#a:Type0) (#rrel #rel:srel a)
(x:mbuffer a rrel rel)
:Lemma (requires (modifies (loc_union l1 l2) h h' /\
loc_disjoint l1 (loc_buffer x) /\
address_liveness_insensitive_locs `loc_includes` l2 /\
live h x))
(ensures (live h' x))
[SMTPatOr [
[SMTPat (live h x); SMTPat (modifies (loc_union l1 l2) h h');];
[SMTPat (live h' x); SMTPat (modifies (loc_union l1 l2) h h');];
]]
let modifies_liveness_insensitive_mreference_weak
(l : loc)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(x: HS.mreference t pre)
: Lemma (requires (modifies l h h' /\
address_liveness_insensitive_locs `loc_includes` l /\
h `HS.contains` x))
(ensures (h' `HS.contains` x))
[SMTPatOr [
[SMTPat (h `HS.contains` x); SMTPat (modifies l h h');];
[SMTPat (h' `HS.contains` x); SMTPat (modifies l h h');];
]]
= modifies_liveness_insensitive_mreference loc_none l h h' x
let modifies_liveness_insensitive_buffer_weak
(l:loc)
(h h':HS.mem)
(#a:Type0) (#rrel #rel:srel a)
(x:mbuffer a rrel rel)
:Lemma (requires (modifies l h h' /\ address_liveness_insensitive_locs `loc_includes` l /\ live h x))
(ensures (live h' x))
[SMTPatOr [
[SMTPat (live h x); SMTPat (modifies l h h');];
[SMTPat (live h' x); SMTPat (modifies l h h');];
]]
= modifies_liveness_insensitive_buffer loc_none l h h' x
val modifies_liveness_insensitive_region
(l1 l2 : loc)
(h h' : HS.mem)
(x: HS.rid)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ loc_disjoint l1 (loc_region_only false x) /\ region_liveness_insensitive_locs `loc_includes` l2 /\ HS.live_region h x))
(ensures (HS.live_region h' x))
[SMTPatOr [
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h x)];
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h' x)];
]]
val modifies_liveness_insensitive_region_mreference
(l1 l2 : loc)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(x: HS.mreference t pre)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ loc_disjoint l1 (loc_mreference x) /\ region_liveness_insensitive_locs `loc_includes` l2 /\ HS.live_region h (HS.frameOf x)))
(ensures (HS.live_region h' (HS.frameOf x)))
[SMTPatOr [
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h (HS.frameOf x))];
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h' (HS.frameOf x))];
]]
val modifies_liveness_insensitive_region_buffer
(l1 l2:loc)
(h h':HS.mem)
(#a:Type0) (#rrel #rel:srel a)
(x:mbuffer a rrel rel)
:Lemma (requires (modifies (loc_union l1 l2) h h' /\ loc_disjoint l1 (loc_buffer x) /\ region_liveness_insensitive_locs `loc_includes` l2 /\ HS.live_region h (frameOf x)))
(ensures (HS.live_region h' (frameOf x)))
[SMTPatOr [
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h (frameOf x))];
[SMTPat (modifies (loc_union l1 l2) h h'); SMTPat (HS.live_region h' (frameOf x))];
]]
let modifies_liveness_insensitive_region_weak
(l2 : loc)
(h h' : HS.mem)
(x: HS.rid)
: Lemma
(requires (modifies l2 h h' /\ region_liveness_insensitive_locs `loc_includes` l2 /\ HS.live_region h x))
(ensures (HS.live_region h' x))
[SMTPatOr [
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h x)];
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h' x)];
]]
= modifies_liveness_insensitive_region loc_none l2 h h' x
let modifies_liveness_insensitive_region_mreference_weak
(l2 : loc)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(x: HS.mreference t pre)
: Lemma (requires (modifies l2 h h' /\
region_liveness_insensitive_locs `loc_includes` l2 /\
HS.live_region h (HS.frameOf x)))
(ensures (HS.live_region h' (HS.frameOf x)))
[SMTPatOr [
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h (HS.frameOf x))];
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h' (HS.frameOf x))];
]]
= modifies_liveness_insensitive_region_mreference loc_none l2 h h' x
let modifies_liveness_insensitive_region_buffer_weak
(l2:loc)
(h h':HS.mem)
(#a:Type0) (#rrel #rel:srel a)
(x:mbuffer a rrel rel)
:Lemma (requires (modifies l2 h h' /\
region_liveness_insensitive_locs `loc_includes` l2 /\
HS.live_region h (frameOf x)))
(ensures (HS.live_region h' (frameOf x)))
[SMTPatOr [
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h (frameOf x))];
[SMTPat (modifies l2 h h'); SMTPat (HS.live_region h' (frameOf x))];
]]
= modifies_liveness_insensitive_region_buffer loc_none l2 h h' x
/// Modifies clauses are transitive. This lemma is the most general
/// one.
val modifies_trans
(s12: loc)
(h1 h2: HS.mem)
(s23: loc)
(h3: HS.mem)
: Lemma
(requires (modifies s12 h1 h2 /\ modifies s23 h2 h3))
(ensures (modifies (loc_union s12 s23) h1 h3))
let modifies_trans_linear (l l_goal:loc) (h1 h2 h3:HS.mem)
: Lemma (requires (modifies l h1 h2 /\ modifies l_goal h2 h3 /\ l_goal `loc_includes` l))
(ensures (modifies l_goal h1 h3))
[SMTPat (modifies l h1 h2); SMTPat (modifies l_goal h1 h3)]
= modifies_trans l h1 h2 l_goal h3
/// Regions that are not live can be removed from sets of memory
/// locations that are modified.
val modifies_only_live_regions
(rs: Set.set HS.rid)
(l: loc)
(h h' : HS.mem)
: Lemma
(requires (
modifies (loc_union (loc_regions false rs) l) h h' /\
(forall r . Set.mem r rs ==> (~ (HS.live_region h r)))
))
(ensures (modifies l h h'))
/// As a consequence, fresh regions can be removed from modifies
/// clauses.
val no_upd_fresh_region: r:HS.rid -> l:loc -> h0:HS.mem -> h1:HS.mem -> Lemma
(requires (HS.fresh_region r h0 h1 /\ modifies (loc_union (loc_all_regions_from false r) l) h0 h1))
(ensures (modifies l h0 h1))
[SMTPat (HS.fresh_region r h0 h1); SMTPat (modifies l h0 h1)]
val new_region_modifies (m0: HS.mem) (r0: HS.rid) (col: option int) : Lemma
(requires (HST.is_eternal_region r0 /\ HS.live_region m0 r0 /\ (None? col \/ HS.is_heap_color (Some?.v col))))
(ensures (
let (_, m1) = HS.new_eternal_region m0 r0 col in
modifies loc_none m0 m1
))
[SMTPat (HS.new_eternal_region m0 r0 col)]
/// Stack discipline: any stack frame (and all its transitively
/// extending regions) that is pushed, modified and popped can be
/// removed from a modifies clause.
/// AR: 01/29/2019: Removing the smt pattern from this lemma.
/// Clients are no longer expected to call it explicitly,
/// if you are having to, please raise an issue.
val modifies_fresh_frame_popped
(h0 h1: HS.mem)
(s: loc)
(h2 h3: HS.mem)
: Lemma
(requires (
HS.fresh_frame h0 h1 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h1)) s) h1 h2 /\
(HS.get_tip h2) == (HS.get_tip h1) /\
HS.popped h2 h3
))
(ensures (
modifies s h0 h3 /\
(HS.get_tip h3) == HS.get_tip h0
))
/// Compatibility lemmas to rescue modifies clauses specified in the
/// standard F* HyperStack library.
val modifies_loc_regions_intro
(rs: Set.set HS.rid)
(h1 h2: HS.mem)
: Lemma
(requires (HS.modifies rs h1 h2))
(ensures (modifies (loc_regions true rs) h1 h2))
val modifies_loc_addresses_intro
(r: HS.rid)
(a: Set.set nat)
(l: loc)
(h1 h2: HS.mem)
: Lemma
(requires (
HS.live_region h2 r /\
modifies (loc_union (loc_region_only false r) l) h1 h2 /\
HS.modifies_ref r a h1 h2
))
(ensures (modifies (loc_union (loc_addresses true r a) l) h1 h2))
/// Modifies clauses for allocating a reference: nothing is
/// modified. (In particular, a modifies clause does not track
/// memory locations that are created.)
val modifies_ralloc_post
(#a: Type)
(#rel: Preorder.preorder a)
(i: HS.rid)
(init: a)
(h: HS.mem)
(x: HST.mreference a rel)
(h' : HS.mem)
: Lemma
(requires (HST.ralloc_post i init h x h'))
(ensures (modifies loc_none h h'))
[SMTPat (HST.ralloc_post i init h x h')]
val modifies_salloc_post
(#a: Type)
(#rel: Preorder.preorder a)
(init: a)
(h: HS.mem)
(x: HST.mreference a rel { HS.is_stack_region (HS.frameOf x) } )
(h' : HS.mem)
: Lemma
(requires (HST.salloc_post init h x h'))
(ensures (modifies loc_none h h'))
[SMTPat (HST.salloc_post init h x h')]
/// Modifies clause for freeing a reference: the address is modified.
val modifies_free
(#a: Type)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel { HS.is_mm r } )
(m: HS.mem { m `HS.contains` r } )
: Lemma
(modifies (loc_freed_mreference r) m (HS.free r m))
[SMTPat (HS.free r m)]
/// Another compatibility lemma
val modifies_none_modifies
(h1 h2: HS.mem)
: Lemma
(requires (HST.modifies_none h1 h2))
(ensures (modifies loc_none h1 h2))
[SMTPat (HST.modifies_none h1 h2)]
/// Compatibility with HS.upd
val modifies_upd
(#t: Type) (#pre: Preorder.preorder t)
(r: HS.mreference t pre)
(v: t)
(h: HS.mem)
: Lemma
(requires (HS.contains h r))
(ensures (modifies (loc_mreference r) h (HS.upd h r v)))
[SMTPat (HS.upd h r v)]
/// Introduction lemma for modifying loc_buffer_from_to
val modifies_loc_buffer_from_to_intro
(#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
(from to: U32.t)
(l: loc) (h h' : HS.mem)
: Lemma
(requires (
let s = as_seq h b in
let s' = as_seq h' b in
live h b /\
modifies (loc_union l (loc_buffer b)) h h' /\
U32.v from <= U32.v to /\
U32.v to <= length b /\
Seq.slice s 0 (U32.v from) `Seq.equal` Seq.slice s' 0 (U32.v from) /\
Seq.slice s (U32.v to) (length b) `Seq.equal` Seq.slice s' (U32.v to) (length b)
))
(ensures (modifies (loc_union l (loc_buffer_from_to b from to)) h h'))
/// A memory ``h`` does not contain address ``a`` in region ``r``, denoted
/// ``does_not_contain_addr h (r, a)``, only if, either region ``r`` is
/// not live, or address ``a`` is unused in region ``r``.
(* BEGIN TODO: move to FStar.Monotonic.HyperStack *)
val does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: GTot Type0
val not_live_region_does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: Lemma
(requires (~ (HS.live_region h (fst ra))))
(ensures (h `does_not_contain_addr` ra))
val unused_in_does_not_contain_addr
(h: HS.mem)
(#a: Type)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
: Lemma
(requires (r `HS.unused_in` h))
(ensures (h `does_not_contain_addr` (HS.frameOf r, HS.as_addr r)))
val addr_unused_in_does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: Lemma
(requires (HS.live_region h (fst ra) ==> snd ra `Heap.addr_unused_in` (Map.sel (HS.get_hmap h) (fst ra))))
(ensures (h `does_not_contain_addr` ra))
val free_does_not_contain_addr
(#a: Type0)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
(m: HS.mem)
(x: HS.rid * nat)
: Lemma
(requires (
HS.is_mm r /\
m `HS.contains` r /\
fst x == HS.frameOf r /\
snd x == HS.as_addr r
))
(ensures (
HS.free r m `does_not_contain_addr` x
))
[SMTPat (HS.free r m `does_not_contain_addr` x)]
val does_not_contain_addr_elim
(#a: Type0)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
(m: HS.mem)
(x: HS.rid * nat)
: Lemma
(requires (
m `does_not_contain_addr` x /\
HS.frameOf r == fst x /\
HS.as_addr r == snd x
))
(ensures (~ (m `HS.contains` r)))
(** END TODO *)
/// Addresses that have not been allocated yet can be removed from
/// modifies clauses.
val modifies_only_live_addresses
(r: HS.rid)
(a: Set.set nat)
(l: loc)
(h h' : HS.mem)
: Lemma
(requires (
modifies (loc_union (loc_addresses false r a) l) h h' /\
(forall x . Set.mem x a ==> h `does_not_contain_addr` (r, x))
))
(ensures (modifies l h h'))
(* Generic way to ensure that a buffer just allocated is disjoint from
any other object, however the latter's liveness is defined. *)
val loc_not_unused_in (h: HS.mem) : GTot loc
val loc_unused_in (h: HS.mem) : GTot loc
(* Shortcut notations with more handy names *)
let loc_in (l: loc) (h: HS.mem) =
loc_not_unused_in h `loc_includes` l
let loc_not_in (l: loc) (h: HS.mem) =
loc_unused_in h `loc_includes` l
val loc_regions_unused_in (h: HS.mem) (rs: Set.set HS.rid) : Lemma
(requires (forall r . Set.mem r rs ==> (~ (HS.live_region h r))))
(ensures (loc_unused_in h `loc_includes` loc_regions false rs))
val loc_unused_in_not_unused_in_disjoint (h: HS.mem) : Lemma
(loc_disjoint (loc_unused_in h) (loc_not_unused_in h))
val not_live_region_loc_not_unused_in_disjoint
(h0: HS.mem)
(r: HS.rid)
: Lemma
(requires (~ (HS.live_region h0 r)))
(ensures (loc_disjoint (loc_region_only false r) (loc_not_unused_in h0)))
let fresh_frame_loc_not_unused_in_disjoint
(h0 h1: HS.mem)
: Lemma
(requires (HS.fresh_frame h0 h1))
(ensures (loc_disjoint (loc_region_only false (HS.get_tip h1)) (loc_not_unused_in h0)))
[SMTPat (HS.fresh_frame h0 h1)]
= not_live_region_loc_not_unused_in_disjoint h0 (HS.get_tip h1)
val live_loc_not_unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (requires (live h b))
(ensures (loc_not_unused_in h `loc_includes` loc_addr_of_buffer b))
[SMTPat (live h b)]
val unused_in_loc_unused_in (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (requires (unused_in b h))
(ensures (loc_unused_in h `loc_includes` loc_addr_of_buffer b))
[SMTPat (unused_in b h)]
val modifies_address_liveness_insensitive_unused_in
(h h' : HS.mem)
: Lemma
(requires (modifies (address_liveness_insensitive_locs) h h'))
(ensures (loc_not_unused_in h' `loc_includes` loc_not_unused_in h /\ loc_unused_in h `loc_includes` loc_unused_in h'))
/// Addresses that have not been allocated yet can be removed from
/// modifies clauses.
val modifies_only_not_unused_in
(l: loc)
(h h' : HS.mem)
: Lemma
(requires (modifies (loc_union (loc_unused_in h) l) h h'))
(ensures (modifies l h h'))
val mreference_live_loc_not_unused_in
(#t: Type)
(#pre: Preorder.preorder t)
(h: HS.mem)
(r: HS.mreference t pre)
: Lemma
(requires (h `HS.contains` r))
(ensures (loc_not_unused_in h `loc_includes` loc_freed_mreference r /\ loc_not_unused_in h `loc_includes` loc_mreference r))
[SMTPatOr [
[SMTPat (HS.contains h r)];
[SMTPat (loc_not_unused_in h `loc_includes` loc_mreference r)];
[SMTPat (loc_not_unused_in h `loc_includes` loc_freed_mreference r)];
]]
val mreference_unused_in_loc_unused_in
(#t: Type)
(#pre: Preorder.preorder t)
(h: HS.mem)
(r: HS.mreference t pre)
: Lemma
(requires (r `HS.unused_in` h))
(ensures (loc_unused_in h `loc_includes` loc_freed_mreference r /\ loc_unused_in h `loc_includes` loc_mreference r))
[SMTPatOr [
[SMTPat (HS.unused_in r h)];
[SMTPat (loc_unused_in h `loc_includes` loc_mreference r)];
[SMTPat (loc_unused_in h `loc_includes` loc_freed_mreference r)];
]]
let unused_in_not_unused_in_disjoint_2
(l1 l2 l1' l2': loc)
(h: HS.mem)
: Lemma
(requires (loc_unused_in h `loc_includes` l1 /\ loc_not_unused_in h `loc_includes` l2 /\ l1 `loc_includes` l1' /\ l2 `loc_includes` l2' ))
(ensures (loc_disjoint l1' l2' ))
[SMTPat (loc_disjoint l1' l2'); SMTPat (loc_unused_in h `loc_includes` l1); SMTPat (loc_not_unused_in h `loc_includes` l2)]
= loc_includes_trans (loc_unused_in h) l1 l1' ;
loc_includes_trans (loc_not_unused_in h) l2 l2' ;
loc_unused_in_not_unused_in_disjoint h ;
loc_disjoint_includes (loc_unused_in h) (loc_not_unused_in h) l1' l2'
val modifies_loc_unused_in
(l: loc)
(h1 h2: HS.mem)
(l' : loc)
: Lemma
(requires (
modifies l h1 h2 /\
address_liveness_insensitive_locs `loc_includes` l /\
loc_unused_in h2 `loc_includes` l'
))
(ensures (loc_unused_in h1 `loc_includes` l'))
[SMTPatOr [
[SMTPat (modifies l h1 h2); SMTPat (loc_unused_in h2 `loc_includes` l')];
[SMTPat (modifies l h1 h2); SMTPat (loc_unused_in h1 `loc_includes` l')];
]]
/// Shorthand: freshness
let fresh_loc (l: loc) (h h' : HS.mem) : GTot Type0 =
loc_unused_in h `loc_includes` l /\
loc_not_unused_in h' `loc_includes` l
let ralloc_post_fresh_loc (#a:Type) (#rel:Preorder.preorder a) (i: HS.rid) (init:a) (m0: HS.mem)
(x: HST.mreference a rel{HST.is_eternal_region (HS.frameOf x)}) (m1: HS.mem) : Lemma
(requires (HST.ralloc_post i init m0 x m1))
(ensures (fresh_loc (loc_freed_mreference x) m0 m1))
[SMTPat (HST.ralloc_post i init m0 x m1)]
= ()
//AR: this is needed for liveness across fresh_frame
val fresh_frame_modifies (h0 h1: HS.mem) : Lemma
(requires (HS.fresh_frame h0 h1))
(ensures (modifies loc_none h0 h1))
[SMTPat (HS.fresh_frame h0 h1)]
val popped_modifies (h0 h1: HS.mem) : Lemma
(requires (HS.popped h0 h1))
(ensures (modifies (loc_region_only false (HS.get_tip h0)) h0 h1))
[SMTPat (HS.popped h0 h1)]
val modifies_remove_new_locs (l_fresh l_aux l_goal:loc) (h1 h2 h3:HS.mem)
: Lemma (requires (fresh_loc l_fresh h1 h2 /\
modifies l_aux h1 h2 /\
l_goal `loc_includes` l_aux /\
modifies (loc_union l_fresh l_goal) h2 h3))
(ensures (modifies l_goal h1 h3))
[SMTPat (fresh_loc l_fresh h1 h2);
SMTPat (modifies l_aux h1 h2);
SMTPat (modifies l_goal h1 h3)]
(*
* AR: this lemma is framing the modifies clause across a fresh frame
* one way to do it would have been to reuse the lemma modifies_remove_new_locs,
* treating the fresh frame as another new location
* however, the way library is set up, loc_region in any form cannot be considered
* a fresh loc
* so, we have a special lemma for fresh_frame
*)
let modifies_remove_fresh_frame (h1 h2 h3:HS.mem) (l:loc)
: Lemma (requires (HS.fresh_frame h1 h2 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h2)) l) h2 h3))
(ensures (modifies l h1 h3))
[SMTPat (modifies l h1 h3); SMTPat (HS.fresh_frame h1 h2)]
= loc_regions_unused_in h1 (HS.mod_set (Set.singleton (HS.get_tip h2)));
modifies_only_not_unused_in l h1 h3
/// Legacy shorthands for disjointness and inclusion of buffers
///
let disjoint (#a1 #a2:Type0) (#rrel1 #rel1:srel a1) (#rrel2 #rel2:srel a2)
(b1:mbuffer a1 rrel1 rel1) (b2:mbuffer a2 rrel2 rel2) :GTot Type0 =
loc_disjoint (loc_buffer b1) (loc_buffer b2)
let includes (#a1 #a2:Type0) (#rrel1 #rel1:srel a1) (#rrel2 #rel2:srel a2)
(b1:mbuffer a1 rrel1 rel1) (b2:mbuffer a2 rrel2 rel2) :GTot Type0 =
loc_includes (loc_buffer b1) (loc_buffer b2) /\
(g_is_null b1 <==> g_is_null b2)
val disjoint_neq (#a1 #a2:Type0) (#rrel1 #rel1:srel a1) (#rrel2 #rel2:srel a2)
(b1:mbuffer a1 rrel1 rel1) (b2:mbuffer a2 rrel2 rel2)
:Lemma (requires (disjoint b1 b2 /\ U32.v (len b1) > 0))
(ensures (~(b1 === b2)))
val empty_disjoint (#t1 #t2: Type) (#rrel1 #rel1: srel t1) (#rrel2 #rel2: srel t2) (b1: mbuffer t1 rrel1 rel1) (b2: mbuffer t2 rrel2 rel2) : Lemma
(requires (length b1 == 0))
(ensures (disjoint b1 b2))
(*
/// The liveness of a sub-buffer entails from the liveness
/// of its enclosing buffer.
val includes_live (#a:Type0) (#rrel #rel1 #rel2:srel a)
(h:HS.mem) (larger:mbuffer a rrel rel1) (smaller:mbuffer a rrel rel2)
:Lemma (requires (larger `includes` smaller))
(ensures (live h larger ==> live h smaller))
[SMTPatOr [
[SMTPat (includes larger smaller); SMTPat (live h larger)];
[SMTPat (includes larger smaller); SMTPat (live h smaller)];
]]
*)
val includes_frameOf_as_addr (#a1 #a2:Type0) (#rrel1 #rel1:srel a1) (#rrel2 #rel2:srel a2)
(larger:mbuffer a1 rrel1 rel1) (smaller:mbuffer a2 rrel2 rel2)
:Lemma (requires (larger `includes` smaller))
(ensures (g_is_null larger == g_is_null smaller /\ frameOf larger == frameOf smaller /\ as_addr larger == as_addr smaller))
[SMTPat (larger `includes` smaller)]
///
/// Useful shorthands for pointers, or maybe-null pointers
inline_for_extraction
type mpointer (a:Type0) (rrel:srel a) (rel:srel a) =
b:mbuffer a rrel rel{length b == 1}
inline_for_extraction
type mpointer_or_null (a:Type0) (rrel:srel a) (rel:srel a) =
b:mbuffer a rrel rel{if g_is_null b then True else length b == 1}
unfold
let deref (#a:Type0) (#rrel #rel:srel a) (h:HS.mem) (x:mpointer a rrel rel) =
get h x 0
/// Two pointers having different contents are disjoint. This is valid
/// only for pointers, i.e. buffers of size 1.
val pointer_distinct_sel_disjoint
(#a:Type0) (#rrel1 #rrel2 #rel1 #rel2:srel a)
(b1:mpointer a rrel1 rel1)
(b2:mpointer a rrel2 rel2)
(h:HS.mem)
:Lemma (requires (live h b1 /\ live h b2 /\ get h b1 0 =!= get h b2 0))
(ensures (disjoint b1 b2))
/// The following stateful operations on buffers do not change the
/// memory, but, as required by the C standard, they all require the
/// buffer in question to be live.
/// The nullity test, ``is_null b``, which KaRaMeL compiles to C as ``b == NULL``.
val is_null (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel)
:HST.Stack bool (requires (fun h -> live h b))
(ensures (fun h y h' -> h == h' /\ y == g_is_null b))
/// ``sub b i len`` constructs the sub-buffer of ``b`` starting from
/// offset ``i`` with length ``len``. KaRaMeL extracts this operation as
/// ``b + i`` (or, equivalently, ``&b[i]``.)
val msub (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a) (b:mbuffer a rrel rel)
(i:U32.t) (len:Ghost.erased U32.t)
:HST.Stack (mbuffer a rrel sub_rel)
(requires (fun h -> U32.v i + U32.v (Ghost.reveal len) <= length b /\ compatible_sub b i (Ghost.reveal len) sub_rel /\ live h b))
(ensures (fun h y h' -> h == h' /\ y == mgsub sub_rel b i (Ghost.reveal len)))
/// ``offset b i`` construct the tail of the buffer ``b`` starting from
/// offset ``i``, i.e. the sub-buffer of ``b`` starting from offset ``i``
/// with length ``U32.sub (len b) i``. KaRaMeL compiles it as ``b + i`` or
/// ``&b[i]``.
///
/// This stateful operation cannot be derived from ``sub``, because the
/// length cannot be computed outside of proofs.
val moffset (#a:Type0) (#rrel #rel:srel a) (sub_rel:srel a) (b:mbuffer a rrel rel)
(i:U32.t)
:HST.Stack (mbuffer a rrel sub_rel)
(requires (fun h -> U32.v i <= length b /\ compatible_sub b i (U32.sub (len b) i) sub_rel /\ live h b))
(ensures (fun h y h' -> h == h' /\ y == mgsub sub_rel b i (U32.sub (len b) i)))
// goffset
/// ``index b i`` reads the value of ``b`` at offset ``i`` from memory and
/// returns it. KaRaMeL compiles it as b[i].
val index (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (i:U32.t)
:HST.Stack a (requires (fun h -> live h b /\ U32.v i < length b))
(ensures (fun h y h' -> h == h' /\ y == Seq.index (as_seq h b) (U32.v i)))
/// The following stateful operations on buffers modify the memory,
/// and, as usual, require the liveness of the buffer.
/// ``g_upd_seq b s h`` updates the entire buffer `b`'s contents in
/// heap `h` to correspond to the sequence `s`
val g_upd_seq (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel) (s:Seq.lseq a (length b))
(h:HS.mem{live h b})
:GTot HS.mem
val lemma_g_upd_with_same_seq (#a:Type0) (#rrel #rel:srel a) (b:mbuffer a rrel rel) (h:HS.mem)
:Lemma (requires (live h b)) (ensures (g_upd_seq b (as_seq h b) h == h))
/// A lemma specifying `g_upd_seq` in terms of its effect on the
/// buffer's underlying sequence
val g_upd_seq_as_seq (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(s:Seq.lseq a (length b))
(h:HS.mem{live h b})
: Lemma (let h' = g_upd_seq b s h in
(Seq.length s > 0 ==> not (g_is_null b)) /\
modifies (loc_buffer b) h h' /\
live h' b /\
HST.equal_domains h h' /\
as_seq h' b == s)
/// ``g_upd b i v h`` updates the buffer `b` in heap `h` at location
/// `i` writing ``v`` there. This is the spec analog of the stateful
/// update `upd` below.
let g_upd (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i:nat{i < length b})
(v:a)
(h:HS.mem{live h b})
: GTot HS.mem
= g_upd_seq b (Seq.upd (as_seq h b) i v) h
val g_upd_modifies_strong (#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i:nat{i < length b})
(v:a)
(h:HS.mem{live h b})
: Lemma (modifies (loc_buffer_from_to b (U32.uint_to_t i) (U32.uint_to_t (i + 1))) h (g_upd b i v h))
/// ``upd b i v`` writes ``v`` to the memory, at offset ``i`` of
/// buffer ``b``. KaRaMeL compiles it as ``b[i] = v``.
val upd'
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i:U32.t)
(v:a)
:HST.Stack unit (requires (fun h -> live h b /\ U32.v i < length b /\
rel (as_seq h b) (Seq.upd (as_seq h b) (U32.v i) v)))
(ensures (fun h _ h' -> h' == g_upd b (U32.v i) v h))
inline_for_extraction
let upd
(#a:Type0) (#rrel #rel:srel a)
(b:mbuffer a rrel rel)
(i:U32.t)
(v:a)
: HST.Stack unit (requires (fun h -> live h b /\ U32.v i < length b /\
rel (as_seq h b) (Seq.upd (as_seq h b) (U32.v i) v)))
(ensures (fun h _ h' -> (not (g_is_null b)) /\
modifies (loc_buffer b) h h' /\
live h' b /\ | false | false | LowStar.Monotonic.Buffer.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val upd (#a: Type0) (#rrel #rel: srel a) (b: mbuffer a rrel rel) (i: U32.t) (v: a)
: HST.Stack unit
(requires
(fun h ->
live h b /\ U32.v i < length b /\ rel (as_seq h b) (Seq.upd (as_seq h b) (U32.v i) v)))
(ensures
(fun h _ h' ->
(not (g_is_null b)) /\ modifies (loc_buffer b) h h' /\ live h' b /\
as_seq h' b == Seq.upd (as_seq h b) (U32.v i) v)) | [] | LowStar.Monotonic.Buffer.upd | {
"file_name": "ulib/LowStar.Monotonic.Buffer.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: LowStar.Monotonic.Buffer.mbuffer a rrel rel -> i: FStar.UInt32.t -> v: a
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 59,
"end_line": 1909,
"start_col": 3,
"start_line": 1907
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let intro_exists_witness_singleton (st:st_term) =
match st.term with
| Tm_IntroExists { witnesses = [_] } -> true
| _ -> false | let intro_exists_witness_singleton (st: st_term) = | false | null | false | match st.term with
| Tm_IntroExists { witnesses = [_] } -> true
| _ -> false | {
"checked_file": "Pulse.Checker.Exists.fsti.checked",
"dependencies": [
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Exists.fsti"
} | [
"total"
] | [
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.__proj__Mkst_term__item__term",
"Pulse.Syntax.Base.vprop",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.st_term'",
"Prims.bool"
] | [] | module Pulse.Checker.Exists
module T = FStar.Tactics.V2
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Base
val check_elim_exists
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_ElimExists? t.term})
: T.Tac (checker_result_t g pre post_hint) | false | true | Pulse.Checker.Exists.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val intro_exists_witness_singleton : st: Pulse.Syntax.Base.st_term -> Prims.bool | [] | Pulse.Checker.Exists.intro_exists_witness_singleton | {
"file_name": "lib/steel/pulse/Pulse.Checker.Exists.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | st: Pulse.Syntax.Base.st_term -> Prims.bool | {
"end_col": 14,
"end_line": 21,
"start_col": 2,
"start_line": 19
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let intro_exists_vprop (st:st_term { Tm_IntroExists? st.term }) =
match st.term with
| Tm_IntroExists { p } -> p | let intro_exists_vprop (st: st_term{Tm_IntroExists? st.term}) = | false | null | false | match st.term with | Tm_IntroExists { p = p } -> p | {
"checked_file": "Pulse.Checker.Exists.fsti.checked",
"dependencies": [
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Pulse.Checker.Exists.fsti"
} | [
"total"
] | [
"Pulse.Syntax.Base.st_term",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_Tm_IntroExists",
"Pulse.Syntax.Base.__proj__Mkst_term__item__term",
"Pulse.Syntax.Base.vprop",
"Prims.list",
"Pulse.Syntax.Base.term"
] | [] | module Pulse.Checker.Exists
module T = FStar.Tactics.V2
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Base
val check_elim_exists
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_ElimExists? t.term})
: T.Tac (checker_result_t g pre post_hint)
let intro_exists_witness_singleton (st:st_term) =
match st.term with
| Tm_IntroExists { witnesses = [_] } -> true
| _ -> false | false | false | Pulse.Checker.Exists.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val intro_exists_vprop : st: Pulse.Syntax.Base.st_term{Tm_IntroExists? (Mkst_term?.term st)} -> Pulse.Syntax.Base.vprop | [] | Pulse.Checker.Exists.intro_exists_vprop | {
"file_name": "lib/steel/pulse/Pulse.Checker.Exists.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | st: Pulse.Syntax.Base.st_term{Tm_IntroExists? (Mkst_term?.term st)} -> Pulse.Syntax.Base.vprop | {
"end_col": 29,
"end_line": 25,
"start_col": 2,
"start_line": 24
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_pre
(a:hash_alg)
(prev:extra_state a)
(blocks:bytes)
=
match a with
| Blake2B | Blake2S ->
(S.length blocks + prev) `less_than_max_input_length` a
| _ -> true | let update_multi_pre (a: hash_alg) (prev: extra_state a) (blocks: bytes) = | false | null | false | match a with
| Blake2B | Blake2S -> (S.length blocks + prev) `less_than_max_input_length` a
| _ -> true | {
"checked_file": "Spec.Agile.Hash.fsti.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.Hash.fsti"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.extra_state",
"Spec.Hash.Definitions.bytes",
"Spec.Hash.Definitions.less_than_max_input_length",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Prims.bool"
] | [] | module Spec.Agile.Hash
module S = FStar.Seq
include Spec.Hash.Definitions
open FStar.Mul
(** Hashes, agility, incrementality, streaming, and hash laws.
For various historical reasons, this module serves two purposes.
- For Merkle-Damgård algorithms (MD5, SHA1, SHA2), this module acts as a
*definitional* specification. This *is* the spec of the MD algorithms, and
low-level implementations (at least, historically) we shown to refine this
specification.
- For non-MD algorithms (Blake2, SHA3), this module serves a different purpose:
it shows that Blake2 and SHA3 obey the hash laws (more on that below), and
that therefore they can be suitably interpreted as behaving like hash
algorithms in this agile specification. The agile hash therefore obeys the
hash laws, because every algorithm does.
This agile specification, in addition to establishing the high-level property that
"all hash algorithms behave like hashes" (i.e., obey the hash laws), serves as
a specification of the agile, multiplexing hash known as EverCrypt.Hash.
The hash laws are as follows.
- Any hash algorithm can be decomposed into an *incremental* specification,
relying on: init, update_multi, update_last, finish. (The MD hashes
specifically decompose update_last as padding + update but this is not
generally true of all hashes.) See
Spec.Hash.Incremental.Definitions.hash_incremental, along with the various
proofs in Spec.Hash.Incremental.X that algorithm X is equivalent to its
incremental specification.
- The update_multi function, which processes n full blocks into the internal
hash state (also known as the accumulator, borrowing from functional
programming terminology for folds), takes the empty input as its neutral element.
Concretely:
update_multi acc empty == acc
- The update_multi function is associative. Concretely:
update_multi (update_multi acc blocks) blocks' == update_multi acc (blocks @ blocks')
Proving the three hash laws is important: they are needed by the streaming
functor (which turns a block-by-block implementation into a buffered
implementation that can take arbitrary amounts of data) for functional
correctness.
(In the case of MD hashes, the proof of incrementality specifically relies on
the two properties of update_multi, but this is not true in the general case.)
The incremental specification (in lemmas/Spec.Hash.Incremental.Definitions)
introduces a notion of "update_last" and then defines the hash as update_multi,
update_last, finish.
*)
val init (a:hash_alg): init_t a
let init_extra_state (a:hash_alg) : extra_state a = match a with
| Blake2B | Blake2S -> 0
| _ -> ()
(* The individual update function. This is an implementation detail, and clients
should reason in terms of update_multi to be fully agile. None of the hash laws
refer to update. *)
val update (a:md_alg): update_t a
(* Because of blake2, we unfortunately have this precondition creeping up. *)
let update_multi_pre
(a:hash_alg)
(prev:extra_state a)
(blocks:bytes) | false | false | Spec.Agile.Hash.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_multi_pre : a: Spec.Hash.Definitions.hash_alg ->
prev: Spec.Hash.Definitions.extra_state a ->
blocks: Spec.Hash.Definitions.bytes
-> Prims.bool | [] | Spec.Agile.Hash.update_multi_pre | {
"file_name": "specs/Spec.Agile.Hash.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg ->
prev: Spec.Hash.Definitions.extra_state a ->
blocks: Spec.Hash.Definitions.bytes
-> Prims.bool | {
"end_col": 13,
"end_line": 74,
"start_col": 2,
"start_line": 71
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash (a:fixed_len_alg) (input:bytes{S.length input `less_than_max_input_length` a}) =
hash' a input () | let hash (a: fixed_len_alg) (input: bytes{(S.length input) `less_than_max_input_length` a}) = | false | null | false | hash' a input () | {
"checked_file": "Spec.Agile.Hash.fsti.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.Hash.fsti"
} | [
"total"
] | [
"Spec.Hash.Definitions.fixed_len_alg",
"Spec.Hash.Definitions.bytes",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Agile.Hash.hash'",
"Lib.ByteSequence.lbytes",
"Spec.Hash.Definitions.hash_length'"
] | [] | module Spec.Agile.Hash
module S = FStar.Seq
include Spec.Hash.Definitions
open FStar.Mul
(** Hashes, agility, incrementality, streaming, and hash laws.
For various historical reasons, this module serves two purposes.
- For Merkle-Damgård algorithms (MD5, SHA1, SHA2), this module acts as a
*definitional* specification. This *is* the spec of the MD algorithms, and
low-level implementations (at least, historically) we shown to refine this
specification.
- For non-MD algorithms (Blake2, SHA3), this module serves a different purpose:
it shows that Blake2 and SHA3 obey the hash laws (more on that below), and
that therefore they can be suitably interpreted as behaving like hash
algorithms in this agile specification. The agile hash therefore obeys the
hash laws, because every algorithm does.
This agile specification, in addition to establishing the high-level property that
"all hash algorithms behave like hashes" (i.e., obey the hash laws), serves as
a specification of the agile, multiplexing hash known as EverCrypt.Hash.
The hash laws are as follows.
- Any hash algorithm can be decomposed into an *incremental* specification,
relying on: init, update_multi, update_last, finish. (The MD hashes
specifically decompose update_last as padding + update but this is not
generally true of all hashes.) See
Spec.Hash.Incremental.Definitions.hash_incremental, along with the various
proofs in Spec.Hash.Incremental.X that algorithm X is equivalent to its
incremental specification.
- The update_multi function, which processes n full blocks into the internal
hash state (also known as the accumulator, borrowing from functional
programming terminology for folds), takes the empty input as its neutral element.
Concretely:
update_multi acc empty == acc
- The update_multi function is associative. Concretely:
update_multi (update_multi acc blocks) blocks' == update_multi acc (blocks @ blocks')
Proving the three hash laws is important: they are needed by the streaming
functor (which turns a block-by-block implementation into a buffered
implementation that can take arbitrary amounts of data) for functional
correctness.
(In the case of MD hashes, the proof of incrementality specifically relies on
the two properties of update_multi, but this is not true in the general case.)
The incremental specification (in lemmas/Spec.Hash.Incremental.Definitions)
introduces a notion of "update_last" and then defines the hash as update_multi,
update_last, finish.
*)
val init (a:hash_alg): init_t a
let init_extra_state (a:hash_alg) : extra_state a = match a with
| Blake2B | Blake2S -> 0
| _ -> ()
(* The individual update function. This is an implementation detail, and clients
should reason in terms of update_multi to be fully agile. None of the hash laws
refer to update. *)
val update (a:md_alg): update_t a
(* Because of blake2, we unfortunately have this precondition creeping up. *)
let update_multi_pre
(a:hash_alg)
(prev:extra_state a)
(blocks:bytes)
=
match a with
| Blake2B | Blake2S ->
(S.length blocks + prev) `less_than_max_input_length` a
| _ -> true
(* Agile multi-block processing function shown to obey the hash laws. *)
val update_multi
(a:hash_alg)
(hash:words_state a)
(prev:extra_state a)
(blocks:bytes_blocks a):
Pure (words_state a)
(requires update_multi_pre a prev blocks)
(ensures fun _ -> True)
val finish (a:hash_alg): Spec.Hash.Definitions.finish_t a
val hash' (a:hash_alg) (input:bytes{S.length input `less_than_max_input_length` a}) (l: output_length a):
Tot (Lib.ByteSequence.lbytes (Spec.Hash.Definitions.hash_length' a l))
unfold | false | false | Spec.Agile.Hash.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash : a: Spec.Hash.Definitions.fixed_len_alg ->
input:
Spec.Hash.Definitions.bytes
{Spec.Hash.Definitions.less_than_max_input_length (FStar.Seq.Base.length input) a}
-> Lib.ByteSequence.lbytes (Spec.Hash.Definitions.hash_length' a ()) | [] | Spec.Agile.Hash.hash | {
"file_name": "specs/Spec.Agile.Hash.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.fixed_len_alg ->
input:
Spec.Hash.Definitions.bytes
{Spec.Hash.Definitions.less_than_max_input_length (FStar.Seq.Base.length input) a}
-> Lib.ByteSequence.lbytes (Spec.Hash.Definitions.hash_length' a ()) | {
"end_col": 18,
"end_line": 93,
"start_col": 2,
"start_line": 93
} |
|
Prims.Tot | val init_extra_state (a: hash_alg) : extra_state a | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let init_extra_state (a:hash_alg) : extra_state a = match a with
| Blake2B | Blake2S -> 0
| _ -> () | val init_extra_state (a: hash_alg) : extra_state a
let init_extra_state (a: hash_alg) : extra_state a = | false | null | false | match a with
| Blake2B | Blake2S -> 0
| _ -> () | {
"checked_file": "Spec.Agile.Hash.fsti.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Agile.Hash.fsti"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.extra_state"
] | [] | module Spec.Agile.Hash
module S = FStar.Seq
include Spec.Hash.Definitions
open FStar.Mul
(** Hashes, agility, incrementality, streaming, and hash laws.
For various historical reasons, this module serves two purposes.
- For Merkle-Damgård algorithms (MD5, SHA1, SHA2), this module acts as a
*definitional* specification. This *is* the spec of the MD algorithms, and
low-level implementations (at least, historically) we shown to refine this
specification.
- For non-MD algorithms (Blake2, SHA3), this module serves a different purpose:
it shows that Blake2 and SHA3 obey the hash laws (more on that below), and
that therefore they can be suitably interpreted as behaving like hash
algorithms in this agile specification. The agile hash therefore obeys the
hash laws, because every algorithm does.
This agile specification, in addition to establishing the high-level property that
"all hash algorithms behave like hashes" (i.e., obey the hash laws), serves as
a specification of the agile, multiplexing hash known as EverCrypt.Hash.
The hash laws are as follows.
- Any hash algorithm can be decomposed into an *incremental* specification,
relying on: init, update_multi, update_last, finish. (The MD hashes
specifically decompose update_last as padding + update but this is not
generally true of all hashes.) See
Spec.Hash.Incremental.Definitions.hash_incremental, along with the various
proofs in Spec.Hash.Incremental.X that algorithm X is equivalent to its
incremental specification.
- The update_multi function, which processes n full blocks into the internal
hash state (also known as the accumulator, borrowing from functional
programming terminology for folds), takes the empty input as its neutral element.
Concretely:
update_multi acc empty == acc
- The update_multi function is associative. Concretely:
update_multi (update_multi acc blocks) blocks' == update_multi acc (blocks @ blocks')
Proving the three hash laws is important: they are needed by the streaming
functor (which turns a block-by-block implementation into a buffered
implementation that can take arbitrary amounts of data) for functional
correctness.
(In the case of MD hashes, the proof of incrementality specifically relies on
the two properties of update_multi, but this is not true in the general case.)
The incremental specification (in lemmas/Spec.Hash.Incremental.Definitions)
introduces a notion of "update_last" and then defines the hash as update_multi,
update_last, finish.
*)
val init (a:hash_alg): init_t a | false | false | Spec.Agile.Hash.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val init_extra_state (a: hash_alg) : extra_state a | [] | Spec.Agile.Hash.init_extra_state | {
"file_name": "specs/Spec.Agile.Hash.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Spec.Hash.Definitions.extra_state a | {
"end_col": 11,
"end_line": 58,
"start_col": 52,
"start_line": 56
} |
Prims.Tot | val wrap_slice (#a: Type0) (s: Seq.seq a) (i: int) : Seq.seq a | [
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Gcm_simplify",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.Simplify_Sha",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64.GCM_IV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a =
Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) | val wrap_slice (#a: Type0) (s: Seq.seq a) (i: int) : Seq.seq a
let wrap_slice (#a: Type0) (s: Seq.seq a) (i: int) : Seq.seq a = | false | null | false | Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) | {
"checked_file": "Vale.Wrapper.X64.GCM_IV.fst.checked",
"dependencies": [
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Stdcalls.X64.GCM_IV.fst.checked",
"Vale.SHA.Simplify_Sha.fsti.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.Gcm_simplify.fsti.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Integers.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Wrapper.X64.GCM_IV.fst"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"FStar.Integers.int",
"FStar.Seq.Base.slice",
"Prims.op_AmpAmp",
"FStar.Integers.op_Less_Equals",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Seq.Base.length",
"Prims.bool",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual"
] | [] | module Vale.Wrapper.X64.GCM_IV
open FStar.Mul
open Vale.Stdcalls.X64.GCM_IV
open Vale.AsLowStar.MemoryHelpers
open Vale.X64.MemoryAdapters
module V = Vale.X64.Decls
open Vale.SHA.Simplify_Sha
open Vale.AES.Gcm_simplify
open Vale.AES.GCM_helpers
open Vale.Arch.Types
open Vale.AES.GHash
open FStar.Integers
open FStar.Int.Cast | false | false | Vale.Wrapper.X64.GCM_IV.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val wrap_slice (#a: Type0) (s: Seq.seq a) (i: int) : Seq.seq a | [] | Vale.Wrapper.X64.GCM_IV.wrap_slice | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCM_IV.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq a -> i: FStar.Integers.int -> FStar.Seq.Base.seq a | {
"end_col": 62,
"end_line": 17,
"start_col": 2,
"start_line": 17
} |
FStar.Pervasives.Lemma | val length_aux5 (b: uint8_p)
: Lemma (requires B.length b = 128) (ensures DV.length (get_downview b) % 16 = 0) | [
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Gcm_simplify",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.Simplify_Sha",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64.GCM_IV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let length_aux5 (b:uint8_p) : Lemma
(requires B.length b = 128)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db | val length_aux5 (b: uint8_p)
: Lemma (requires B.length b = 128) (ensures DV.length (get_downview b) % 16 = 0)
let length_aux5 (b: uint8_p)
: Lemma (requires B.length b = 128) (ensures DV.length (get_downview b) % 16 = 0) = | false | null | true | let db = get_downview b in
DV.length_eq db | {
"checked_file": "Vale.Wrapper.X64.GCM_IV.fst.checked",
"dependencies": [
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Stdcalls.X64.GCM_IV.fst.checked",
"Vale.SHA.Simplify_Sha.fsti.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.Gcm_simplify.fsti.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Integers.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Wrapper.X64.GCM_IV.fst"
} | [
"lemma"
] | [
"Vale.Wrapper.X64.GCM_IV.uint8_p",
"LowStar.BufferView.Down.length_eq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"Vale.Arch.HeapTypes_s.TUInt8",
"LowStar.Buffer.trivial_preorder",
"Prims.unit",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"LowStar.Monotonic.Buffer.length",
"Prims.squash",
"FStar.Integers.op_Percent",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"LowStar.BufferView.Down.length",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Wrapper.X64.GCM_IV
open FStar.Mul
open Vale.Stdcalls.X64.GCM_IV
open Vale.AsLowStar.MemoryHelpers
open Vale.X64.MemoryAdapters
module V = Vale.X64.Decls
open Vale.SHA.Simplify_Sha
open Vale.AES.Gcm_simplify
open Vale.AES.GCM_helpers
open Vale.Arch.Types
open Vale.AES.GHash
open FStar.Integers
open FStar.Int.Cast
let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a =
Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0)
let length_aux (b:uint8_p) (n:nat) : Lemma
(requires B.length b = 16 * n)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_mod n 16
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let length_aux5 (b:uint8_p) : Lemma | false | false | Vale.Wrapper.X64.GCM_IV.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val length_aux5 (b: uint8_p)
: Lemma (requires B.length b = 128) (ensures DV.length (get_downview b) % 16 = 0) | [] | Vale.Wrapper.X64.GCM_IV.length_aux5 | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCM_IV.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.Wrapper.X64.GCM_IV.uint8_p
-> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.length b = 128)
(ensures LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b) % 16 = 0) | {
"end_col": 19,
"end_line": 32,
"start_col": 49,
"start_line": 30
} |
FStar.Pervasives.Lemma | val length_aux (b: uint8_p) (n: nat)
: Lemma (requires B.length b = 16 * n) (ensures DV.length (get_downview b) % 16 = 0) | [
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Gcm_simplify",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.Simplify_Sha",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64.GCM_IV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let length_aux (b:uint8_p) (n:nat) : Lemma
(requires B.length b = 16 * n)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_mod n 16 | val length_aux (b: uint8_p) (n: nat)
: Lemma (requires B.length b = 16 * n) (ensures DV.length (get_downview b) % 16 = 0)
let length_aux (b: uint8_p) (n: nat)
: Lemma (requires B.length b = 16 * n) (ensures DV.length (get_downview b) % 16 = 0) = | false | null | true | let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_mod n 16 | {
"checked_file": "Vale.Wrapper.X64.GCM_IV.fst.checked",
"dependencies": [
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Stdcalls.X64.GCM_IV.fst.checked",
"Vale.SHA.Simplify_Sha.fsti.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.Gcm_simplify.fsti.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Integers.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Wrapper.X64.GCM_IV.fst"
} | [
"lemma"
] | [
"Vale.Wrapper.X64.GCM_IV.uint8_p",
"FStar.Integers.nat",
"FStar.Math.Lemmas.cancel_mul_mod",
"Prims.unit",
"LowStar.BufferView.Down.length_eq",
"FStar.UInt8.t",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"Vale.Arch.HeapTypes_s.TUInt8",
"LowStar.Buffer.trivial_preorder",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"LowStar.Monotonic.Buffer.length",
"FStar.Integers.op_Star",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"Prims.squash",
"FStar.Integers.op_Percent",
"LowStar.BufferView.Down.length",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Wrapper.X64.GCM_IV
open FStar.Mul
open Vale.Stdcalls.X64.GCM_IV
open Vale.AsLowStar.MemoryHelpers
open Vale.X64.MemoryAdapters
module V = Vale.X64.Decls
open Vale.SHA.Simplify_Sha
open Vale.AES.Gcm_simplify
open Vale.AES.GCM_helpers
open Vale.Arch.Types
open Vale.AES.GHash
open FStar.Integers
open FStar.Int.Cast
let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a =
Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0)
let length_aux (b:uint8_p) (n:nat) : Lemma | false | false | Vale.Wrapper.X64.GCM_IV.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val length_aux (b: uint8_p) (n: nat)
: Lemma (requires B.length b = 16 * n) (ensures DV.length (get_downview b) % 16 = 0) | [] | Vale.Wrapper.X64.GCM_IV.length_aux | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCM_IV.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.Wrapper.X64.GCM_IV.uint8_p -> n: FStar.Integers.nat
-> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.length b = 16 * n)
(ensures LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b) % 16 = 0) | {
"end_col": 41,
"end_line": 24,
"start_col": 49,
"start_line": 21
} |
FStar.Pervasives.Lemma | val lemma_same_seq_same_buffer_read (h0 h1: HS.mem) (b: uint8_p)
: Lemma
(requires
B.live h0 b /\ B.live h1 b /\ B.length b == 128 /\
(B.as_seq h0 b) `Seq.equal` (B.as_seq h1 b))
(ensures
(DV.length_eq (get_downview b);
low_buffer_read TUInt8 TUInt128 h0 b 2 == low_buffer_read TUInt8 TUInt128 h1 b 2)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Gcm_simplify",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.Simplify_Sha",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64.GCM_IV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_same_seq_same_buffer_read (h0 h1:HS.mem) (b:uint8_p) : Lemma
(requires
B.live h0 b /\ B.live h1 b /\
B.length b == 128 /\ B.as_seq h0 b `Seq.equal` B.as_seq h1 b)
(ensures (
DV.length_eq (get_downview b);
low_buffer_read TUInt8 TUInt128 h0 b 2 == low_buffer_read TUInt8 TUInt128 h1 b 2)
)
=
let b_d = get_downview b in
DV.length_eq b_d;
let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in
lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1;
lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1;
UV.length_eq b_u;
UV.as_seq_sel h0 b_u 2;
UV.as_seq_sel h1 b_u 2 | val lemma_same_seq_same_buffer_read (h0 h1: HS.mem) (b: uint8_p)
: Lemma
(requires
B.live h0 b /\ B.live h1 b /\ B.length b == 128 /\
(B.as_seq h0 b) `Seq.equal` (B.as_seq h1 b))
(ensures
(DV.length_eq (get_downview b);
low_buffer_read TUInt8 TUInt128 h0 b 2 == low_buffer_read TUInt8 TUInt128 h1 b 2))
let lemma_same_seq_same_buffer_read (h0 h1: HS.mem) (b: uint8_p)
: Lemma
(requires
B.live h0 b /\ B.live h1 b /\ B.length b == 128 /\
(B.as_seq h0 b) `Seq.equal` (B.as_seq h1 b))
(ensures
(DV.length_eq (get_downview b);
low_buffer_read TUInt8 TUInt128 h0 b 2 == low_buffer_read TUInt8 TUInt128 h1 b 2)) = | false | null | true | let b_d = get_downview b in
DV.length_eq b_d;
let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in
lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1;
lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1;
UV.length_eq b_u;
UV.as_seq_sel h0 b_u 2;
UV.as_seq_sel h1 b_u 2 | {
"checked_file": "Vale.Wrapper.X64.GCM_IV.fst.checked",
"dependencies": [
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Stdcalls.X64.GCM_IV.fst.checked",
"Vale.SHA.Simplify_Sha.fsti.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.Gcm_simplify.fsti.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Integers.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Wrapper.X64.GCM_IV.fst"
} | [
"lemma"
] | [
"FStar.Monotonic.HyperStack.mem",
"Vale.Wrapper.X64.GCM_IV.uint8_p",
"LowStar.BufferView.Up.as_seq_sel",
"Vale.Def.Types_s.quad32",
"Prims.unit",
"LowStar.BufferView.Up.length_eq",
"Vale.Lib.BufferViewHelpers.lemma_uv_equal",
"FStar.UInt8.t",
"Vale.Interop.Views.up_view128",
"Vale.Interop.Types.get_downview",
"Vale.Arch.HeapTypes_s.TUInt8",
"LowStar.Buffer.trivial_preorder",
"Vale.Lib.BufferViewHelpers.lemma_dv_equal",
"Vale.Interop.Views.down_view8",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.mk_buffer",
"LowStar.BufferView.Down.length_eq",
"LowStar.BufferView.Down.buffer",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Prims.eq2",
"Prims.int",
"LowStar.Monotonic.Buffer.length",
"FStar.Seq.Base.equal",
"LowStar.Monotonic.Buffer.as_seq",
"Prims.squash",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Arch.HeapTypes_s.TUInt128",
"Vale.AsLowStar.MemoryHelpers.low_buffer_read",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Wrapper.X64.GCM_IV
open FStar.Mul
open Vale.Stdcalls.X64.GCM_IV
open Vale.AsLowStar.MemoryHelpers
open Vale.X64.MemoryAdapters
module V = Vale.X64.Decls
open Vale.SHA.Simplify_Sha
open Vale.AES.Gcm_simplify
open Vale.AES.GCM_helpers
open Vale.Arch.Types
open Vale.AES.GHash
open FStar.Integers
open FStar.Int.Cast
let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a =
Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0)
let length_aux (b:uint8_p) (n:nat) : Lemma
(requires B.length b = 16 * n)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_mod n 16
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let length_aux5 (b:uint8_p) : Lemma
(requires B.length b = 128)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db
#push-options "--z3cliopt smt.arith.nl=true"
inline_for_extraction
val compute_iv_stdcall':
iv:Ghost.erased supported_iv_LE ->
iv_b:uint8_p ->
num_bytes:uint64 ->
len:uint64 ->
j0_b:uint8_p ->
iv_extra_b:uint8_p ->
hkeys_b:uint8_p ->
Stack unit
(requires fun h0 ->
B.disjoint iv_b j0_b /\ B.disjoint iv_b iv_extra_b /\ B.disjoint iv_b hkeys_b /\
(B.disjoint j0_b iv_extra_b \/ j0_b == iv_extra_b) /\
B.disjoint j0_b hkeys_b /\ B.disjoint iv_extra_b hkeys_b /\
B.live h0 iv_b /\ B.live h0 j0_b /\ B.live h0 iv_extra_b /\ B.live h0 hkeys_b /\
B.length iv_b == 16 * UInt64.v len /\
B.length j0_b == 16 /\
B.length iv_extra_b == 16 /\
B.length hkeys_b == 128 /\
UInt64.v len * (128/8) <= UInt64.v num_bytes /\
UInt64.v num_bytes < UInt64.v len * (128/8) + 128/8 /\
0 < 8 * UInt64.v num_bytes /\
8 * UInt64.v num_bytes < pow2_64 /\
pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\
( let db = get_downview hkeys_b in
length_aux5 hkeys_b; DV.length_eq (get_downview hkeys_b);
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32
(reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2)))) /\
( let in_d = get_downview iv_b in
length_aux iv_b (UInt64.v len);
let in_u = UV.mk_buffer in_d Vale.Interop.Views.up_view128 in
let inout_d = get_downview iv_extra_b in
length_aux iv_extra_b 1;
let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in
let iv_raw_quads = Seq.append (UV.as_seq h0 in_u) (UV.as_seq h0 inout_u) in
let iv_bytes_LE = wrap_slice (le_seq_quad32_to_bytes iv_raw_quads) (UInt64.v num_bytes) in
Seq.equal iv_bytes_LE (Ghost.reveal iv)
)
)
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer j0_b) h0 h1 /\
(DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview j0_b);
let h_LE = reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2) in
low_buffer_read TUInt8 TUInt128 h1 j0_b 0 == compute_iv_BE h_LE (Ghost.reveal iv))
)
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#set-options "--ext compat:normalizer_memo_ignore_cfg"
inline_for_extraction
let compute_iv_stdcall' iv iv_b num_bytes len j0_b iv_extra_b hkeys_b =
let h0 = get() in
DV.length_eq (get_downview iv_b);
DV.length_eq (get_downview iv_extra_b);
DV.length_eq (get_downview j0_b);
DV.length_eq (get_downview hkeys_b);
as_vale_buffer_len #TUInt8 #TUInt128 iv_b;
as_vale_buffer_len #TUInt8 #TUInt128 iv_extra_b;
as_vale_buffer_len #TUInt8 #TUInt128 j0_b;
as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b;
bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b;
bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b;
let (x, _) = compute_iv_stdcall iv iv_b num_bytes len j0_b iv_extra_b hkeys_b () in
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires
B.length b_start = B.length b / 16 * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\
B.length b_extra = 16 /\
Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))
)
(ensures (
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b))
))
=
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in
// if B.length b > B.length b_start then (
calc (==) {
sf;
(==) { DV.length_eq b_start_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(UV.as_seq h b_extra_u)))
(B.length b);
(==) { DV.length_eq b_extra_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
(==) { append_distributes_le_seq_quad32_to_bytes
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
}
wrap_slice (Seq.append
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))))
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
(==) { le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start));
le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)) }
wrap_slice (Seq.append
(seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b);
(==) { Seq.lemma_eq_intro b_f
(wrap_slice (Seq.append
(seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b))
}
b_f;
}
#pop-options
let lemma_slice_sub (b:uint8_p) (b_sub:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires B.length b_extra = 16 /\ B.length b_sub = B.length b / 16 * 16 /\
b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\
Seq.equal
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))
)
(ensures Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))
) =
calc (==) {
Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b);
(==) { Seq.lemma_eq_intro
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))
(Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)))
}
Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16));
(==) { }
Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16));
(==) { }
Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b));
(==) { Seq.lemma_eq_intro (B.as_seq h b)
(Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b)))
}
B.as_seq h b;
}
open Vale.Lib.BufferViewHelpers
#push-options "--smtencoding.nl_arith_repr boxwrap"
let lemma_same_seq_same_buffer_read (h0 h1:HS.mem) (b:uint8_p) : Lemma
(requires
B.live h0 b /\ B.live h1 b /\
B.length b == 128 /\ B.as_seq h0 b `Seq.equal` B.as_seq h1 b)
(ensures (
DV.length_eq (get_downview b);
low_buffer_read TUInt8 TUInt128 h0 b 2 == low_buffer_read TUInt8 TUInt128 h1 b 2) | false | false | Vale.Wrapper.X64.GCM_IV.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "boxwrap",
"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"
} | null | val lemma_same_seq_same_buffer_read (h0 h1: HS.mem) (b: uint8_p)
: Lemma
(requires
B.live h0 b /\ B.live h1 b /\ B.length b == 128 /\
(B.as_seq h0 b) `Seq.equal` (B.as_seq h1 b))
(ensures
(DV.length_eq (get_downview b);
low_buffer_read TUInt8 TUInt128 h0 b 2 == low_buffer_read TUInt8 TUInt128 h1 b 2)) | [] | Vale.Wrapper.X64.GCM_IV.lemma_same_seq_same_buffer_read | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCM_IV.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
b: Vale.Wrapper.X64.GCM_IV.uint8_p
-> FStar.Pervasives.Lemma
(requires
LowStar.Monotonic.Buffer.live h0 b /\ LowStar.Monotonic.Buffer.live h1 b /\
LowStar.Monotonic.Buffer.length b == 128 /\
FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h0 b)
(LowStar.Monotonic.Buffer.as_seq h1 b))
(ensures
([@@ FStar.Pervasives.inline_let ]let _ =
LowStar.BufferView.Down.length_eq (Vale.Interop.Types.get_downview b)
in
Vale.AsLowStar.MemoryHelpers.low_buffer_read Vale.Arch.HeapTypes_s.TUInt8
Vale.Arch.HeapTypes_s.TUInt128
h0
b
2 ==
Vale.AsLowStar.MemoryHelpers.low_buffer_read Vale.Arch.HeapTypes_s.TUInt8
Vale.Arch.HeapTypes_s.TUInt128
h1
b
2)) | {
"end_col": 25,
"end_line": 240,
"start_col": 4,
"start_line": 232
} |
FStar.Pervasives.Lemma | val lemma_slice_uv_extra (b b_start b_extra: uint8_p) (h: HS.mem)
: Lemma
(requires
B.length b_start = (B.length b / 16) * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\
Seq.equal (B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b)))
(ensures
(let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)))) | [
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Gcm_simplify",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.Simplify_Sha",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64.GCM_IV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires
B.length b_start = B.length b / 16 * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\
B.length b_extra = 16 /\
Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))
)
(ensures (
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b))
))
=
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in
// if B.length b > B.length b_start then (
calc (==) {
sf;
(==) { DV.length_eq b_start_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(UV.as_seq h b_extra_u)))
(B.length b);
(==) { DV.length_eq b_extra_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
(==) { append_distributes_le_seq_quad32_to_bytes
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
}
wrap_slice (Seq.append
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))))
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
(==) { le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start));
le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)) }
wrap_slice (Seq.append
(seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b);
(==) { Seq.lemma_eq_intro b_f
(wrap_slice (Seq.append
(seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b))
}
b_f;
} | val lemma_slice_uv_extra (b b_start b_extra: uint8_p) (h: HS.mem)
: Lemma
(requires
B.length b_start = (B.length b / 16) * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\
Seq.equal (B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b)))
(ensures
(let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b))))
let lemma_slice_uv_extra (b b_start b_extra: uint8_p) (h: HS.mem)
: Lemma
(requires
B.length b_start = (B.length b / 16) * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\
Seq.equal (B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b)))
(ensures
(let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)))) = | false | null | true | let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in
calc ( == ) {
sf;
( == ) { (DV.length_eq b_start_d;
lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u)) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq
h
b_start)))
(UV.as_seq h b_extra_u)))
(B.length b);
( == ) { (DV.length_eq b_extra_d;
lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u)) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq
h
b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
( == ) { append_distributes_le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (
B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) }
wrap_slice (Seq.append (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq
h
b_start))))
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))
)))
(B.length b);
( == ) { (le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start));
le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) }
wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b);
( == ) { Seq.lemma_eq_intro b_f
(wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b)) }
b_f;
} | {
"checked_file": "Vale.Wrapper.X64.GCM_IV.fst.checked",
"dependencies": [
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Stdcalls.X64.GCM_IV.fst.checked",
"Vale.SHA.Simplify_Sha.fsti.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.Gcm_simplify.fsti.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Integers.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Wrapper.X64.GCM_IV.fst"
} | [
"lemma"
] | [
"Vale.Wrapper.X64.GCM_IV.uint8_p",
"FStar.Monotonic.HyperStack.mem",
"FStar.Calc.calc_finish",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Prims.eq2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Vale.Wrapper.X64.GCM_IV.wrap_slice",
"Vale.Def.Words_s.nat8",
"FStar.Seq.Base.append",
"Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.UInt8.t",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.length",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.Def.Types_s.quad32",
"LowStar.BufferView.Up.as_seq",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes",
"Vale.SHA.Simplify_Sha.lemma_seq_nat8_le_seq_quad32_to_bytes_uint32",
"LowStar.BufferView.Down.length_eq",
"Prims.squash",
"Vale.Arch.Types.append_distributes_le_seq_quad32_to_bytes",
"Vale.Arch.Types.le_seq_quad32_to_bytes_to_seq_quad32",
"FStar.Seq.Base.lemma_eq_intro",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.mk_buffer",
"Vale.Interop.Views.up_view128",
"Vale.Interop.Types.get_downview",
"Vale.Arch.HeapTypes_s.TUInt8",
"LowStar.BufferView.Down.buffer",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Integers.op_Star",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Integers.op_Slash",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.uint_to_t",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.slice",
"FStar.Pervasives.pattern"
] | [] | module Vale.Wrapper.X64.GCM_IV
open FStar.Mul
open Vale.Stdcalls.X64.GCM_IV
open Vale.AsLowStar.MemoryHelpers
open Vale.X64.MemoryAdapters
module V = Vale.X64.Decls
open Vale.SHA.Simplify_Sha
open Vale.AES.Gcm_simplify
open Vale.AES.GCM_helpers
open Vale.Arch.Types
open Vale.AES.GHash
open FStar.Integers
open FStar.Int.Cast
let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a =
Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0)
let length_aux (b:uint8_p) (n:nat) : Lemma
(requires B.length b = 16 * n)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_mod n 16
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let length_aux5 (b:uint8_p) : Lemma
(requires B.length b = 128)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db
#push-options "--z3cliopt smt.arith.nl=true"
inline_for_extraction
val compute_iv_stdcall':
iv:Ghost.erased supported_iv_LE ->
iv_b:uint8_p ->
num_bytes:uint64 ->
len:uint64 ->
j0_b:uint8_p ->
iv_extra_b:uint8_p ->
hkeys_b:uint8_p ->
Stack unit
(requires fun h0 ->
B.disjoint iv_b j0_b /\ B.disjoint iv_b iv_extra_b /\ B.disjoint iv_b hkeys_b /\
(B.disjoint j0_b iv_extra_b \/ j0_b == iv_extra_b) /\
B.disjoint j0_b hkeys_b /\ B.disjoint iv_extra_b hkeys_b /\
B.live h0 iv_b /\ B.live h0 j0_b /\ B.live h0 iv_extra_b /\ B.live h0 hkeys_b /\
B.length iv_b == 16 * UInt64.v len /\
B.length j0_b == 16 /\
B.length iv_extra_b == 16 /\
B.length hkeys_b == 128 /\
UInt64.v len * (128/8) <= UInt64.v num_bytes /\
UInt64.v num_bytes < UInt64.v len * (128/8) + 128/8 /\
0 < 8 * UInt64.v num_bytes /\
8 * UInt64.v num_bytes < pow2_64 /\
pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\
( let db = get_downview hkeys_b in
length_aux5 hkeys_b; DV.length_eq (get_downview hkeys_b);
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32
(reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2)))) /\
( let in_d = get_downview iv_b in
length_aux iv_b (UInt64.v len);
let in_u = UV.mk_buffer in_d Vale.Interop.Views.up_view128 in
let inout_d = get_downview iv_extra_b in
length_aux iv_extra_b 1;
let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in
let iv_raw_quads = Seq.append (UV.as_seq h0 in_u) (UV.as_seq h0 inout_u) in
let iv_bytes_LE = wrap_slice (le_seq_quad32_to_bytes iv_raw_quads) (UInt64.v num_bytes) in
Seq.equal iv_bytes_LE (Ghost.reveal iv)
)
)
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer j0_b) h0 h1 /\
(DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview j0_b);
let h_LE = reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2) in
low_buffer_read TUInt8 TUInt128 h1 j0_b 0 == compute_iv_BE h_LE (Ghost.reveal iv))
)
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#set-options "--ext compat:normalizer_memo_ignore_cfg"
inline_for_extraction
let compute_iv_stdcall' iv iv_b num_bytes len j0_b iv_extra_b hkeys_b =
let h0 = get() in
DV.length_eq (get_downview iv_b);
DV.length_eq (get_downview iv_extra_b);
DV.length_eq (get_downview j0_b);
DV.length_eq (get_downview hkeys_b);
as_vale_buffer_len #TUInt8 #TUInt128 iv_b;
as_vale_buffer_len #TUInt8 #TUInt128 iv_extra_b;
as_vale_buffer_len #TUInt8 #TUInt128 j0_b;
as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b;
bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b;
bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b;
let (x, _) = compute_iv_stdcall iv iv_b num_bytes len j0_b iv_extra_b hkeys_b () in
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires
B.length b_start = B.length b / 16 * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\
B.length b_extra = 16 /\
Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))
)
(ensures (
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)) | false | false | Vale.Wrapper.X64.GCM_IV.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3",
"smt.arith.nl=true"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_slice_uv_extra (b b_start b_extra: uint8_p) (h: HS.mem)
: Lemma
(requires
B.length b_start = (B.length b / 16) * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\
Seq.equal (B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b)))
(ensures
(let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)))) | [] | Vale.Wrapper.X64.GCM_IV.lemma_slice_uv_extra | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCM_IV.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.Wrapper.X64.GCM_IV.uint8_p ->
b_start: Vale.Wrapper.X64.GCM_IV.uint8_p ->
b_extra: Vale.Wrapper.X64.GCM_IV.uint8_p ->
h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
LowStar.Monotonic.Buffer.length b_start = (LowStar.Monotonic.Buffer.length b / 16) * 16 /\
b_start ==
LowStar.Buffer.gsub b 0ul (FStar.UInt32.uint_to_t (LowStar.Monotonic.Buffer.length b_start)) /\
LowStar.Monotonic.Buffer.length b_extra = 16 /\
FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h b)
(FStar.Seq.Base.slice (FStar.Seq.Base.append (LowStar.Monotonic.Buffer.as_seq h b_start)
(LowStar.Monotonic.Buffer.as_seq h b_extra))
0
(LowStar.Monotonic.Buffer.length b)))
(ensures
(let b_start_d = Vale.Interop.Types.get_downview b_start in
[@@ FStar.Pervasives.inline_let ]let _ =
LowStar.BufferView.Down.length_eq (Vale.Interop.Types.get_downview b_start)
in
let b_start_u = LowStar.BufferView.Up.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = Vale.Interop.Types.get_downview b_extra in
[@@ FStar.Pervasives.inline_let ]let _ =
LowStar.BufferView.Down.length_eq (Vale.Interop.Types.get_downview b_extra)
in
let b_extra_u = LowStar.BufferView.Up.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv =
FStar.Seq.Base.append (LowStar.BufferView.Up.as_seq h b_start_u)
(LowStar.BufferView.Up.as_seq h b_extra_u)
in
let sf =
Vale.Wrapper.X64.GCM_IV.wrap_slice (Vale.Def.Types_s.le_seq_quad32_to_bytes suv)
(LowStar.Monotonic.Buffer.length b)
in
FStar.Seq.Base.equal sf
(Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (LowStar.Monotonic.Buffer.as_seq h b)))) | {
"end_col": 4,
"end_line": 183,
"start_col": 2,
"start_line": 137
} |
FStar.Pervasives.Lemma | val lemma_slice_sub (b b_sub b_extra: uint8_p) (h: HS.mem)
: Lemma
(requires
B.length b_extra = 16 /\ B.length b_sub = (B.length b / 16) * 16 /\
b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\
Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)))
(ensures
Seq.equal (B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))) | [
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Gcm_simplify",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.Simplify_Sha",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64.GCM_IV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_slice_sub (b:uint8_p) (b_sub:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires B.length b_extra = 16 /\ B.length b_sub = B.length b / 16 * 16 /\
b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\
Seq.equal
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))
)
(ensures Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))
) =
calc (==) {
Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b);
(==) { Seq.lemma_eq_intro
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))
(Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)))
}
Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16));
(==) { }
Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16));
(==) { }
Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b));
(==) { Seq.lemma_eq_intro (B.as_seq h b)
(Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b)))
}
B.as_seq h b;
} | val lemma_slice_sub (b b_sub b_extra: uint8_p) (h: HS.mem)
: Lemma
(requires
B.length b_extra = 16 /\ B.length b_sub = (B.length b / 16) * 16 /\
b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\
Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)))
(ensures
Seq.equal (B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)))
let lemma_slice_sub (b b_sub b_extra: uint8_p) (h: HS.mem)
: Lemma
(requires
B.length b_extra = 16 /\ B.length b_sub = (B.length b / 16) * 16 /\
b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\
Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)))
(ensures
Seq.equal (B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))) = | false | null | true | calc ( == ) {
Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b);
( == ) { Seq.lemma_eq_intro (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra))
0
(B.length b))
(Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))) }
Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16));
( == ) { () }
Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16));
( == ) { () }
Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b));
( == ) { Seq.lemma_eq_intro (B.as_seq h b)
(Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b))) }
B.as_seq h b;
} | {
"checked_file": "Vale.Wrapper.X64.GCM_IV.fst.checked",
"dependencies": [
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Stdcalls.X64.GCM_IV.fst.checked",
"Vale.SHA.Simplify_Sha.fsti.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.Gcm_simplify.fsti.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Integers.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Wrapper.X64.GCM_IV.fst"
} | [
"lemma"
] | [
"Vale.Wrapper.X64.GCM_IV.uint8_p",
"FStar.Monotonic.HyperStack.mem",
"FStar.Calc.calc_finish",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"Prims.eq2",
"FStar.Seq.Base.slice",
"FStar.Seq.Base.append",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.length",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Integers.op_Percent",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Seq.Base.lemma_eq_intro",
"Prims.squash",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Integers.op_Star",
"FStar.Integers.op_Slash",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.uint_to_t",
"FStar.Seq.Base.equal",
"FStar.Integers.op_Plus",
"FStar.Pervasives.pattern"
] | [] | module Vale.Wrapper.X64.GCM_IV
open FStar.Mul
open Vale.Stdcalls.X64.GCM_IV
open Vale.AsLowStar.MemoryHelpers
open Vale.X64.MemoryAdapters
module V = Vale.X64.Decls
open Vale.SHA.Simplify_Sha
open Vale.AES.Gcm_simplify
open Vale.AES.GCM_helpers
open Vale.Arch.Types
open Vale.AES.GHash
open FStar.Integers
open FStar.Int.Cast
let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a =
Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0)
let length_aux (b:uint8_p) (n:nat) : Lemma
(requires B.length b = 16 * n)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_mod n 16
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let length_aux5 (b:uint8_p) : Lemma
(requires B.length b = 128)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db
#push-options "--z3cliopt smt.arith.nl=true"
inline_for_extraction
val compute_iv_stdcall':
iv:Ghost.erased supported_iv_LE ->
iv_b:uint8_p ->
num_bytes:uint64 ->
len:uint64 ->
j0_b:uint8_p ->
iv_extra_b:uint8_p ->
hkeys_b:uint8_p ->
Stack unit
(requires fun h0 ->
B.disjoint iv_b j0_b /\ B.disjoint iv_b iv_extra_b /\ B.disjoint iv_b hkeys_b /\
(B.disjoint j0_b iv_extra_b \/ j0_b == iv_extra_b) /\
B.disjoint j0_b hkeys_b /\ B.disjoint iv_extra_b hkeys_b /\
B.live h0 iv_b /\ B.live h0 j0_b /\ B.live h0 iv_extra_b /\ B.live h0 hkeys_b /\
B.length iv_b == 16 * UInt64.v len /\
B.length j0_b == 16 /\
B.length iv_extra_b == 16 /\
B.length hkeys_b == 128 /\
UInt64.v len * (128/8) <= UInt64.v num_bytes /\
UInt64.v num_bytes < UInt64.v len * (128/8) + 128/8 /\
0 < 8 * UInt64.v num_bytes /\
8 * UInt64.v num_bytes < pow2_64 /\
pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\
( let db = get_downview hkeys_b in
length_aux5 hkeys_b; DV.length_eq (get_downview hkeys_b);
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32
(reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2)))) /\
( let in_d = get_downview iv_b in
length_aux iv_b (UInt64.v len);
let in_u = UV.mk_buffer in_d Vale.Interop.Views.up_view128 in
let inout_d = get_downview iv_extra_b in
length_aux iv_extra_b 1;
let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in
let iv_raw_quads = Seq.append (UV.as_seq h0 in_u) (UV.as_seq h0 inout_u) in
let iv_bytes_LE = wrap_slice (le_seq_quad32_to_bytes iv_raw_quads) (UInt64.v num_bytes) in
Seq.equal iv_bytes_LE (Ghost.reveal iv)
)
)
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer j0_b) h0 h1 /\
(DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview j0_b);
let h_LE = reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2) in
low_buffer_read TUInt8 TUInt128 h1 j0_b 0 == compute_iv_BE h_LE (Ghost.reveal iv))
)
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#set-options "--ext compat:normalizer_memo_ignore_cfg"
inline_for_extraction
let compute_iv_stdcall' iv iv_b num_bytes len j0_b iv_extra_b hkeys_b =
let h0 = get() in
DV.length_eq (get_downview iv_b);
DV.length_eq (get_downview iv_extra_b);
DV.length_eq (get_downview j0_b);
DV.length_eq (get_downview hkeys_b);
as_vale_buffer_len #TUInt8 #TUInt128 iv_b;
as_vale_buffer_len #TUInt8 #TUInt128 iv_extra_b;
as_vale_buffer_len #TUInt8 #TUInt128 j0_b;
as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b;
bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b;
bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b;
let (x, _) = compute_iv_stdcall iv iv_b num_bytes len j0_b iv_extra_b hkeys_b () in
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires
B.length b_start = B.length b / 16 * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\
B.length b_extra = 16 /\
Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))
)
(ensures (
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b))
))
=
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in
// if B.length b > B.length b_start then (
calc (==) {
sf;
(==) { DV.length_eq b_start_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(UV.as_seq h b_extra_u)))
(B.length b);
(==) { DV.length_eq b_extra_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
(==) { append_distributes_le_seq_quad32_to_bytes
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
}
wrap_slice (Seq.append
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))))
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
(==) { le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start));
le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)) }
wrap_slice (Seq.append
(seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b);
(==) { Seq.lemma_eq_intro b_f
(wrap_slice (Seq.append
(seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b))
}
b_f;
}
#pop-options
let lemma_slice_sub (b:uint8_p) (b_sub:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires B.length b_extra = 16 /\ B.length b_sub = B.length b / 16 * 16 /\
b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\
Seq.equal
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))
)
(ensures Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)) | false | false | Vale.Wrapper.X64.GCM_IV.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_slice_sub (b b_sub b_extra: uint8_p) (h: HS.mem)
: Lemma
(requires
B.length b_extra = 16 /\ B.length b_sub = (B.length b / 16) * 16 /\
b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\
Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)))
(ensures
Seq.equal (B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))) | [] | Vale.Wrapper.X64.GCM_IV.lemma_slice_sub | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCM_IV.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.Wrapper.X64.GCM_IV.uint8_p ->
b_sub: Vale.Wrapper.X64.GCM_IV.uint8_p ->
b_extra: Vale.Wrapper.X64.GCM_IV.uint8_p ->
h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
LowStar.Monotonic.Buffer.length b_extra = 16 /\
LowStar.Monotonic.Buffer.length b_sub = (LowStar.Monotonic.Buffer.length b / 16) * 16 /\
b_sub ==
LowStar.Buffer.gsub b 0ul (FStar.UInt32.uint_to_t (LowStar.Monotonic.Buffer.length b_sub)) /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice (LowStar.Monotonic.Buffer.as_seq h b)
(LowStar.Monotonic.Buffer.length b_sub)
(LowStar.Monotonic.Buffer.length b_sub + LowStar.Monotonic.Buffer.length b % 16))
(FStar.Seq.Base.slice (LowStar.Monotonic.Buffer.as_seq h b_extra)
0
(LowStar.Monotonic.Buffer.length b % 16)))
(ensures
FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h b)
(FStar.Seq.Base.slice (FStar.Seq.Base.append (LowStar.Monotonic.Buffer.as_seq h b_sub)
(LowStar.Monotonic.Buffer.as_seq h b_extra))
0
(LowStar.Monotonic.Buffer.length b))) | {
"end_col": 3,
"end_line": 218,
"start_col": 2,
"start_line": 197
} |
FStar.HyperStack.ST.Stack | val compute_iv
(a:algorithm)
(key:Ghost.erased (Seq.seq nat32))
(iv_b:uint8_p)
(num_bytes:UInt32.t)
(j0_b:uint8_p)
(extra_b:uint8_p)
(hkeys_b:uint8_p) : Stack unit
(requires fun h ->
B.live h iv_b /\ B.live h extra_b /\ B.live h hkeys_b /\ B.live h j0_b /\
B.length j0_b == 16 /\ B.length extra_b == 16 /\
B.length hkeys_b == 128 /\ B.length iv_b == UInt32.v num_bytes /\
UInt32.v num_bytes > 0 /\
B.disjoint iv_b j0_b /\ B.disjoint iv_b extra_b /\ B.disjoint iv_b hkeys_b /\
(B.disjoint j0_b extra_b \/ j0_b == extra_b) /\
B.disjoint j0_b hkeys_b /\ B.disjoint hkeys_b extra_b /\
pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\
is_aes_key_LE a (Ghost.reveal key) /\
hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h hkeys_b)))
(reverse_bytes_quad32 (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0)))
)
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer j0_b `B.loc_union` B.loc_buffer extra_b) h0 h1 /\
le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 j0_b)) ==
compute_iv_BE (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0))
(seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) | [
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Gcm_simplify",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.Simplify_Sha",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64.GCM_IV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_iv a key full_iv_b num_bytes j0_b extra_b hkeys_b =
let h0 = get() in
let len = num_bytes / 16ul in
let bytes_len = len * 16ul in
let iv_b = B.sub full_iv_b 0ul bytes_len in
B.blit full_iv_b bytes_len extra_b 0ul (num_bytes % 16ul);
let h1 = get() in
lemma_slice_sub full_iv_b iv_b extra_b h1;
lemma_slice_uv_extra full_iv_b iv_b extra_b h1;
DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview j0_b);
lemma_same_seq_same_buffer_read h0 h1 hkeys_b;
let aux () : Lemma
(aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0) ==
reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2))
= let keys_quad = le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b)) in
let h_BE = low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2 in
lemma_hkeys_reqs_pub_priv
keys_quad
(reverse_bytes_quad32 (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0)));
let db = get_downview hkeys_b in
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
calc (==) {
le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b));
(==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h0 }
le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub))));
(==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) }
UV.as_seq h0 ub;
};
UV.as_seq_sel h0 ub 2;
reveal_reverse_bytes_quad32 h_BE;
reveal_reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)
in aux();
let lemma_uv_key () : Lemma
(let db = get_downview hkeys_b in
length_aux5 hkeys_b;
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
Seq.length (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 hkeys_b))) == 8 /\
Seq.equal (UV.as_seq h1 ub) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 hkeys_b))))
= length_aux5 hkeys_b;
let db = get_downview hkeys_b in
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
DV.length_eq db;
UV.length_eq ub;
calc (==) {
le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 hkeys_b));
(==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h1 }
le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h1 ub))));
(==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h1 ub) }
UV.as_seq h1 ub;
}
in lemma_uv_key ();
compute_iv_stdcall' (Ghost.hide (seq_uint8_to_seq_nat8 (B.as_seq h0 full_iv_b)))
iv_b (uint32_to_uint64 num_bytes) (uint32_to_uint64 len)
j0_b extra_b hkeys_b;
let h2 = get() in
gcm_simplify2 j0_b h2;
le_bytes_to_quad32_to_bytes (compute_iv_BE (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0))
(seq_uint8_to_seq_nat8 (B.as_seq h0 full_iv_b))) | val compute_iv
(a:algorithm)
(key:Ghost.erased (Seq.seq nat32))
(iv_b:uint8_p)
(num_bytes:UInt32.t)
(j0_b:uint8_p)
(extra_b:uint8_p)
(hkeys_b:uint8_p) : Stack unit
(requires fun h ->
B.live h iv_b /\ B.live h extra_b /\ B.live h hkeys_b /\ B.live h j0_b /\
B.length j0_b == 16 /\ B.length extra_b == 16 /\
B.length hkeys_b == 128 /\ B.length iv_b == UInt32.v num_bytes /\
UInt32.v num_bytes > 0 /\
B.disjoint iv_b j0_b /\ B.disjoint iv_b extra_b /\ B.disjoint iv_b hkeys_b /\
(B.disjoint j0_b extra_b \/ j0_b == extra_b) /\
B.disjoint j0_b hkeys_b /\ B.disjoint hkeys_b extra_b /\
pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\
is_aes_key_LE a (Ghost.reveal key) /\
hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h hkeys_b)))
(reverse_bytes_quad32 (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0)))
)
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer j0_b `B.loc_union` B.loc_buffer extra_b) h0 h1 /\
le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 j0_b)) ==
compute_iv_BE (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0))
(seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b)))
let compute_iv a key full_iv_b num_bytes j0_b extra_b hkeys_b = | true | null | false | let h0 = get () in
let len = num_bytes / 16ul in
let bytes_len = len * 16ul in
let iv_b = B.sub full_iv_b 0ul bytes_len in
B.blit full_iv_b bytes_len extra_b 0ul (num_bytes % 16ul);
let h1 = get () in
lemma_slice_sub full_iv_b iv_b extra_b h1;
lemma_slice_uv_extra full_iv_b iv_b extra_b h1;
DV.length_eq (get_downview hkeys_b);
DV.length_eq (get_downview j0_b);
lemma_same_seq_same_buffer_read h0 h1 hkeys_b;
let aux ()
: Lemma
(aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0) ==
reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2)) =
let keys_quad = le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b)) in
let h_BE = low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2 in
lemma_hkeys_reqs_pub_priv keys_quad
(reverse_bytes_quad32 (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0)));
let db = get_downview hkeys_b in
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
calc ( == ) {
le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b));
( == ) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h0 }
le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq
h0
ub))));
( == ) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) }
UV.as_seq h0 ub;
};
UV.as_seq_sel h0 ub 2;
reveal_reverse_bytes_quad32 h_BE;
reveal_reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)
in
aux ();
let lemma_uv_key ()
: Lemma
(let db = get_downview hkeys_b in
length_aux5 hkeys_b;
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
Seq.length (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 hkeys_b))) == 8 /\
Seq.equal (UV.as_seq h1 ub)
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 hkeys_b)))) =
length_aux5 hkeys_b;
let db = get_downview hkeys_b in
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
DV.length_eq db;
UV.length_eq ub;
calc ( == ) {
le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 hkeys_b));
( == ) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h1 }
le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq
h1
ub))));
( == ) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h1 ub) }
UV.as_seq h1 ub;
}
in
lemma_uv_key ();
compute_iv_stdcall' (Ghost.hide (seq_uint8_to_seq_nat8 (B.as_seq h0 full_iv_b)))
iv_b
(uint32_to_uint64 num_bytes)
(uint32_to_uint64 len)
j0_b
extra_b
hkeys_b;
let h2 = get () in
gcm_simplify2 j0_b h2;
le_bytes_to_quad32_to_bytes (compute_iv_BE (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0))
(seq_uint8_to_seq_nat8 (B.as_seq h0 full_iv_b))) | {
"checked_file": "Vale.Wrapper.X64.GCM_IV.fst.checked",
"dependencies": [
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Stdcalls.X64.GCM_IV.fst.checked",
"Vale.SHA.Simplify_Sha.fsti.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.Gcm_simplify.fsti.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Integers.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Wrapper.X64.GCM_IV.fst"
} | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Wrapper.X64.GCM_IV.uint8_p",
"FStar.UInt32.t",
"Vale.Arch.Types.le_bytes_to_quad32_to_bytes",
"Vale.AES.GCM_s.compute_iv_BE",
"Vale.AES.AES_s.aes_encrypt_LE",
"FStar.Ghost.reveal",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.UInt8.t",
"LowStar.Buffer.trivial_preorder",
"Prims.unit",
"Vale.AES.Gcm_simplify.gcm_simplify2",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Vale.Wrapper.X64.GCM_IV.compute_iv_stdcall'",
"FStar.Ghost.hide",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Int.Cast.uint32_to_uint64",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"FStar.Seq.Base.equal",
"LowStar.BufferView.Up.as_seq",
"LowStar.BufferView.Up.mk_buffer",
"Vale.Interop.Types.get_downview",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Interop.Views.up_view128",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"FStar.Calc.calc_step",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Vale.SHA.Simplify_Sha.lemma_seq_nat8_le_seq_quad32_to_bytes_uint32",
"Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes",
"LowStar.BufferView.Up.length_eq",
"LowStar.BufferView.Down.length_eq",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Down.buffer",
"Vale.Wrapper.X64.GCM_IV.length_aux5",
"Vale.Def.Words_s.nat32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AsLowStar.MemoryHelpers.low_buffer_read",
"Vale.Arch.HeapTypes_s.TUInt128",
"Vale.Def.Types_s.reveal_reverse_bytes_quad32",
"LowStar.BufferView.Up.as_seq_sel",
"Vale.AES.GHash.lemma_hkeys_reqs_pub_priv",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Wrapper.X64.GCM_IV.lemma_same_seq_same_buffer_read",
"Vale.Wrapper.X64.GCM_IV.lemma_slice_uv_extra",
"Vale.Wrapper.X64.GCM_IV.lemma_slice_sub",
"LowStar.Monotonic.Buffer.blit",
"FStar.UInt32.__uint_to_t",
"FStar.Integers.op_Percent",
"FStar.Integers.Unsigned",
"FStar.Integers.W32",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.sub",
"FStar.Integers.int_t",
"FStar.Integers.op_Star",
"FStar.Integers.op_Slash"
] | [] | module Vale.Wrapper.X64.GCM_IV
open FStar.Mul
open Vale.Stdcalls.X64.GCM_IV
open Vale.AsLowStar.MemoryHelpers
open Vale.X64.MemoryAdapters
module V = Vale.X64.Decls
open Vale.SHA.Simplify_Sha
open Vale.AES.Gcm_simplify
open Vale.AES.GCM_helpers
open Vale.Arch.Types
open Vale.AES.GHash
open FStar.Integers
open FStar.Int.Cast
let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a =
Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0)
let length_aux (b:uint8_p) (n:nat) : Lemma
(requires B.length b = 16 * n)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db;
FStar.Math.Lemmas.cancel_mul_mod n 16
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let length_aux5 (b:uint8_p) : Lemma
(requires B.length b = 128)
(ensures DV.length (get_downview b) % 16 = 0) =
let db = get_downview b in
DV.length_eq db
#push-options "--z3cliopt smt.arith.nl=true"
inline_for_extraction
val compute_iv_stdcall':
iv:Ghost.erased supported_iv_LE ->
iv_b:uint8_p ->
num_bytes:uint64 ->
len:uint64 ->
j0_b:uint8_p ->
iv_extra_b:uint8_p ->
hkeys_b:uint8_p ->
Stack unit
(requires fun h0 ->
B.disjoint iv_b j0_b /\ B.disjoint iv_b iv_extra_b /\ B.disjoint iv_b hkeys_b /\
(B.disjoint j0_b iv_extra_b \/ j0_b == iv_extra_b) /\
B.disjoint j0_b hkeys_b /\ B.disjoint iv_extra_b hkeys_b /\
B.live h0 iv_b /\ B.live h0 j0_b /\ B.live h0 iv_extra_b /\ B.live h0 hkeys_b /\
B.length iv_b == 16 * UInt64.v len /\
B.length j0_b == 16 /\
B.length iv_extra_b == 16 /\
B.length hkeys_b == 128 /\
UInt64.v len * (128/8) <= UInt64.v num_bytes /\
UInt64.v num_bytes < UInt64.v len * (128/8) + 128/8 /\
0 < 8 * UInt64.v num_bytes /\
8 * UInt64.v num_bytes < pow2_64 /\
pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\
( let db = get_downview hkeys_b in
length_aux5 hkeys_b; DV.length_eq (get_downview hkeys_b);
let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in
hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32
(reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2)))) /\
( let in_d = get_downview iv_b in
length_aux iv_b (UInt64.v len);
let in_u = UV.mk_buffer in_d Vale.Interop.Views.up_view128 in
let inout_d = get_downview iv_extra_b in
length_aux iv_extra_b 1;
let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in
let iv_raw_quads = Seq.append (UV.as_seq h0 in_u) (UV.as_seq h0 inout_u) in
let iv_bytes_LE = wrap_slice (le_seq_quad32_to_bytes iv_raw_quads) (UInt64.v num_bytes) in
Seq.equal iv_bytes_LE (Ghost.reveal iv)
)
)
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer j0_b) h0 h1 /\
(DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview j0_b);
let h_LE = reverse_bytes_quad32 (low_buffer_read TUInt8 TUInt128 h0 hkeys_b 2) in
low_buffer_read TUInt8 TUInt128 h1 j0_b 0 == compute_iv_BE h_LE (Ghost.reveal iv))
)
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
#set-options "--ext compat:normalizer_memo_ignore_cfg"
inline_for_extraction
let compute_iv_stdcall' iv iv_b num_bytes len j0_b iv_extra_b hkeys_b =
let h0 = get() in
DV.length_eq (get_downview iv_b);
DV.length_eq (get_downview iv_extra_b);
DV.length_eq (get_downview j0_b);
DV.length_eq (get_downview hkeys_b);
as_vale_buffer_len #TUInt8 #TUInt128 iv_b;
as_vale_buffer_len #TUInt8 #TUInt128 iv_extra_b;
as_vale_buffer_len #TUInt8 #TUInt128 j0_b;
as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b;
bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b;
bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b;
let (x, _) = compute_iv_stdcall iv iv_b num_bytes len j0_b iv_extra_b hkeys_b () in
()
#pop-options
#push-options "--z3cliopt smt.arith.nl=true"
let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires
B.length b_start = B.length b / 16 * 16 /\
b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\
B.length b_extra = 16 /\
Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))
)
(ensures (
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b))
))
=
let b_start_d = get_downview b_start in
DV.length_eq (get_downview b_start);
let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in
let b_extra_d = get_downview b_extra in
DV.length_eq (get_downview b_extra);
let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in
let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in
let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in
let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in
// if B.length b > B.length b_start then (
calc (==) {
sf;
(==) { DV.length_eq b_start_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(UV.as_seq h b_extra_u)))
(B.length b);
(==) { DV.length_eq b_extra_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h;
le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u) }
wrap_slice (le_seq_quad32_to_bytes (Seq.append
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
(==) { append_distributes_le_seq_quad32_to_bytes
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))
(le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
}
wrap_slice (Seq.append
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))))
(le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))))
(B.length b);
(==) { le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start));
le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)) }
wrap_slice (Seq.append
(seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b);
(==) { Seq.lemma_eq_intro b_f
(wrap_slice (Seq.append
(seq_uint8_to_seq_nat8 (B.as_seq h b_start))
(seq_uint8_to_seq_nat8 (B.as_seq h b_extra)))
(B.length b))
}
b_f;
}
#pop-options
let lemma_slice_sub (b:uint8_p) (b_sub:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma
(requires B.length b_extra = 16 /\ B.length b_sub = B.length b / 16 * 16 /\
b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\
Seq.equal
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))
)
(ensures Seq.equal
(B.as_seq h b)
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))
) =
calc (==) {
Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b);
(==) { Seq.lemma_eq_intro
(Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))
(Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)))
}
Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16));
(==) { }
Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16));
(==) { }
Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b));
(==) { Seq.lemma_eq_intro (B.as_seq h b)
(Seq.append
(Seq.slice (B.as_seq h b) 0 (B.length b_sub))
(Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b)))
}
B.as_seq h b;
}
open Vale.Lib.BufferViewHelpers
#push-options "--smtencoding.nl_arith_repr boxwrap"
let lemma_same_seq_same_buffer_read (h0 h1:HS.mem) (b:uint8_p) : Lemma
(requires
B.live h0 b /\ B.live h1 b /\
B.length b == 128 /\ B.as_seq h0 b `Seq.equal` B.as_seq h1 b)
(ensures (
DV.length_eq (get_downview b);
low_buffer_read TUInt8 TUInt128 h0 b 2 == low_buffer_read TUInt8 TUInt128 h1 b 2)
)
=
let b_d = get_downview b in
DV.length_eq b_d;
let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in
lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1;
lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1;
UV.length_eq b_u;
UV.as_seq_sel h0 b_u 2;
UV.as_seq_sel h1 b_u 2
#pop-options | false | false | Vale.Wrapper.X64.GCM_IV.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_iv
(a:algorithm)
(key:Ghost.erased (Seq.seq nat32))
(iv_b:uint8_p)
(num_bytes:UInt32.t)
(j0_b:uint8_p)
(extra_b:uint8_p)
(hkeys_b:uint8_p) : Stack unit
(requires fun h ->
B.live h iv_b /\ B.live h extra_b /\ B.live h hkeys_b /\ B.live h j0_b /\
B.length j0_b == 16 /\ B.length extra_b == 16 /\
B.length hkeys_b == 128 /\ B.length iv_b == UInt32.v num_bytes /\
UInt32.v num_bytes > 0 /\
B.disjoint iv_b j0_b /\ B.disjoint iv_b extra_b /\ B.disjoint iv_b hkeys_b /\
(B.disjoint j0_b extra_b \/ j0_b == extra_b) /\
B.disjoint j0_b hkeys_b /\ B.disjoint hkeys_b extra_b /\
pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\
is_aes_key_LE a (Ghost.reveal key) /\
hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h hkeys_b)))
(reverse_bytes_quad32 (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0)))
)
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer j0_b `B.loc_union` B.loc_buffer extra_b) h0 h1 /\
le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h1 j0_b)) ==
compute_iv_BE (aes_encrypt_LE a (Ghost.reveal key) (Mkfour 0 0 0 0))
(seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) | [] | Vale.Wrapper.X64.GCM_IV.compute_iv | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCM_IV.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Vale.AES.AES_common_s.algorithm ->
key: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) ->
iv_b: Vale.Wrapper.X64.GCM_IV.uint8_p ->
num_bytes: FStar.UInt32.t ->
j0_b: Vale.Wrapper.X64.GCM_IV.uint8_p ->
extra_b: Vale.Wrapper.X64.GCM_IV.uint8_p ->
hkeys_b: Vale.Wrapper.X64.GCM_IV.uint8_p
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 52,
"end_line": 318,
"start_col": 63,
"start_line": 244
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let proj_point = felem & felem & felem | let proj_point = | false | null | false | felem & felem & felem | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple3",
"Spec.K256.PointOps.felem"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val proj_point : Type0 | [] | Spec.K256.PointOps.proj_point | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 38,
"end_line": 56,
"start_col": 17,
"start_line": 56
} |
|
Prims.Tot | val scalar_is_high (x: qelem) : bool | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let scalar_is_high (x:qelem) : bool = x > q / 2 | val scalar_is_high (x: qelem) : bool
let scalar_is_high (x: qelem) : bool = | false | null | false | x > q / 2 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.qelem",
"Prims.op_GreaterThan",
"Prims.op_Division",
"Spec.K256.PointOps.q",
"Prims.bool"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2) | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val scalar_is_high (x: qelem) : bool | [] | Spec.K256.PointOps.scalar_is_high | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.qelem -> Prims.bool | {
"end_col": 47,
"end_line": 48,
"start_col": 38,
"start_line": 48
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point = felem & felem | let aff_point = | false | null | false | felem & felem | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Spec.K256.PointOps.felem"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point : Type0 | [] | Spec.K256.PointOps.aff_point | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 29,
"end_line": 55,
"start_col": 16,
"start_line": 55
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let felem = x:nat{x < prime} | let felem = | false | null | false | x: nat{x < prime} | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.K256.PointOps.prime"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val felem : Type0 | [] | Spec.K256.PointOps.felem | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 28,
"end_line": 20,
"start_col": 12,
"start_line": 20
} |
|
Prims.Tot | val aff_point_at_inf:aff_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_at_inf : aff_point = (zero, zero) | val aff_point_at_inf:aff_point
let aff_point_at_inf:aff_point = | false | null | false | (zero, zero) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.Mktuple2",
"Spec.K256.PointOps.felem",
"Spec.K256.PointOps.zero"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_at_inf:aff_point | [] | Spec.K256.PointOps.aff_point_at_inf | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.K256.PointOps.aff_point | {
"end_col": 47,
"end_line": 64,
"start_col": 35,
"start_line": 64
} |
Prims.Tot | val is_fodd (x: nat) : bool | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_fodd (x:nat) : bool = x % 2 = 1 | val is_fodd (x: nat) : bool
let is_fodd (x: nat) : bool = | false | null | false | x % 2 = 1 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Prims.bool"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2) | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_fodd (x: nat) : bool | [] | Spec.K256.PointOps.is_fodd | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Prims.nat -> Prims.bool | {
"end_col": 38,
"end_line": 29,
"start_col": 29,
"start_line": 29
} |
Prims.Tot | val to_aff_point (p: proj_point) : aff_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y) | val to_aff_point (p: proj_point) : aff_point
let to_aff_point (p: proj_point) : aff_point = | false | null | false | let px, py, pz = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.felem",
"FStar.Pervasives.Native.Mktuple2",
"Spec.K256.PointOps.op_Star_Percent",
"Spec.K256.PointOps.finv",
"Spec.K256.PointOps.aff_point"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val to_aff_point (p: proj_point) : aff_point | [] | Spec.K256.PointOps.to_aff_point | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.proj_point -> Spec.K256.PointOps.aff_point | {
"end_col": 8,
"end_line": 79,
"start_col": 45,
"start_line": 73
} |
Prims.Tot | val to_proj_point (p: aff_point) : proj_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one) | val to_proj_point (p: aff_point) : proj_point
let to_proj_point (p: aff_point) : proj_point = | false | null | false | let x, y = p in
(x, y, one) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.aff_point",
"Spec.K256.PointOps.felem",
"FStar.Pervasives.Native.Mktuple3",
"Spec.K256.PointOps.one",
"Spec.K256.PointOps.proj_point"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y) | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val to_proj_point (p: aff_point) : proj_point | [] | Spec.K256.PointOps.to_proj_point | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.aff_point -> Spec.K256.PointOps.proj_point | {
"end_col": 31,
"end_line": 82,
"start_col": 46,
"start_line": 81
} |
Prims.Tot | val g:proj_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g : proj_point = (g_x, g_y, one) | val g:proj_point
let g:proj_point = | false | null | false | (g_x, g_y, one) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.Mktuple3",
"Spec.K256.PointOps.felem",
"Spec.K256.PointOps.g_x",
"Spec.K256.PointOps.g_y",
"Spec.K256.PointOps.one"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val g:proj_point | [] | Spec.K256.PointOps.g | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.K256.PointOps.proj_point | {
"end_col": 36,
"end_line": 87,
"start_col": 21,
"start_line": 87
} |
Prims.Tot | val q:q: pos{q < pow2 256} | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 | val q:q: pos{q < pow2 256}
let q:q: pos{q < pow2 256} = | false | null | false | assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val q:q: pos{q < pow2 256} | [] | Spec.K256.PointOps.q | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q: Prims.pos{q < Prims.pow2 256} | {
"end_col": 68,
"end_line": 41,
"start_col": 2,
"start_line": 40
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( /% ) (x y:felem) = x *% finv y | let op_Slash_Percent (x y: felem) = | false | null | false | x *% finv y | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.felem",
"Spec.K256.PointOps.op_Star_Percent",
"Spec.K256.PointOps.finv"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Slash_Percent : x: Spec.K256.PointOps.felem -> y: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem | [] | Spec.K256.PointOps.op_Slash_Percent | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.felem -> y: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem | {
"end_col": 36,
"end_line": 34,
"start_col": 25,
"start_line": 34
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qelem = x:nat{x < q} | let qelem = | false | null | false | x: nat{x < q} | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.K256.PointOps.q"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qelem : Type0 | [] | Spec.K256.PointOps.qelem | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 24,
"end_line": 43,
"start_col": 12,
"start_line": 43
} |
|
Prims.Tot | val point_at_inf:proj_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_at_inf : proj_point = (zero, one, zero) | val point_at_inf:proj_point
let point_at_inf:proj_point = | false | null | false | (zero, one, zero) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.Mktuple3",
"Spec.K256.PointOps.felem",
"Spec.K256.PointOps.zero",
"Spec.K256.PointOps.one"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_at_inf:proj_point | [] | Spec.K256.PointOps.point_at_inf | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.K256.PointOps.proj_point | {
"end_col": 49,
"end_line": 65,
"start_col": 32,
"start_line": 65
} |
Prims.Tot | val finv (x: felem) : felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2) | val finv (x: felem) : felem
let finv (x: felem) : felem = | false | null | false | M.pow_mod #prime x (prime - 2) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.felem",
"Lib.NatMod.pow_mod",
"Spec.K256.PointOps.prime",
"Prims.op_Subtraction"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finv (x: felem) : felem | [] | Spec.K256.PointOps.finv | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem | {
"end_col": 59,
"end_line": 27,
"start_col": 29,
"start_line": 27
} |
Prims.Tot | val one:felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let one : felem = 1 | val one:felem
let one:felem = | false | null | false | 1 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime} | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val one:felem | [] | Spec.K256.PointOps.one | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.K256.PointOps.felem | {
"end_col": 20,
"end_line": 22,
"start_col": 19,
"start_line": 22
} |
Prims.Tot | val is_aff_point_at_inf (p: aff_point) : bool | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero | val is_aff_point_at_inf (p: aff_point) : bool
let is_aff_point_at_inf (p: aff_point) : bool = | false | null | false | let x, y = p in
x = zero && y = zero | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.aff_point",
"Spec.K256.PointOps.felem",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"Spec.K256.PointOps.zero",
"Prims.bool"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero) | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_aff_point_at_inf (p: aff_point) : bool | [] | Spec.K256.PointOps.is_aff_point_at_inf | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.aff_point -> Prims.bool | {
"end_col": 40,
"end_line": 68,
"start_col": 46,
"start_line": 67
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b | let is_on_curve (p: aff_point) = | false | null | false | let x, y = p in
y *% y = x *% x *% x +% b | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.aff_point",
"Spec.K256.PointOps.felem",
"Prims.op_Equality",
"Spec.K256.PointOps.op_Star_Percent",
"Spec.K256.PointOps.op_Plus_Percent",
"Spec.K256.PointOps.b",
"Prims.bool"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_on_curve : p: Spec.K256.PointOps.aff_point -> Prims.bool | [] | Spec.K256.PointOps.is_on_curve | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.aff_point -> Prims.bool | {
"end_col": 43,
"end_line": 62,
"start_col": 31,
"start_line": 61
} |
|
Prims.Tot | val g_y:felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 | val g_y:felem
let g_y:felem = | false | null | false | 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val g_y:felem | [] | Spec.K256.PointOps.g_y | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.K256.PointOps.felem | {
"end_col": 84,
"end_line": 86,
"start_col": 18,
"start_line": 86
} |
Prims.Tot | val g_x:felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 | val g_x:felem
let g_x:felem = | false | null | false | 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one) | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val g_x:felem | [] | Spec.K256.PointOps.g_x | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.K256.PointOps.felem | {
"end_col": 84,
"end_line": 85,
"start_col": 18,
"start_line": 85
} |
Prims.Tot | val fadd (x y: felem) : felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fadd (x y:felem) : felem = (x + y) % prime | val fadd (x y: felem) : felem
let fadd (x y: felem) : felem = | false | null | false | (x + y) % prime | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.felem",
"Prims.op_Modulus",
"Prims.op_Addition",
"Spec.K256.PointOps.prime"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fadd (x y: felem) : felem | [] | Spec.K256.PointOps.fadd | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.felem -> y: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem | {
"end_col": 46,
"end_line": 24,
"start_col": 31,
"start_line": 24
} |
Prims.Tot | val aff_point_double (p: aff_point) : aff_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end | val aff_point_double (p: aff_point) : aff_point
let aff_point_double (p: aff_point) : aff_point = | false | null | false | let px, py = p in
if is_aff_point_at_inf p
then p
else
if py = 0
then aff_point_at_inf
else
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.aff_point",
"Spec.K256.PointOps.felem",
"Spec.K256.PointOps.is_aff_point_at_inf",
"Prims.bool",
"Prims.op_Equality",
"Prims.int",
"Spec.K256.PointOps.aff_point_at_inf",
"FStar.Pervasives.Native.Mktuple2",
"Spec.K256.PointOps.op_Subtraction_Percent",
"Spec.K256.PointOps.op_Star_Percent",
"Spec.K256.PointOps.op_Slash_Percent"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_double (p: aff_point) : aff_point | [] | Spec.K256.PointOps.aff_point_double | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.aff_point -> Spec.K256.PointOps.aff_point | {
"end_col": 5,
"end_line": 101,
"start_col": 48,
"start_line": 91
} |
Prims.Tot | val qnegate (x: qelem) : qelem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qnegate (x:qelem) : qelem = (- x) % q | val qnegate (x: qelem) : qelem
let qnegate (x: qelem) : qelem = | false | null | false | (- x) % q | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.qelem",
"Prims.op_Modulus",
"Prims.op_Minus",
"Spec.K256.PointOps.q"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qnegate (x: qelem) : qelem | [] | Spec.K256.PointOps.qnegate | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.qelem -> Spec.K256.PointOps.qelem | {
"end_col": 41,
"end_line": 47,
"start_col": 32,
"start_line": 47
} |
Prims.Tot | val qadd (x y: qelem) : qelem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qadd (x y:qelem) : qelem = (x + y) % q | val qadd (x y: qelem) : qelem
let qadd (x y: qelem) : qelem = | false | null | false | (x + y) % q | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.qelem",
"Prims.op_Modulus",
"Prims.op_Addition",
"Spec.K256.PointOps.q"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qadd (x y: qelem) : qelem | [] | Spec.K256.PointOps.qadd | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.qelem -> y: Spec.K256.PointOps.qelem -> Spec.K256.PointOps.qelem | {
"end_col": 42,
"end_line": 44,
"start_col": 31,
"start_line": 44
} |
Prims.Tot | val recover_y (x: felem) (is_odd: bool) : option felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let recover_y (x:felem) (is_odd:bool) : option felem =
let y2 = x *% x *% x +% b in
let y = fsqrt y2 in
if y *% y <> y2 then None
else begin
let y = if is_fodd y <> is_odd then (prime - y) % prime else y in
Some y end | val recover_y (x: felem) (is_odd: bool) : option felem
let recover_y (x: felem) (is_odd: bool) : option felem = | false | null | false | let y2 = x *% x *% x +% b in
let y = fsqrt y2 in
if y *% y <> y2
then None
else
let y = if is_fodd y <> is_odd then (prime - y) % prime else y in
Some y | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.felem",
"Prims.bool",
"Prims.op_disEquality",
"Spec.K256.PointOps.op_Star_Percent",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"Spec.K256.PointOps.is_fodd",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Spec.K256.PointOps.prime",
"FStar.Pervasives.Native.option",
"Spec.K256.PointOps.fsqrt",
"Spec.K256.PointOps.op_Plus_Percent",
"Spec.K256.PointOps.b"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3
let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
let point_inv_bytes (b:BSeq.lbytes 64) =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
px < prime && py < prime && is_on_curve (px, py)
let load_point_nocheck (b:BSeq.lbytes 64{point_inv_bytes b}) : proj_point =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
to_proj_point (px, py)
let aff_point_store (p:aff_point) : BSeq.lbytes 64 =
let (px, py) = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy
let point_store (p:proj_point) : BSeq.lbytes 64 =
aff_point_store (to_aff_point p) | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val recover_y (x: felem) (is_odd: bool) : option felem | [] | Spec.K256.PointOps.recover_y | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.felem -> is_odd: Prims.bool
-> FStar.Pervasives.Native.option Spec.K256.PointOps.felem | {
"end_col": 14,
"end_line": 212,
"start_col": 54,
"start_line": 206
} |
Prims.Tot | val fsqrt (x: felem) : felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4) | val fsqrt (x: felem) : felem
let fsqrt (x: felem) : felem = | false | null | false | M.pow_mod #prime x ((prime + 1) / 4) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.felem",
"Lib.NatMod.pow_mod",
"Spec.K256.PointOps.prime",
"Prims.op_Division",
"Prims.op_Addition"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fsqrt (x: felem) : felem | [] | Spec.K256.PointOps.fsqrt | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem | {
"end_col": 66,
"end_line": 28,
"start_col": 30,
"start_line": 28
} |
Prims.Tot | val aff_point_add (p q: aff_point) : aff_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end | val aff_point_add (p q: aff_point) : aff_point
let aff_point_add (p q: aff_point) : aff_point = | false | null | false | let px, py = p in
let qx, qy = q in
if is_aff_point_at_inf p
then q
else
if is_aff_point_at_inf q
then p
else
if p = q
then aff_point_double p
else
if qx = px
then aff_point_at_inf
else
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.aff_point",
"Spec.K256.PointOps.felem",
"Spec.K256.PointOps.is_aff_point_at_inf",
"Prims.bool",
"Prims.op_Equality",
"Spec.K256.PointOps.aff_point_double",
"Spec.K256.PointOps.aff_point_at_inf",
"FStar.Pervasives.Native.Mktuple2",
"Spec.K256.PointOps.op_Subtraction_Percent",
"Spec.K256.PointOps.op_Star_Percent",
"Spec.K256.PointOps.op_Slash_Percent"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_add (p q: aff_point) : aff_point | [] | Spec.K256.PointOps.aff_point_add | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.aff_point -> q: Spec.K256.PointOps.aff_point -> Spec.K256.PointOps.aff_point | {
"end_col": 5,
"end_line": 120,
"start_col": 59,
"start_line": 103
} |
Prims.Tot | val fsub (x y: felem) : felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fsub (x y:felem) : felem = (x - y) % prime | val fsub (x y: felem) : felem
let fsub (x y: felem) : felem = | false | null | false | (x - y) % prime | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.felem",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Spec.K256.PointOps.prime"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fsub (x y: felem) : felem | [] | Spec.K256.PointOps.fsub | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.felem -> y: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem | {
"end_col": 46,
"end_line": 25,
"start_col": 31,
"start_line": 25
} |
Prims.Tot | val b:felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let b : felem = 7 | val b:felem
let b:felem = | false | null | false | 7 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val b:felem | [] | Spec.K256.PointOps.b | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.K256.PointOps.felem | {
"end_col": 17,
"end_line": 59,
"start_col": 16,
"start_line": 59
} |
Prims.Tot | val point_add (p q: proj_point) : proj_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3 | val point_add (p q: proj_point) : proj_point
let point_add (p q: proj_point) : proj_point = | false | null | false | let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.felem",
"FStar.Pervasives.Native.Mktuple3",
"Spec.K256.PointOps.op_Plus_Percent",
"Spec.K256.PointOps.op_Star_Percent",
"Spec.K256.PointOps.op_Subtraction_Percent",
"Spec.K256.PointOps.b"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_add (p q: proj_point) : proj_point | [] | Spec.K256.PointOps.point_add | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.proj_point -> q: Spec.K256.PointOps.proj_point
-> Spec.K256.PointOps.proj_point | {
"end_col": 12,
"end_line": 146,
"start_col": 58,
"start_line": 128
} |
Prims.Tot | val fmul (x y: felem) : felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fmul (x y:felem) : felem = (x * y) % prime | val fmul (x y: felem) : felem
let fmul (x y: felem) : felem = | false | null | false | (x * y) % prime | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.felem",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Spec.K256.PointOps.prime"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul (x y: felem) : felem | [] | Spec.K256.PointOps.fmul | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.felem -> y: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem | {
"end_col": 46,
"end_line": 26,
"start_col": 31,
"start_line": 26
} |
Prims.Tot | val aff_point_negate (p: aff_point) : aff_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime | val aff_point_negate (p: aff_point) : aff_point
let aff_point_negate (p: aff_point) : aff_point = | false | null | false | let x, y = p in
x, (- y) % prime | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.aff_point",
"Spec.K256.PointOps.felem",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Modulus",
"Prims.op_Minus",
"Spec.K256.PointOps.prime"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_negate (p: aff_point) : aff_point | [] | Spec.K256.PointOps.aff_point_negate | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.aff_point -> Spec.K256.PointOps.aff_point | {
"end_col": 33,
"end_line": 123,
"start_col": 48,
"start_line": 122
} |
Prims.Tot | val qmul (x y: qelem) : qelem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qmul (x y:qelem) : qelem = (x * y) % q | val qmul (x y: qelem) : qelem
let qmul (x y: qelem) : qelem = | false | null | false | (x * y) % q | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.qelem",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Spec.K256.PointOps.q"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q} | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qmul (x y: qelem) : qelem | [] | Spec.K256.PointOps.qmul | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.qelem -> y: Spec.K256.PointOps.qelem -> Spec.K256.PointOps.qelem | {
"end_col": 42,
"end_line": 45,
"start_col": 31,
"start_line": 45
} |
Prims.Tot | val zero:felem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let zero : felem = 0 | val zero:felem
let zero:felem = | false | null | false | 0 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val zero:felem | [] | Spec.K256.PointOps.zero | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.K256.PointOps.felem | {
"end_col": 20,
"end_line": 21,
"start_col": 19,
"start_line": 21
} |
Prims.Tot | val point_negate (p: proj_point) : proj_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z | val point_negate (p: proj_point) : proj_point
let point_negate (p: proj_point) : proj_point = | false | null | false | let x, y, z = p in
x, (- y) % prime, z | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.felem",
"FStar.Pervasives.Native.Mktuple3",
"Prims.op_Modulus",
"Prims.op_Minus",
"Spec.K256.PointOps.prime"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_negate (p: proj_point) : proj_point | [] | Spec.K256.PointOps.point_negate | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.proj_point -> Spec.K256.PointOps.proj_point | {
"end_col": 20,
"end_line": 166,
"start_col": 46,
"start_line": 164
} |
Prims.Tot | val is_proj_point_at_inf (p: proj_point) : bool | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero | val is_proj_point_at_inf (p: proj_point) : bool
let is_proj_point_at_inf (p: proj_point) : bool = | false | null | false | let _, _, z = p in
z = zero | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.felem",
"Prims.op_Equality",
"Spec.K256.PointOps.zero",
"Prims.bool"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_proj_point_at_inf (p: proj_point) : bool | [] | Spec.K256.PointOps.is_proj_point_at_inf | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.proj_point -> Prims.bool | {
"end_col": 31,
"end_line": 71,
"start_col": 48,
"start_line": 70
} |
Prims.Tot | val point_double (p: proj_point) : proj_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3 | val point_double (p: proj_point) : proj_point
let point_double (p: proj_point) : proj_point = | false | null | false | let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.felem",
"FStar.Pervasives.Native.Mktuple3",
"Spec.K256.PointOps.op_Star_Percent",
"Spec.K256.PointOps.op_Plus_Percent",
"Spec.K256.PointOps.b",
"Spec.K256.PointOps.op_Subtraction_Percent"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3 | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_double (p: proj_point) : proj_point | [] | Spec.K256.PointOps.point_double | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.proj_point -> Spec.K256.PointOps.proj_point | {
"end_col": 12,
"end_line": 162,
"start_col": 46,
"start_line": 148
} |
Prims.Tot | val qinv (x: qelem) : qelem | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2) | val qinv (x: qelem) : qelem
let qinv (x: qelem) : qelem = | false | null | false | M.pow_mod #q x (q - 2) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.qelem",
"Lib.NatMod.pow_mod",
"Spec.K256.PointOps.q",
"Prims.op_Subtraction"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q | false | true | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qinv (x: qelem) : qelem | [] | Spec.K256.PointOps.qinv | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Spec.K256.PointOps.qelem -> Spec.K256.PointOps.qelem | {
"end_col": 51,
"end_line": 46,
"start_col": 29,
"start_line": 46
} |
Prims.Tot | val prime:(p: pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1 | val prime:(p: pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F})
let prime:(p: pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) = | false | null | false | assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 =
pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 =
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1 | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_LessThan"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val prime:(p: pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) | [] | Spec.K256.PointOps.prime | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Prims.pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F} | {
"end_col": 24,
"end_line": 18,
"start_col": 2,
"start_line": 15
} |
Prims.Tot | val aff_point_store (p: aff_point) : BSeq.lbytes 64 | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_store (p:aff_point) : BSeq.lbytes 64 =
let (px, py) = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy | val aff_point_store (p: aff_point) : BSeq.lbytes 64
let aff_point_store (p: aff_point) : BSeq.lbytes 64 = | false | null | false | let px, py = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.aff_point",
"Spec.K256.PointOps.felem",
"Lib.Sequence.concat",
"Lib.IntTypes.uint8",
"Lib.Sequence.seq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"Lib.Sequence.length",
"Prims.l_or",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.ByteSequence.nat_from_intseq_be",
"Lib.ByteSequence.nat_to_bytes_be",
"Lib.ByteSequence.lbytes"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3
let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
let point_inv_bytes (b:BSeq.lbytes 64) =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
px < prime && py < prime && is_on_curve (px, py)
let load_point_nocheck (b:BSeq.lbytes 64{point_inv_bytes b}) : proj_point =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
to_proj_point (px, py) | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_store (p: aff_point) : BSeq.lbytes 64 | [] | Spec.K256.PointOps.aff_point_store | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.aff_point -> Lib.ByteSequence.lbytes 64 | {
"end_col": 31,
"end_line": 200,
"start_col": 52,
"start_line": 196
} |
Prims.Tot | val point_store (p: proj_point) : BSeq.lbytes 64 | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_store (p:proj_point) : BSeq.lbytes 64 =
aff_point_store (to_aff_point p) | val point_store (p: proj_point) : BSeq.lbytes 64
let point_store (p: proj_point) : BSeq.lbytes 64 = | false | null | false | aff_point_store (to_aff_point p) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.aff_point_store",
"Spec.K256.PointOps.to_aff_point",
"Lib.ByteSequence.lbytes"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3
let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
let point_inv_bytes (b:BSeq.lbytes 64) =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
px < prime && py < prime && is_on_curve (px, py)
let load_point_nocheck (b:BSeq.lbytes 64{point_inv_bytes b}) : proj_point =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
to_proj_point (px, py)
let aff_point_store (p:aff_point) : BSeq.lbytes 64 =
let (px, py) = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_store (p: proj_point) : BSeq.lbytes 64 | [] | Spec.K256.PointOps.point_store | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.K256.PointOps.proj_point -> Lib.ByteSequence.lbytes 64 | {
"end_col": 34,
"end_line": 203,
"start_col": 2,
"start_line": 203
} |
Prims.Tot | val load_point (b: BSeq.lbytes 64) : option proj_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None | val load_point (b: BSeq.lbytes 64) : option proj_point
let load_point (b: BSeq.lbytes 64) : option proj_point = | false | null | false | match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Lib.ByteSequence.lbytes",
"Spec.K256.PointOps.aff_point_load",
"Spec.K256.PointOps.aff_point",
"FStar.Pervasives.Native.Some",
"Spec.K256.PointOps.proj_point",
"Spec.K256.PointOps.to_proj_point",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3
let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_point (b: BSeq.lbytes 64) : option proj_point | [] | Spec.K256.PointOps.load_point | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.ByteSequence.lbytes 64 -> FStar.Pervasives.Native.option Spec.K256.PointOps.proj_point | {
"end_col": 16,
"end_line": 182,
"start_col": 2,
"start_line": 180
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_inv_bytes (b:BSeq.lbytes 64) =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
px < prime && py < prime && is_on_curve (px, py) | let point_inv_bytes (b: BSeq.lbytes 64) = | false | null | false | let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
px < prime && py < prime && is_on_curve (px, py) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Lib.ByteSequence.lbytes",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"Spec.K256.PointOps.prime",
"Spec.K256.PointOps.is_on_curve",
"FStar.Pervasives.Native.Mktuple2",
"Spec.K256.PointOps.felem",
"Prims.nat",
"Prims.b2t",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.ByteSequence.nat_from_bytes_be",
"Lib.IntTypes.uint_t",
"Prims.bool"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3
let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_inv_bytes : b: Lib.ByteSequence.lbytes 64 -> Prims.bool | [] | Spec.K256.PointOps.point_inv_bytes | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.ByteSequence.lbytes 64 -> Prims.bool | {
"end_col": 50,
"end_line": 188,
"start_col": 40,
"start_line": 185
} |
|
Prims.Tot | val aff_point_load (b: BSeq.lbytes 64) : option aff_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None | val aff_point_load (b: BSeq.lbytes 64) : option aff_point
let aff_point_load (b: BSeq.lbytes 64) : option aff_point = | false | null | false | let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve = if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Lib.ByteSequence.lbytes",
"FStar.Pervasives.Native.Some",
"Spec.K256.PointOps.aff_point",
"FStar.Pervasives.Native.Mktuple2",
"Spec.K256.PointOps.felem",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Prims.op_AmpAmp",
"Spec.K256.PointOps.is_on_curve",
"Prims.op_LessThan",
"Spec.K256.PointOps.prime",
"Prims.nat",
"Prims.b2t",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.ByteSequence.nat_from_bytes_be",
"Lib.IntTypes.uint_t"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3
let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z
/// Point conversion between affine, projective and bytes representation | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_load (b: BSeq.lbytes 64) : option aff_point | [] | Spec.K256.PointOps.aff_point_load | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.ByteSequence.lbytes 64 -> FStar.Pervasives.Native.option Spec.K256.PointOps.aff_point | {
"end_col": 52,
"end_line": 177,
"start_col": 58,
"start_line": 170
} |
Prims.Tot | val load_point_nocheck (b: BSeq.lbytes 64 {point_inv_bytes b}) : proj_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_point_nocheck (b:BSeq.lbytes 64{point_inv_bytes b}) : proj_point =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
to_proj_point (px, py) | val load_point_nocheck (b: BSeq.lbytes 64 {point_inv_bytes b}) : proj_point
let load_point_nocheck (b: BSeq.lbytes 64 {point_inv_bytes b}) : proj_point = | false | null | false | let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
to_proj_point (px, py) | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Lib.ByteSequence.lbytes",
"Prims.b2t",
"Spec.K256.PointOps.point_inv_bytes",
"Spec.K256.PointOps.to_proj_point",
"FStar.Pervasives.Native.Mktuple2",
"Spec.K256.PointOps.felem",
"Prims.nat",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.ByteSequence.nat_from_bytes_be",
"Lib.IntTypes.uint_t",
"Spec.K256.PointOps.proj_point"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3
let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
let point_inv_bytes (b:BSeq.lbytes 64) =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
px < prime && py < prime && is_on_curve (px, py) | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_point_nocheck (b: BSeq.lbytes 64 {point_inv_bytes b}) : proj_point | [] | Spec.K256.PointOps.load_point_nocheck | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.ByteSequence.lbytes 64 {Spec.K256.PointOps.point_inv_bytes b}
-> Spec.K256.PointOps.proj_point | {
"end_col": 24,
"end_line": 193,
"start_col": 75,
"start_line": 190
} |
Prims.Tot | val aff_point_decompress (s: BSeq.lbytes 33) : option aff_point | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_decompress (s:BSeq.lbytes 33) : option aff_point =
let s0 = Lib.RawIntTypes.u8_to_UInt8 s.[0] in
if not (s0 = 0x02uy || s0 = 0x03uy) then None
else begin
let x = BSeq.nat_from_bytes_be (sub s 1 32) in
let is_x_valid = x < prime in
let is_y_odd = s0 = 0x03uy in
if not is_x_valid then None
else
match (recover_y x is_y_odd) with
| Some y -> Some (x, y)
| None -> None end | val aff_point_decompress (s: BSeq.lbytes 33) : option aff_point
let aff_point_decompress (s: BSeq.lbytes 33) : option aff_point = | false | null | false | let s0 = Lib.RawIntTypes.u8_to_UInt8 s.[ 0 ] in
if not (s0 = 0x02uy || s0 = 0x03uy)
then None
else
let x = BSeq.nat_from_bytes_be (sub s 1 32) in
let is_x_valid = x < prime in
let is_y_odd = s0 = 0x03uy in
if not is_x_valid
then None
else
match (recover_y x is_y_odd) with
| Some y -> Some (x, y)
| None -> None | {
"checked_file": "Spec.K256.PointOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.K256.PointOps.fst"
} | [
"total"
] | [
"Lib.ByteSequence.lbytes",
"Prims.op_Negation",
"Prims.op_BarBar",
"Prims.op_Equality",
"FStar.UInt8.t",
"FStar.UInt8.__uint_to_t",
"FStar.Pervasives.Native.None",
"Spec.K256.PointOps.aff_point",
"Prims.bool",
"Spec.K256.PointOps.recover_y",
"Spec.K256.PointOps.felem",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"Prims.op_LessThan",
"Spec.K256.PointOps.prime",
"Prims.nat",
"Prims.b2t",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.ByteSequence.nat_from_bytes_be",
"Lib.IntTypes.uint_t",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"FStar.UInt.size",
"Lib.IntTypes.v",
"Lib.Sequence.index",
"FStar.UInt8.v",
"Lib.RawIntTypes.u8_to_UInt8",
"Lib.Sequence.op_String_Access"
] | [] | module Spec.K256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
/// Finite field
let prime : (p:pos{p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F}) =
assert_norm (24 < pow2 256 - 0x1000003D1);
assert_norm (pow2 256 - 0x1000003D1 = pow2 256 - pow2 32 - pow2 9 - pow2 8 - pow2 7 - pow2 6 - pow2 4 - 1);
assert_norm (pow2 256 - 0x1000003D1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F);
pow2 256 - 0x1000003D1
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (x:felem) : felem = M.pow_mod #prime x (prime - 2)
let fsqrt (x:felem) : felem = M.pow_mod #prime x ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let q : q:pos{q < pow2 256} =
assert_norm (0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 < pow2 256);
0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
let qelem = x:nat{x < q}
let qadd (x y:qelem) : qelem = (x + y) % q
let qmul (x y:qelem) : qelem = (x * y) % q
let qinv (x:qelem) : qelem = M.pow_mod #q x (q - 2)
let qnegate (x:qelem) : qelem = (- x) % q
let scalar_is_high (x:qelem) : bool = x > q / 2
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve
let aff_point = felem & felem // Affine point
let proj_point = felem & felem & felem // Projective coordinates
// y * y = x * x * x + b
let b : felem = 7
let is_on_curve (p:aff_point) =
let x, y = p in y *% y = x *% x *% x +% b
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_proj_point_at_inf (p:proj_point) : bool =
let (_, _, z) = p in z = zero
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
// Base point
let g_x : felem = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
let g_y : felem = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
let g : proj_point = (g_x, g_y, one)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = 3 *% px *% px /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
let aff_point_negate (p:aff_point) : aff_point =
let x, y = p in x, (-y) % prime
/// Point addition and doubling in projective coordinates
let point_add (p:proj_point) (q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let xx = x1 *% x2 in
let yy = y1 *% y2 in
let zz = z1 *% z2 in
let xy_pairs = (x1 +% y1) *% (x2 +% y2) -% (xx +% yy) in
let yz_pairs = (y1 +% z1) *% (y2 +% z2) -% (yy +% zz) in
let xz_pairs = (x1 +% z1) *% (x2 +% z2) -% (xx +% zz) in
let bzz3 = 3 *% b *% zz in
let yy_m_bzz3 = yy -% bzz3 in
let yy_p_bzz3 = yy +% bzz3 in
let byz3 = 3 *% b *% yz_pairs in
let xx3 = 3 *% xx in
let bxx9 = 3 *% b *% xx3 in
let x3 = xy_pairs *% yy_m_bzz3 -% byz3 *% xz_pairs in
let y3 = yy_p_bzz3 *% yy_m_bzz3 +% bxx9 *% xz_pairs in
let z3 = yz_pairs *% yy_p_bzz3 +% xx3 *% xy_pairs in
x3, y3, z3
let point_double (p:proj_point) : proj_point =
let x, y, z = p in
let yy = y *% y in
let zz = z *% z in
let xy2 = 2 *% x *% y in
let bzz3 = 3 *% b *% zz in
let bzz9 = 3 *% bzz3 in
let yy_m_bzz9 = yy -% bzz9 in
let yy_p_bzz3 = yy +% bzz3 in
let yy_zz = yy *% zz in
let t = 24 *% b *% yy_zz in
let x3 = xy2 *% yy_m_bzz9 in
let y3 = yy_m_bzz9 *% yy_p_bzz3 +% t in
let z3 = yy *% y *% z *% 8 in
x3, y3, z3
let point_negate (p:proj_point) : proj_point =
let x, y, z = p in
x, (-y) % prime, z
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
let point_inv_bytes (b:BSeq.lbytes 64) =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
px < prime && py < prime && is_on_curve (px, py)
let load_point_nocheck (b:BSeq.lbytes 64{point_inv_bytes b}) : proj_point =
let px = BSeq.nat_from_bytes_be (sub b 0 32) in
let py = BSeq.nat_from_bytes_be (sub b 32 32) in
to_proj_point (px, py)
let aff_point_store (p:aff_point) : BSeq.lbytes 64 =
let (px, py) = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy
let point_store (p:proj_point) : BSeq.lbytes 64 =
aff_point_store (to_aff_point p)
let recover_y (x:felem) (is_odd:bool) : option felem =
let y2 = x *% x *% x +% b in
let y = fsqrt y2 in
if y *% y <> y2 then None
else begin
let y = if is_fodd y <> is_odd then (prime - y) % prime else y in
Some y end | false | false | Spec.K256.PointOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_decompress (s: BSeq.lbytes 33) : option aff_point | [] | Spec.K256.PointOps.aff_point_decompress | {
"file_name": "specs/Spec.K256.PointOps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Lib.ByteSequence.lbytes 33 -> FStar.Pervasives.Native.option Spec.K256.PointOps.aff_point | {
"end_col": 24,
"end_line": 227,
"start_col": 64,
"start_line": 215
} |
FStar.HyperStack.ST.Stack | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Array_Access (#a:Type0) (#rrel #rel:B.srel a) = B.index #a #rrel #rel | let op_Array_Access (#a: Type0) (#rrel #rel: B.srel a) = | true | null | false | B.index #a #rrel #rel | {
"checked_file": "LowStar.BufferOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.BufferOps.fst"
} | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.index",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"LowStar.Monotonic.Buffer.length",
"Prims.eq2",
"FStar.Seq.Base.index",
"LowStar.Monotonic.Buffer.as_seq"
] | [] | (*
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 LowStar.BufferOps
(* Handy notations for LowStar.Buffer, so users can open this module
instead of the whole LowStar.Buffer, to just bring these operators
and notations into the scope without bringing any definition from
LowStar.Buffer into the scope. *)
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module G = FStar.Ghost
module Seq = FStar.Seq
module B = LowStar.Buffer
module L = FStar.List.Tot
inline_for_extraction | false | false | LowStar.BufferOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Array_Access : b: LowStar.Monotonic.Buffer.mbuffer a rrel rel -> i: FStar.UInt32.t -> FStar.HyperStack.ST.Stack a | [] | LowStar.BufferOps.op_Array_Access | {
"file_name": "ulib/LowStar.BufferOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: LowStar.Monotonic.Buffer.mbuffer a rrel rel -> i: FStar.UInt32.t -> FStar.HyperStack.ST.Stack a | {
"end_col": 76,
"end_line": 33,
"start_col": 55,
"start_line": 33
} |
|
FStar.HyperStack.ST.Stack | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Array_Assignment (#a:Type0) (#rrel #rel:B.srel a) = B.upd #a #rrel #rel | let op_Array_Assignment (#a: Type0) (#rrel #rel: B.srel a) = | true | null | false | B.upd #a #rrel #rel | {
"checked_file": "LowStar.BufferOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.BufferOps.fst"
} | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.upd",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.t",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"LowStar.Monotonic.Buffer.length",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.Seq.Base.upd",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.eq2",
"FStar.Seq.Base.seq"
] | [] | (*
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 LowStar.BufferOps
(* Handy notations for LowStar.Buffer, so users can open this module
instead of the whole LowStar.Buffer, to just bring these operators
and notations into the scope without bringing any definition from
LowStar.Buffer into the scope. *)
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module G = FStar.Ghost
module Seq = FStar.Seq
module B = LowStar.Buffer
module L = FStar.List.Tot
inline_for_extraction
unfold
let op_Array_Access (#a:Type0) (#rrel #rel:B.srel a) = B.index #a #rrel #rel
inline_for_extraction | false | false | LowStar.BufferOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Array_Assignment : b: LowStar.Monotonic.Buffer.mbuffer a rrel rel -> i: FStar.UInt32.t -> v: a
-> FStar.HyperStack.ST.Stack Prims.unit | [] | LowStar.BufferOps.op_Array_Assignment | {
"file_name": "ulib/LowStar.BufferOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: LowStar.Monotonic.Buffer.mbuffer a rrel rel -> i: FStar.UInt32.t -> v: a
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 78,
"end_line": 37,
"start_col": 59,
"start_line": 37
} |
|
FStar.HyperStack.ST.Stack | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let blit (#a:Type0) (#rrel1 #rel1 #rrel2 #rel2:B.srel a) = B.blit #a #rrel1 #rel1 #rrel2 #rel2 | let blit (#a: Type0) (#rrel1 #rel1 #rrel2 #rel2: B.srel a) = | true | null | false | B.blit #a #rrel1 #rel1 #rrel2 #rel2 | {
"checked_file": "LowStar.BufferOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.BufferOps.fst"
} | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.blit",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.t",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.UInt32.v",
"LowStar.Monotonic.Buffer.length",
"Prims.l_or",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer_from_to",
"FStar.UInt32.add",
"LowStar.Monotonic.Buffer.disjoint",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.Seq.Properties.replace_subseq",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.eq2",
"FStar.Seq.Base.seq"
] | [] | (*
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 LowStar.BufferOps
(* Handy notations for LowStar.Buffer, so users can open this module
instead of the whole LowStar.Buffer, to just bring these operators
and notations into the scope without bringing any definition from
LowStar.Buffer into the scope. *)
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module G = FStar.Ghost
module Seq = FStar.Seq
module B = LowStar.Buffer
module L = FStar.List.Tot
inline_for_extraction
unfold
let op_Array_Access (#a:Type0) (#rrel #rel:B.srel a) = B.index #a #rrel #rel
inline_for_extraction
unfold
let op_Array_Assignment (#a:Type0) (#rrel #rel:B.srel a) = B.upd #a #rrel #rel
(* NOTE: DO NOT mark ( !* ) as inline_for_extraction,
because it is specially treated by KaRaMeL to extract as *p instead
of p[0] *)
let ( !* ) (#a:Type0) (#rrel #rel:B.srel a) (p:B.mpointer a rrel rel):
HST.Stack a
(requires (fun h -> B.live h p))
(ensures (fun h0 x h1 -> B.live h1 p /\ x == B.get h0 p 0 /\ h1 == h0)) =
B.index p 0ul
(* NOTE: DO NOT mark ( *= ) as inline_for_extraction,
because it is specially treated by KaRaMeL to extract as *p = v instead
of p[0] = v *)
let ( *= ) (#a:Type0) (#rrel #rel:B.srel a) (p:B.mpointer a rrel rel) (v:a) : HST.Stack unit
(requires (fun h -> B.live h p /\ rel (B.as_seq h p) (Seq.upd (B.as_seq h p) 0 v)))
(ensures (fun h0 _ h1 ->
B.live h1 p /\
B.as_seq h1 p `Seq.equal` Seq.create 1 v /\
B.modifies (B.loc_buffer p) h0 h1
))
= B.upd p 0ul v
// TODO: remove | false | false | LowStar.BufferOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val blit : src: LowStar.Monotonic.Buffer.mbuffer a rrel1 rrel2 ->
idx_src: FStar.UInt32.t ->
dst: LowStar.Monotonic.Buffer.mbuffer a rel1 rel2 ->
idx_dst: FStar.UInt32.t ->
len: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.unit | [] | LowStar.BufferOps.blit | {
"file_name": "ulib/LowStar.BufferOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
src: LowStar.Monotonic.Buffer.mbuffer a rrel1 rrel2 ->
idx_src: FStar.UInt32.t ->
dst: LowStar.Monotonic.Buffer.mbuffer a rel1 rel2 ->
idx_dst: FStar.UInt32.t ->
len: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 94,
"end_line": 63,
"start_col": 59,
"start_line": 63
} |
|
FStar.HyperStack.ST.Stack | val op_Bang_Star (#a: Type0) (#rrel #rel: B.srel a) (p: B.mpointer a rrel rel)
: HST.Stack a
(requires (fun h -> B.live h p))
(ensures (fun h0 x h1 -> B.live h1 p /\ x == B.get h0 p 0 /\ h1 == h0)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( !* ) (#a:Type0) (#rrel #rel:B.srel a) (p:B.mpointer a rrel rel):
HST.Stack a
(requires (fun h -> B.live h p))
(ensures (fun h0 x h1 -> B.live h1 p /\ x == B.get h0 p 0 /\ h1 == h0)) =
B.index p 0ul | val op_Bang_Star (#a: Type0) (#rrel #rel: B.srel a) (p: B.mpointer a rrel rel)
: HST.Stack a
(requires (fun h -> B.live h p))
(ensures (fun h0 x h1 -> B.live h1 p /\ x == B.get h0 p 0 /\ h1 == h0))
let op_Bang_Star (#a: Type0) (#rrel #rel: B.srel a) (p: B.mpointer a rrel rel)
: HST.Stack a
(requires (fun h -> B.live h p))
(ensures (fun h0 x h1 -> B.live h1 p /\ x == B.get h0 p 0 /\ h1 == h0)) = | true | null | false | B.index p 0ul | {
"checked_file": "LowStar.BufferOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.BufferOps.fst"
} | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.mpointer",
"LowStar.Monotonic.Buffer.index",
"FStar.UInt32.__uint_to_t",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"LowStar.Monotonic.Buffer.get"
] | [] | (*
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 LowStar.BufferOps
(* Handy notations for LowStar.Buffer, so users can open this module
instead of the whole LowStar.Buffer, to just bring these operators
and notations into the scope without bringing any definition from
LowStar.Buffer into the scope. *)
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module G = FStar.Ghost
module Seq = FStar.Seq
module B = LowStar.Buffer
module L = FStar.List.Tot
inline_for_extraction
unfold
let op_Array_Access (#a:Type0) (#rrel #rel:B.srel a) = B.index #a #rrel #rel
inline_for_extraction
unfold
let op_Array_Assignment (#a:Type0) (#rrel #rel:B.srel a) = B.upd #a #rrel #rel
(* NOTE: DO NOT mark ( !* ) as inline_for_extraction,
because it is specially treated by KaRaMeL to extract as *p instead
of p[0] *)
let ( !* ) (#a:Type0) (#rrel #rel:B.srel a) (p:B.mpointer a rrel rel):
HST.Stack a
(requires (fun h -> B.live h p)) | false | false | LowStar.BufferOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Bang_Star (#a: Type0) (#rrel #rel: B.srel a) (p: B.mpointer a rrel rel)
: HST.Stack a
(requires (fun h -> B.live h p))
(ensures (fun h0 x h1 -> B.live h1 p /\ x == B.get h0 p 0 /\ h1 == h0)) | [] | LowStar.BufferOps.op_Bang_Star | {
"file_name": "ulib/LowStar.BufferOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: LowStar.Monotonic.Buffer.mpointer a rrel rel -> FStar.HyperStack.ST.Stack a | {
"end_col": 15,
"end_line": 46,
"start_col": 2,
"start_line": 46
} |
FStar.HyperStack.ST.Stack | val op_Star_Equals (#a: Type0) (#rrel #rel: B.srel a) (p: B.mpointer a rrel rel) (v: a)
: HST.Stack unit
(requires (fun h -> B.live h p /\ rel (B.as_seq h p) (Seq.upd (B.as_seq h p) 0 v)))
(ensures
(fun h0 _ h1 ->
B.live h1 p /\ (B.as_seq h1 p) `Seq.equal` (Seq.create 1 v) /\
B.modifies (B.loc_buffer p) h0 h1)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( *= ) (#a:Type0) (#rrel #rel:B.srel a) (p:B.mpointer a rrel rel) (v:a) : HST.Stack unit
(requires (fun h -> B.live h p /\ rel (B.as_seq h p) (Seq.upd (B.as_seq h p) 0 v)))
(ensures (fun h0 _ h1 ->
B.live h1 p /\
B.as_seq h1 p `Seq.equal` Seq.create 1 v /\
B.modifies (B.loc_buffer p) h0 h1
))
= B.upd p 0ul v | val op_Star_Equals (#a: Type0) (#rrel #rel: B.srel a) (p: B.mpointer a rrel rel) (v: a)
: HST.Stack unit
(requires (fun h -> B.live h p /\ rel (B.as_seq h p) (Seq.upd (B.as_seq h p) 0 v)))
(ensures
(fun h0 _ h1 ->
B.live h1 p /\ (B.as_seq h1 p) `Seq.equal` (Seq.create 1 v) /\
B.modifies (B.loc_buffer p) h0 h1))
let op_Star_Equals (#a: Type0) (#rrel #rel: B.srel a) (p: B.mpointer a rrel rel) (v: a)
: HST.Stack unit
(requires (fun h -> B.live h p /\ rel (B.as_seq h p) (Seq.upd (B.as_seq h p) 0 v)))
(ensures
(fun h0 _ h1 ->
B.live h1 p /\ (B.as_seq h1 p) `Seq.equal` (Seq.create 1 v) /\
B.modifies (B.loc_buffer p) h0 h1)) = | true | null | false | B.upd p 0ul v | {
"checked_file": "LowStar.BufferOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.BufferOps.fst"
} | [] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.mpointer",
"LowStar.Monotonic.Buffer.upd",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.Seq.Base.upd",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.create",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer"
] | [] | (*
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 LowStar.BufferOps
(* Handy notations for LowStar.Buffer, so users can open this module
instead of the whole LowStar.Buffer, to just bring these operators
and notations into the scope without bringing any definition from
LowStar.Buffer into the scope. *)
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module G = FStar.Ghost
module Seq = FStar.Seq
module B = LowStar.Buffer
module L = FStar.List.Tot
inline_for_extraction
unfold
let op_Array_Access (#a:Type0) (#rrel #rel:B.srel a) = B.index #a #rrel #rel
inline_for_extraction
unfold
let op_Array_Assignment (#a:Type0) (#rrel #rel:B.srel a) = B.upd #a #rrel #rel
(* NOTE: DO NOT mark ( !* ) as inline_for_extraction,
because it is specially treated by KaRaMeL to extract as *p instead
of p[0] *)
let ( !* ) (#a:Type0) (#rrel #rel:B.srel a) (p:B.mpointer a rrel rel):
HST.Stack a
(requires (fun h -> B.live h p))
(ensures (fun h0 x h1 -> B.live h1 p /\ x == B.get h0 p 0 /\ h1 == h0)) =
B.index p 0ul
(* NOTE: DO NOT mark ( *= ) as inline_for_extraction,
because it is specially treated by KaRaMeL to extract as *p = v instead
of p[0] = v *)
let ( *= ) (#a:Type0) (#rrel #rel:B.srel a) (p:B.mpointer a rrel rel) (v:a) : HST.Stack unit
(requires (fun h -> B.live h p /\ rel (B.as_seq h p) (Seq.upd (B.as_seq h p) 0 v)))
(ensures (fun h0 _ h1 ->
B.live h1 p /\
B.as_seq h1 p `Seq.equal` Seq.create 1 v /\
B.modifies (B.loc_buffer p) h0 h1 | false | false | LowStar.BufferOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Star_Equals (#a: Type0) (#rrel #rel: B.srel a) (p: B.mpointer a rrel rel) (v: a)
: HST.Stack unit
(requires (fun h -> B.live h p /\ rel (B.as_seq h p) (Seq.upd (B.as_seq h p) 0 v)))
(ensures
(fun h0 _ h1 ->
B.live h1 p /\ (B.as_seq h1 p) `Seq.equal` (Seq.create 1 v) /\
B.modifies (B.loc_buffer p) h0 h1)) | [] | LowStar.BufferOps.op_Star_Equals | {
"file_name": "ulib/LowStar.BufferOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: LowStar.Monotonic.Buffer.mpointer a rrel rel -> v: a -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 15,
"end_line": 58,
"start_col": 2,
"start_line": 58
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let size_key = 32 | let size_key = | false | null | false | 32 | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0" | false | true | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size_key : Prims.int | [] | Spec.SecretBox.size_key | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 17,
"end_line": 11,
"start_col": 15,
"start_line": 11
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let size_block = 64 | let size_block = | false | null | false | 64 | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_key = 32 (* in bytes *) | false | true | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size_block : Prims.int | [] | Spec.SecretBox.size_block | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 19,
"end_line": 13,
"start_col": 17,
"start_line": 13
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let size_tag = 16 | let size_tag = | false | null | false | 16 | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_key = 32 (* in bytes *)
let size_nonce = 24 (* in bytes *) | false | true | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size_tag : Prims.int | [] | Spec.SecretBox.size_tag | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 17,
"end_line": 14,
"start_col": 15,
"start_line": 14
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let size_nonce = 24 | let size_nonce = | false | null | false | 24 | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *) | false | true | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size_nonce : Prims.int | [] | Spec.SecretBox.size_nonce | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 19,
"end_line": 12,
"start_col": 17,
"start_line": 12
} |
|
Prims.Tot | val get_len0 (len: nat) : r: size_nat{r <= 32} | [
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let get_len0 (len:nat) : r:size_nat{r <= 32} =
if len <= 32 then len else 32 | val get_len0 (len: nat) : r: size_nat{r <= 32}
let get_len0 (len: nat) : r: size_nat{r <= 32} = | false | null | false | if len <= 32 then len else 32 | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"Lib.IntTypes.size_nat",
"Prims.b2t"
] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_key = 32 (* in bytes *)
let size_nonce = 24 (* in bytes *)
let size_block = 64 (* in bytes *)
let size_tag = 16 (* in bytes *)
type key = lbytes size_key
type aekey = lbytes (size_key + size_key)
type nonce = lbytes size_nonce
type tag = lbytes size_tag
let secretbox_init (k:key) (n:nonce) : key & aekey =
let n0 : lbytes 16 = sub n 0 16 in
let n1 : lbytes 8 = sub n 16 8 in
let subkey : lbytes 32 = Spec.Salsa20.hsalsa20 k n0 in
let aekey : lbytes 64 = Spec.Salsa20.salsa20_key_block0 subkey n1 in
(subkey,aekey) | false | false | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_len0 (len: nat) : r: size_nat{r <= 32} | [] | Spec.SecretBox.get_len0 | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Prims.nat -> r: Lib.IntTypes.size_nat{r <= 32} | {
"end_col": 31,
"end_line": 29,
"start_col": 2,
"start_line": 29
} |
Prims.Tot | val secretbox_init (k: key) (n: nonce) : key & aekey | [
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let secretbox_init (k:key) (n:nonce) : key & aekey =
let n0 : lbytes 16 = sub n 0 16 in
let n1 : lbytes 8 = sub n 16 8 in
let subkey : lbytes 32 = Spec.Salsa20.hsalsa20 k n0 in
let aekey : lbytes 64 = Spec.Salsa20.salsa20_key_block0 subkey n1 in
(subkey,aekey) | val secretbox_init (k: key) (n: nonce) : key & aekey
let secretbox_init (k: key) (n: nonce) : key & aekey = | false | null | false | let n0:lbytes 16 = sub n 0 16 in
let n1:lbytes 8 = sub n 16 8 in
let subkey:lbytes 32 = Spec.Salsa20.hsalsa20 k n0 in
let aekey:lbytes 64 = Spec.Salsa20.salsa20_key_block0 subkey n1 in
(subkey, aekey) | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"FStar.Pervasives.Native.Mktuple2",
"Spec.SecretBox.aekey",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Salsa20.salsa20_key_block0",
"Spec.Salsa20.hsalsa20",
"Lib.Sequence.sub",
"Lib.IntTypes.uint_t",
"Spec.SecretBox.size_nonce",
"FStar.Pervasives.Native.tuple2"
] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_key = 32 (* in bytes *)
let size_nonce = 24 (* in bytes *)
let size_block = 64 (* in bytes *)
let size_tag = 16 (* in bytes *)
type key = lbytes size_key
type aekey = lbytes (size_key + size_key)
type nonce = lbytes size_nonce
type tag = lbytes size_tag | false | true | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_init (k: key) (n: nonce) : key & aekey | [] | Spec.SecretBox.secretbox_init | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Spec.SecretBox.key -> n: Spec.SecretBox.nonce -> Spec.SecretBox.key * Spec.SecretBox.aekey | {
"end_col": 16,
"end_line": 26,
"start_col": 52,
"start_line": 21
} |
Prims.Tot | val secretbox_easy (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: c: bytes{length c = size_tag + length m} | [
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let secretbox_easy (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} =
let (tg,c) = secretbox_detached k n m in
Seq.append tg c | val secretbox_easy (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: c: bytes{length c = size_tag + length m}
let secretbox_easy (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: c: bytes{length c = size_tag + length m} = | false | null | false | let tg, c = secretbox_detached k n m in
Seq.append tg c | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.tag",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.append",
"Prims.int",
"Prims.op_Addition",
"Spec.SecretBox.size_tag",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.seq",
"Lib.IntTypes.int_t",
"Spec.SecretBox.secretbox_detached"
] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_key = 32 (* in bytes *)
let size_nonce = 24 (* in bytes *)
let size_block = 64 (* in bytes *)
let size_tag = 16 (* in bytes *)
type key = lbytes size_key
type aekey = lbytes (size_key + size_key)
type nonce = lbytes size_nonce
type tag = lbytes size_tag
let secretbox_init (k:key) (n:nonce) : key & aekey =
let n0 : lbytes 16 = sub n 0 16 in
let n1 : lbytes 8 = sub n 16 8 in
let subkey : lbytes 32 = Spec.Salsa20.hsalsa20 k n0 in
let aekey : lbytes 64 = Spec.Salsa20.salsa20_key_block0 subkey n1 in
(subkey,aekey)
let get_len0 (len:nat) : r:size_nat{r <= 32} =
if len <= 32 then len else 32
let secretbox_detached (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : (tag & c:bytes{length c = length m}) =
let (subkey,aekey) = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let mlen0 = get_len0 (length m) in
let m0 = Seq.slice m 0 mlen0 in
let m1 = Seq.slice m mlen0 (length m) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 mlen0 m0 in
let block0 = map2 (^.) block0 ekey0 in
let c0 = sub block0 0 mlen0 in
let c1 = Spec.Salsa20.salsa20_encrypt_bytes subkey n1 1 m1 in
let c = Seq.append c0 c1 in
let tg = Spec.Poly1305.poly1305_mac c mkey in
(tg, c)
let secretbox_open_detached (k:key) (n:nonce) (tg:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
let (subkey,aekey) = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let tg' = Spec.Poly1305.poly1305_mac c mkey in
if Lib.ByteSequence.lbytes_eq tg tg' then (
let clen0 = get_len0 (length c) in
let c0 = Seq.slice c 0 clen0 in
let c1 = Seq.slice c clen0 (length c) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 clen0 c0 in
let block0 = map2 (^.) block0 ekey0 in
let m0 = sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let m = Seq.append m0 m1 in
Some m)
else None | false | false | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_easy (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: c: bytes{length c = size_tag + length m} | [] | Spec.SecretBox.secretbox_easy | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
k: Spec.SecretBox.key ->
n: Spec.SecretBox.nonce ->
m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> c:
Lib.ByteSequence.bytes{Lib.Sequence.length c = Spec.SecretBox.size_tag + Lib.Sequence.length m} | {
"end_col": 17,
"end_line": 77,
"start_col": 127,
"start_line": 75
} |
Prims.Tot | val secretbox_open_easy
(k: key)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) | [
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let secretbox_open_easy (k:key) (n:nonce) (c:bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m:bytes{length m = length c - size_tag}) =
let tg = Seq.slice c 0 size_tag in
let e = Seq.slice c size_tag (length c) in
secretbox_open_detached k n tg e | val secretbox_open_easy
(k: key)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag})
let secretbox_open_easy
(k: key)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) = | false | null | false | let tg = Seq.slice c 0 size_tag in
let e = Seq.slice c size_tag (length c) in
secretbox_open_detached k n tg e | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_tag",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Prims.op_Subtraction",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.secretbox_open_detached",
"FStar.Seq.Base.seq",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.slice",
"FStar.Pervasives.Native.option",
"Prims.op_Equality",
"Prims.int"
] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_key = 32 (* in bytes *)
let size_nonce = 24 (* in bytes *)
let size_block = 64 (* in bytes *)
let size_tag = 16 (* in bytes *)
type key = lbytes size_key
type aekey = lbytes (size_key + size_key)
type nonce = lbytes size_nonce
type tag = lbytes size_tag
let secretbox_init (k:key) (n:nonce) : key & aekey =
let n0 : lbytes 16 = sub n 0 16 in
let n1 : lbytes 8 = sub n 16 8 in
let subkey : lbytes 32 = Spec.Salsa20.hsalsa20 k n0 in
let aekey : lbytes 64 = Spec.Salsa20.salsa20_key_block0 subkey n1 in
(subkey,aekey)
let get_len0 (len:nat) : r:size_nat{r <= 32} =
if len <= 32 then len else 32
let secretbox_detached (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : (tag & c:bytes{length c = length m}) =
let (subkey,aekey) = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let mlen0 = get_len0 (length m) in
let m0 = Seq.slice m 0 mlen0 in
let m1 = Seq.slice m mlen0 (length m) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 mlen0 m0 in
let block0 = map2 (^.) block0 ekey0 in
let c0 = sub block0 0 mlen0 in
let c1 = Spec.Salsa20.salsa20_encrypt_bytes subkey n1 1 m1 in
let c = Seq.append c0 c1 in
let tg = Spec.Poly1305.poly1305_mac c mkey in
(tg, c)
let secretbox_open_detached (k:key) (n:nonce) (tg:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
let (subkey,aekey) = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let tg' = Spec.Poly1305.poly1305_mac c mkey in
if Lib.ByteSequence.lbytes_eq tg tg' then (
let clen0 = get_len0 (length c) in
let c0 = Seq.slice c 0 clen0 in
let c1 = Seq.slice c clen0 (length c) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 clen0 c0 in
let block0 = map2 (^.) block0 ekey0 in
let m0 = sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let m = Seq.append m0 m1 in
Some m)
else None
let secretbox_easy (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} =
let (tg,c) = secretbox_detached k n m in
Seq.append tg c | false | false | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_open_easy
(k: key)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) | [] | Spec.SecretBox.secretbox_open_easy | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
k: Spec.SecretBox.key ->
n: Spec.SecretBox.nonce ->
c:
Lib.ByteSequence.bytes
{ Lib.Sequence.length c >= Spec.SecretBox.size_tag /\
(Lib.Sequence.length c - Spec.SecretBox.size_tag) / Spec.SecretBox.size_block <=
Lib.IntTypes.max_size_t }
-> FStar.Pervasives.Native.option (m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m = Lib.Sequence.length c - Spec.SecretBox.size_tag}) | {
"end_col": 34,
"end_line": 82,
"start_col": 178,
"start_line": 79
} |
Prims.Tot | val secretbox_detached (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: (tag & c: bytes{length c = length m}) | [
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let secretbox_detached (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : (tag & c:bytes{length c = length m}) =
let (subkey,aekey) = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let mlen0 = get_len0 (length m) in
let m0 = Seq.slice m 0 mlen0 in
let m1 = Seq.slice m mlen0 (length m) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 mlen0 m0 in
let block0 = map2 (^.) block0 ekey0 in
let c0 = sub block0 0 mlen0 in
let c1 = Spec.Salsa20.salsa20_encrypt_bytes subkey n1 1 m1 in
let c = Seq.append c0 c1 in
let tg = Spec.Poly1305.poly1305_mac c mkey in
(tg, c) | val secretbox_detached (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: (tag & c: bytes{length c = length m})
let secretbox_detached (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: (tag & c: bytes{length c = length m}) = | false | null | false | let subkey, aekey = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let mlen0 = get_len0 (length m) in
let m0 = Seq.slice m 0 mlen0 in
let m1 = Seq.slice m mlen0 (length m) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 mlen0 m0 in
let block0 = map2 ( ^. ) block0 ekey0 in
let c0 = sub block0 0 mlen0 in
let c1 = Spec.Salsa20.salsa20_encrypt_bytes subkey n1 1 m1 in
let c = Seq.append c0 c1 in
let tg = Spec.Poly1305.poly1305_mac c mkey in
(tg, c) | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.aekey",
"FStar.Pervasives.Native.Mktuple2",
"Spec.SecretBox.tag",
"Prims.op_Equality",
"Prims.nat",
"Spec.Poly1305.tag",
"Spec.Poly1305.poly1305_mac",
"FStar.Seq.Base.seq",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.append",
"Lib.Sequence.seq",
"Prims.eq2",
"Spec.Salsa20.salsa20_encrypt_bytes",
"Lib.Sequence.lseq",
"Prims.l_and",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub",
"Prims.l_imp",
"Lib.IntTypes.logxor",
"Lib.Sequence.map2",
"Lib.IntTypes.op_Hat_Dot",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.SecretBox.get_len0",
"Spec.SecretBox.size_key",
"Spec.SecretBox.size_nonce",
"FStar.Pervasives.Native.tuple2",
"Spec.SecretBox.secretbox_init"
] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_key = 32 (* in bytes *)
let size_nonce = 24 (* in bytes *)
let size_block = 64 (* in bytes *)
let size_tag = 16 (* in bytes *)
type key = lbytes size_key
type aekey = lbytes (size_key + size_key)
type nonce = lbytes size_nonce
type tag = lbytes size_tag
let secretbox_init (k:key) (n:nonce) : key & aekey =
let n0 : lbytes 16 = sub n 0 16 in
let n1 : lbytes 8 = sub n 16 8 in
let subkey : lbytes 32 = Spec.Salsa20.hsalsa20 k n0 in
let aekey : lbytes 64 = Spec.Salsa20.salsa20_key_block0 subkey n1 in
(subkey,aekey)
let get_len0 (len:nat) : r:size_nat{r <= 32} =
if len <= 32 then len else 32 | false | false | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_detached (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: (tag & c: bytes{length c = length m}) | [] | Spec.SecretBox.secretbox_detached | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
k: Spec.SecretBox.key ->
n: Spec.SecretBox.nonce ->
m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> Spec.SecretBox.tag * c: Lib.ByteSequence.bytes{Lib.Sequence.length c = Lib.Sequence.length m} | {
"end_col": 9,
"end_line": 50,
"start_col": 128,
"start_line": 31
} |
Prims.Tot | val secretbox_open_detached
(k: key)
(n: nonce)
(tg: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) | [
{
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "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
}
] | false | let secretbox_open_detached (k:key) (n:nonce) (tg:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
let (subkey,aekey) = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let tg' = Spec.Poly1305.poly1305_mac c mkey in
if Lib.ByteSequence.lbytes_eq tg tg' then (
let clen0 = get_len0 (length c) in
let c0 = Seq.slice c 0 clen0 in
let c1 = Seq.slice c clen0 (length c) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 clen0 c0 in
let block0 = map2 (^.) block0 ekey0 in
let m0 = sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let m = Seq.append m0 m1 in
Some m)
else None | val secretbox_open_detached
(k: key)
(n: nonce)
(tg: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c})
let secretbox_open_detached
(k: key)
(n: nonce)
(tg: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) = | false | null | false | let subkey, aekey = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let tg' = Spec.Poly1305.poly1305_mac c mkey in
if Lib.ByteSequence.lbytes_eq tg tg'
then
(let clen0 = get_len0 (length c) in
let c0 = Seq.slice c 0 clen0 in
let c1 = Seq.slice c clen0 (length c) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 clen0 c0 in
let block0 = map2 ( ^. ) block0 ekey0 in
let m0 = sub block0 0 clen0 in
let m1 = Spec.Salsa20.salsa20_decrypt_bytes subkey n1 1 c1 in
let m = Seq.append m0 m1 in
Some m)
else None | {
"checked_file": "Spec.SecretBox.fst.checked",
"dependencies": [
"Spec.Salsa20.fst.checked",
"Spec.Poly1305.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SecretBox.fst"
} | [
"total"
] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"Spec.SecretBox.tag",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.aekey",
"Lib.ByteSequence.lbytes_eq",
"Spec.SecretBox.size_tag",
"FStar.Pervasives.Native.Some",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.seq",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.append",
"Lib.Sequence.seq",
"Prims.eq2",
"Spec.Salsa20.salsa20_decrypt_bytes",
"Lib.Sequence.lseq",
"Prims.l_and",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub",
"Prims.l_imp",
"Lib.IntTypes.logxor",
"Lib.Sequence.map2",
"Lib.IntTypes.op_Hat_Dot",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.SecretBox.get_len0",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Spec.Poly1305.tag",
"Spec.Poly1305.poly1305_mac",
"Spec.SecretBox.size_key",
"Spec.SecretBox.size_nonce",
"FStar.Pervasives.Native.tuple2",
"Spec.SecretBox.secretbox_init"
] | [] | module Spec.SecretBox
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_key = 32 (* in bytes *)
let size_nonce = 24 (* in bytes *)
let size_block = 64 (* in bytes *)
let size_tag = 16 (* in bytes *)
type key = lbytes size_key
type aekey = lbytes (size_key + size_key)
type nonce = lbytes size_nonce
type tag = lbytes size_tag
let secretbox_init (k:key) (n:nonce) : key & aekey =
let n0 : lbytes 16 = sub n 0 16 in
let n1 : lbytes 8 = sub n 16 8 in
let subkey : lbytes 32 = Spec.Salsa20.hsalsa20 k n0 in
let aekey : lbytes 64 = Spec.Salsa20.salsa20_key_block0 subkey n1 in
(subkey,aekey)
let get_len0 (len:nat) : r:size_nat{r <= 32} =
if len <= 32 then len else 32
let secretbox_detached (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : (tag & c:bytes{length c = length m}) =
let (subkey,aekey) = secretbox_init k n in
let n1 = sub n 16 8 in
let mkey = sub aekey 0 32 in
let ekey0 = sub aekey 32 32 in
let mlen0 = get_len0 (length m) in
let m0 = Seq.slice m 0 mlen0 in
let m1 = Seq.slice m mlen0 (length m) in
let block0 = create 32 (u8 0) in
let block0 = update_sub block0 0 mlen0 m0 in
let block0 = map2 (^.) block0 ekey0 in
let c0 = sub block0 0 mlen0 in
let c1 = Spec.Salsa20.salsa20_encrypt_bytes subkey n1 1 m1 in
let c = Seq.append c0 c1 in
let tg = Spec.Poly1305.poly1305_mac c mkey in
(tg, c) | false | false | Spec.SecretBox.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secretbox_open_detached
(k: key)
(n: nonce)
(tg: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) | [] | Spec.SecretBox.secretbox_open_detached | {
"file_name": "specs/Spec.SecretBox.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
k: Spec.SecretBox.key ->
n: Spec.SecretBox.nonce ->
tg: Spec.SecretBox.tag ->
c:
Lib.ByteSequence.bytes
{Lib.Sequence.length c / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> FStar.Pervasives.Native.option (m:
Lib.ByteSequence.bytes{Lib.Sequence.length m = Lib.Sequence.length c}) | {
"end_col": 11,
"end_line": 73,
"start_col": 143,
"start_line": 52
} |
Prims.Tot | val state: b:lbuffer uint8 48ul{ recallable b } | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Random",
"short_module": "S"
},
{
"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.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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
}
] | false | let state = gcmalloc HyperStack.root 0uy 48ul | val state: b:lbuffer uint8 48ul{ recallable b }
let state = | false | null | false | gcmalloc HyperStack.root 0uy 48ul | {
"checked_file": "Hacl.Frodo.Random.fst.checked",
"dependencies": [
"Spec.Frodo.Random.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.RandomBuffer.System.fsti.checked",
"Lib.IntTypes.fst.checked",
"Lib.IntTypes.fst.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Frodo.Random.fst"
} | [
"total"
] | [
"LowStar.Buffer.gcmalloc",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"FStar.UInt8.__uint_to_t",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable"
] | [] | module Hacl.Frodo.Random
open FStar.HyperStack.All
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
module S = Spec.Frodo.Random
(* Stub stateless implementation on top of Lib.RandomBuffer.System.
Intended to be replaced for KATs with include/rng.c *)
friend Lib.IntTypes
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | false | Hacl.Frodo.Random.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state: b:lbuffer uint8 48ul{ recallable b } | [] | Hacl.Frodo.Random.state | {
"file_name": "code/frodo/Hacl.Frodo.Random.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 48ul {Lib.Buffer.recallable b} | {
"end_col": 45,
"end_line": 19,
"start_col": 12,
"start_line": 19
} |
Prims.Tot | val secret_int (#sl:sl u#c)
(l:lattice_element sl)
(s:sw) : Type0 | [
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IFC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let secret_int (#sl:sl)
(l:lattice_element sl)
(s:sw) : Type0 =
protected l (int_t s) | val secret_int (#sl:sl u#c)
(l:lattice_element sl)
(s:sw) : Type0
let secret_int (#sl: sl) (l: lattice_element sl) (s: sw) : Type0 = | false | null | false | protected l (int_t s) | {
"checked_file": "FStar.ConstantTime.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.IFC.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.ConstantTime.Integers.fst"
} | [
"total"
] | [
"FStar.IFC.sl",
"FStar.IFC.lattice_element",
"FStar.ConstantTime.Integers.sw",
"FStar.IFC.protected",
"FStar.Integers.int_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.ConstantTime.Integers
(**
This module provides a refinement of FStar.IFC providing an
interface restricted only to constant-time operations on integers.
In contrast, FStar.IFC provides a general monadic information-flow
control framework, which need not be restricted to constant-time
operations.
*)
open FStar.IFC
open FStar.Integers
/// A `secret_int l s` is a machine-integer at secrecy level `l` and
/// signedness/width `s`.
let secret_int (#sl:sl)
(l:lattice_element sl) | false | false | FStar.ConstantTime.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val secret_int (#sl:sl u#c)
(l:lattice_element sl)
(s:sw) : Type0 | [] | FStar.ConstantTime.Integers.secret_int | {
"file_name": "ulib/experimental/FStar.ConstantTime.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | l: FStar.IFC.lattice_element sl -> s: FStar.ConstantTime.Integers.sw -> Type0 | {
"end_col": 25,
"end_line": 35,
"start_col": 4,
"start_line": 35
} |
Prims.GTot | val hide (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:int{within_bounds s x})
: GTot (secret_int l s) | [
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IFC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hide (#sl:sl) (#l:lattice_element sl) (#s:sw) (x:int{within_bounds s x})
: GTot (secret_int l s)
= return l (u x) | val hide (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:int{within_bounds s x})
: GTot (secret_int l s)
let hide (#sl: sl) (#l: lattice_element sl) (#s: sw) (x: int{within_bounds s x})
: GTot (secret_int l s) = | false | null | false | return l (u x) | {
"checked_file": "FStar.ConstantTime.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.IFC.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.ConstantTime.Integers.fst"
} | [
"sometrivial"
] | [
"FStar.IFC.sl",
"FStar.IFC.lattice_element",
"FStar.ConstantTime.Integers.sw",
"FStar.Integers.int",
"FStar.Integers.within_bounds",
"FStar.IFC.return",
"FStar.Integers.int_t",
"FStar.Integers.u",
"FStar.ConstantTime.Integers.secret_int"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.ConstantTime.Integers
(**
This module provides a refinement of FStar.IFC providing an
interface restricted only to constant-time operations on integers.
In contrast, FStar.IFC provides a general monadic information-flow
control framework, which need not be restricted to constant-time
operations.
*)
open FStar.IFC
open FStar.Integers
/// A `secret_int l s` is a machine-integer at secrecy level `l` and
/// signedness/width `s`.
let secret_int (#sl:sl)
(l:lattice_element sl)
(s:sw) : Type0 =
protected l (int_t s)
/// A `secret_int l s` can be seen as an int in spec
let reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s)
: GTot (y:int{within_bounds s y})
= v (reveal x)
/// `hide` is the inverse of `reveal`, proving that `secret_int` is injective
let hide (#sl:sl) (#l:lattice_element sl) (#s:sw) (x:int{within_bounds s x}) | false | false | FStar.ConstantTime.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hide (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:int{within_bounds s x})
: GTot (secret_int l s) | [] | FStar.ConstantTime.Integers.hide | {
"file_name": "ulib/experimental/FStar.ConstantTime.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Integers.int{FStar.Integers.within_bounds s x}
-> Prims.GTot (FStar.ConstantTime.Integers.secret_int l s) | {
"end_col": 18,
"end_line": 48,
"start_col": 4,
"start_line": 48
} |
Prims.GTot | val reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s)
: GTot (y:int{within_bounds s y}) | [
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IFC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s)
: GTot (y:int{within_bounds s y})
= v (reveal x) | val reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s)
: GTot (y:int{within_bounds s y})
let reveal (#sl: sl) (#l: lattice_element sl) (#s: sw) (x: secret_int l s)
: GTot (y: int{within_bounds s y}) = | false | null | false | v (reveal x) | {
"checked_file": "FStar.ConstantTime.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.IFC.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.ConstantTime.Integers.fst"
} | [
"sometrivial"
] | [
"FStar.IFC.sl",
"FStar.IFC.lattice_element",
"FStar.ConstantTime.Integers.sw",
"FStar.ConstantTime.Integers.secret_int",
"FStar.Integers.v",
"FStar.IFC.reveal",
"FStar.Integers.int_t",
"FStar.Integers.int",
"FStar.Integers.within_bounds"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.ConstantTime.Integers
(**
This module provides a refinement of FStar.IFC providing an
interface restricted only to constant-time operations on integers.
In contrast, FStar.IFC provides a general monadic information-flow
control framework, which need not be restricted to constant-time
operations.
*)
open FStar.IFC
open FStar.Integers
/// A `secret_int l s` is a machine-integer at secrecy level `l` and
/// signedness/width `s`.
let secret_int (#sl:sl)
(l:lattice_element sl)
(s:sw) : Type0 =
protected l (int_t s)
/// A `secret_int l s` can be seen as an int in spec
let reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s) | false | false | FStar.ConstantTime.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s)
: GTot (y:int{within_bounds s y}) | [] | FStar.ConstantTime.Integers.reveal | {
"file_name": "ulib/experimental/FStar.ConstantTime.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.ConstantTime.Integers.secret_int l s
-> Prims.GTot (y: FStar.Integers.int{FStar.Integers.within_bounds s y}) | {
"end_col": 17,
"end_line": 43,
"start_col": 5,
"start_line": 43
} |
Prims.Tot | val promote (#sl:sl)
(#l0:lattice_element sl)
(#s:sw)
(x:secret_int l0 s)
(l1:lattice_element sl)
: Tot (y:secret_int (l1 `lub` l0) s{reveal y == reveal x}) | [
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IFC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let promote #sl #l0 #s x l1 =
join (return #_ #(secret_int l0 s) l1 x) | val promote (#sl:sl)
(#l0:lattice_element sl)
(#s:sw)
(x:secret_int l0 s)
(l1:lattice_element sl)
: Tot (y:secret_int (l1 `lub` l0) s{reveal y == reveal x})
let promote #sl #l0 #s x l1 = | false | null | false | join (return #_ #(secret_int l0 s) l1 x) | {
"checked_file": "FStar.ConstantTime.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.IFC.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.ConstantTime.Integers.fst"
} | [
"total"
] | [
"FStar.IFC.sl",
"FStar.IFC.lattice_element",
"FStar.ConstantTime.Integers.sw",
"FStar.ConstantTime.Integers.secret_int",
"FStar.IFC.join",
"FStar.Integers.int_t",
"FStar.IFC.return",
"FStar.IFC.lub",
"Prims.eq2",
"FStar.Integers.int",
"Prims.l_or",
"FStar.Integers.within_bounds",
"FStar.ConstantTime.Integers.reveal"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.ConstantTime.Integers
(**
This module provides a refinement of FStar.IFC providing an
interface restricted only to constant-time operations on integers.
In contrast, FStar.IFC provides a general monadic information-flow
control framework, which need not be restricted to constant-time
operations.
*)
open FStar.IFC
open FStar.Integers
/// A `secret_int l s` is a machine-integer at secrecy level `l` and
/// signedness/width `s`.
let secret_int (#sl:sl)
(l:lattice_element sl)
(s:sw) : Type0 =
protected l (int_t s)
/// A `secret_int l s` can be seen as an int in spec
let reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s)
: GTot (y:int{within_bounds s y})
= v (reveal x)
/// `hide` is the inverse of `reveal`, proving that `secret_int` is injective
let hide (#sl:sl) (#l:lattice_element sl) (#s:sw) (x:int{within_bounds s x})
: GTot (secret_int l s)
= return l (u x)
let reveal_hide #sl #l #s x = ()
let hide_reveal #sl #l #s x = () | false | false | FStar.ConstantTime.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val promote (#sl:sl)
(#l0:lattice_element sl)
(#s:sw)
(x:secret_int l0 s)
(l1:lattice_element sl)
: Tot (y:secret_int (l1 `lub` l0) s{reveal y == reveal x}) | [] | FStar.ConstantTime.Integers.promote | {
"file_name": "ulib/experimental/FStar.ConstantTime.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.ConstantTime.Integers.secret_int l0 s -> l1: FStar.IFC.lattice_element sl
-> y:
FStar.ConstantTime.Integers.secret_int (FStar.IFC.lub l1 l0) s
{FStar.ConstantTime.Integers.reveal y == FStar.ConstantTime.Integers.reveal x} | {
"end_col": 44,
"end_line": 54,
"start_col": 4,
"start_line": 54
} |
Prims.Tot | val addition (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x : secret_int l s)
(y : secret_int l s {ok ( + ) (m x) (m y)})
: Tot (z:secret_int l s{m z == m x + m y}) | [
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IFC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let addition #sl (#l:lattice_element sl) #s
(x : secret_int l s)
(y : secret_int l s {ok ( + ) (m x) (m y)})
: Tot (z:secret_int l s{m z == m x + m y})
= let>> a = x in
let>> b = y in
return l (a + b) | val addition (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x : secret_int l s)
(y : secret_int l s {ok ( + ) (m x) (m y)})
: Tot (z:secret_int l s{m z == m x + m y})
let addition
#sl
(#l: lattice_element sl)
#s
(x: secret_int l s)
(y: secret_int l s {ok ( + ) (m x) (m y)})
: Tot (z: secret_int l s {m z == m x + m y}) = | false | null | false | let>> a = x in
let>> b = y in
return l (a + b) | {
"checked_file": "FStar.ConstantTime.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.IFC.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.ConstantTime.Integers.fst"
} | [
"total"
] | [
"FStar.IFC.sl",
"FStar.IFC.lattice_element",
"FStar.ConstantTime.Integers.sw",
"FStar.ConstantTime.Integers.secret_int",
"FStar.Integers.ok",
"FStar.Integers.op_Plus",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"FStar.ConstantTime.Integers.m",
"FStar.IFC.op_let_Greater_Greater",
"FStar.Integers.int_t",
"FStar.IFC.lub",
"Prims.eq2",
"FStar.IFC.reveal",
"FStar.IFC.return",
"FStar.IFC.protected"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.ConstantTime.Integers
(**
This module provides a refinement of FStar.IFC providing an
interface restricted only to constant-time operations on integers.
In contrast, FStar.IFC provides a general monadic information-flow
control framework, which need not be restricted to constant-time
operations.
*)
open FStar.IFC
open FStar.Integers
/// A `secret_int l s` is a machine-integer at secrecy level `l` and
/// signedness/width `s`.
let secret_int (#sl:sl)
(l:lattice_element sl)
(s:sw) : Type0 =
protected l (int_t s)
/// A `secret_int l s` can be seen as an int in spec
let reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s)
: GTot (y:int{within_bounds s y})
= v (reveal x)
/// `hide` is the inverse of `reveal`, proving that `secret_int` is injective
let hide (#sl:sl) (#l:lattice_element sl) (#s:sw) (x:int{within_bounds s x})
: GTot (secret_int l s)
= return l (u x)
let reveal_hide #sl #l #s x = ()
let hide_reveal #sl #l #s x = ()
let promote #sl #l0 #s x l1 =
join (return #_ #(secret_int l0 s) l1 x)
//////////////////////////////////////////////////////////////////////////////////////////
/// The remainder of this module provides liftings of specific integers operations
/// to work on secret integers, i.e., only those that respect the constant time guarantees
/// and do not break confidentiality.
///
/// Note, with our choice of representation, it is impossible to
/// implement functions that break basic IFC guarantees, e.g., we
/// cannot implement a boolean comparison function on secret_ints
noextract
inline_for_extraction
let addition #sl (#l:lattice_element sl) #s
(x : secret_int l s)
(y : secret_int l s {ok ( + ) (m x) (m y)}) | false | false | FStar.ConstantTime.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val addition (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x : secret_int l s)
(y : secret_int l s {ok ( + ) (m x) (m y)})
: Tot (z:secret_int l s{m z == m x + m y}) | [] | FStar.ConstantTime.Integers.addition | {
"file_name": "ulib/experimental/FStar.ConstantTime.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
x: FStar.ConstantTime.Integers.secret_int l s ->
y:
FStar.ConstantTime.Integers.secret_int l s
{ FStar.Integers.ok FStar.Integers.op_Plus
(FStar.ConstantTime.Integers.m x)
(FStar.ConstantTime.Integers.m y) }
-> z:
FStar.ConstantTime.Integers.secret_int l s
{ FStar.ConstantTime.Integers.m z ==
FStar.ConstantTime.Integers.m x + FStar.ConstantTime.Integers.m y } | {
"end_col": 22,
"end_line": 72,
"start_col": 6,
"start_line": 70
} |
Prims.Tot | val addition_mod (#sl:sl)
(#l:lattice_element sl)
(#sw: _ {Unsigned? sw /\ width_of_sw sw <> W128})
(x : secret_int l sw)
(y : secret_int l sw)
: Tot (z:secret_int l sw { m z == m x +% m y } ) | [
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IFC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ConstantTime",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let addition_mod (#sl:sl)
(#l:lattice_element sl)
(#sw: _ {Unsigned? sw /\ width_of_sw sw <> W128})
(x : secret_int l sw)
(y : secret_int l sw)
: Tot (z:secret_int l sw { m z == m x +% m y } )
= let>> a = x in
let>> b = y in
return l (a +% b) | val addition_mod (#sl:sl)
(#l:lattice_element sl)
(#sw: _ {Unsigned? sw /\ width_of_sw sw <> W128})
(x : secret_int l sw)
(y : secret_int l sw)
: Tot (z:secret_int l sw { m z == m x +% m y } )
let addition_mod
(#sl: sl)
(#l: lattice_element sl)
(#sw: _{Unsigned? sw /\ width_of_sw sw <> W128})
(x y: secret_int l sw)
: Tot (z: secret_int l sw {m z == m x +% m y}) = | false | null | false | let>> a = x in
let>> b = y in
return l (a +% b) | {
"checked_file": "FStar.ConstantTime.Integers.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.IFC.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.ConstantTime.Integers.fst"
} | [
"total"
] | [
"FStar.IFC.sl",
"FStar.IFC.lattice_element",
"FStar.Integers.signed_width",
"Prims.l_and",
"Prims.b2t",
"FStar.Integers.uu___is_Unsigned",
"Prims.op_disEquality",
"FStar.Integers.width",
"FStar.Integers.width_of_sw",
"FStar.Integers.W128",
"FStar.ConstantTime.Integers.secret_int",
"FStar.IFC.op_let_Greater_Greater",
"FStar.Integers.int_t",
"FStar.IFC.lub",
"Prims.eq2",
"FStar.IFC.reveal",
"FStar.IFC.return",
"FStar.Integers.op_Plus_Percent",
"FStar.IFC.protected",
"FStar.ConstantTime.Integers.m"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.ConstantTime.Integers
(**
This module provides a refinement of FStar.IFC providing an
interface restricted only to constant-time operations on integers.
In contrast, FStar.IFC provides a general monadic information-flow
control framework, which need not be restricted to constant-time
operations.
*)
open FStar.IFC
open FStar.Integers
/// A `secret_int l s` is a machine-integer at secrecy level `l` and
/// signedness/width `s`.
let secret_int (#sl:sl)
(l:lattice_element sl)
(s:sw) : Type0 =
protected l (int_t s)
/// A `secret_int l s` can be seen as an int in spec
let reveal (#sl:sl)
(#l:lattice_element sl)
(#s:sw)
(x:secret_int l s)
: GTot (y:int{within_bounds s y})
= v (reveal x)
/// `hide` is the inverse of `reveal`, proving that `secret_int` is injective
let hide (#sl:sl) (#l:lattice_element sl) (#s:sw) (x:int{within_bounds s x})
: GTot (secret_int l s)
= return l (u x)
let reveal_hide #sl #l #s x = ()
let hide_reveal #sl #l #s x = ()
let promote #sl #l0 #s x l1 =
join (return #_ #(secret_int l0 s) l1 x)
//////////////////////////////////////////////////////////////////////////////////////////
/// The remainder of this module provides liftings of specific integers operations
/// to work on secret integers, i.e., only those that respect the constant time guarantees
/// and do not break confidentiality.
///
/// Note, with our choice of representation, it is impossible to
/// implement functions that break basic IFC guarantees, e.g., we
/// cannot implement a boolean comparison function on secret_ints
noextract
inline_for_extraction
let addition #sl (#l:lattice_element sl) #s
(x : secret_int l s)
(y : secret_int l s {ok ( + ) (m x) (m y)})
: Tot (z:secret_int l s{m z == m x + m y})
= let>> a = x in
let>> b = y in
return l (a + b)
noextract
inline_for_extraction
let addition_mod (#sl:sl)
(#l:lattice_element sl)
(#sw: _ {Unsigned? sw /\ width_of_sw sw <> W128})
(x : secret_int l sw)
(y : secret_int l sw) | false | false | FStar.ConstantTime.Integers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val addition_mod (#sl:sl)
(#l:lattice_element sl)
(#sw: _ {Unsigned? sw /\ width_of_sw sw <> W128})
(x : secret_int l sw)
(y : secret_int l sw)
: Tot (z:secret_int l sw { m z == m x +% m y } ) | [] | FStar.ConstantTime.Integers.addition_mod | {
"file_name": "ulib/experimental/FStar.ConstantTime.Integers.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.ConstantTime.Integers.secret_int l sw -> y: FStar.ConstantTime.Integers.secret_int l sw
-> z:
FStar.ConstantTime.Integers.secret_int l sw
{ FStar.ConstantTime.Integers.m z ==
FStar.ConstantTime.Integers.m x +% FStar.ConstantTime.Integers.m y } | {
"end_col": 23,
"end_line": 84,
"start_col": 6,
"start_line": 82
} |
Prims.Tot | val mul_wide_add2_st: #t:limb_t -> mul_wide_add2_t t | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_wide_add2_st #t =
match t with
| U32 -> mul_wide_add2_u32
| U64 -> mul_wide_add2_u64 | val mul_wide_add2_st: #t:limb_t -> mul_wide_add2_t t
let mul_wide_add2_st #t = | false | null | false | match t with
| U32 -> mul_wide_add2_u32
| U64 -> mul_wide_add2_u64 | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Base.mul_wide_add2_u32",
"Hacl.Bignum.Base.mul_wide_add2_u64",
"Hacl.Bignum.Base.mul_wide_add2_t"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out
inline_for_extraction noextract
let mul_wide_add_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in)
val mul_wide_add_u32: mul_wide_add_t U32
[@CInline]
let mul_wide_add_u32 a b c_in out =
lemma_mul_wide_add a b c_in (u32 0);
let res = to_u64 a *! to_u64 b +! to_u64 c_in in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul)
val mul_wide_add_u64: mul_wide_add_t U64
[@CInline]
let mul_wide_add_u64 a b c_in out =
lemma_mul_wide_add a b c_in (u64 0);
let res = mul64_wide a b +! to_u128 c_in in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul)
inline_for_extraction noextract
val mul_wide_add_st: #t:limb_t -> mul_wide_add_t t
let mul_wide_add_st #t =
match t with
| U32 -> mul_wide_add_u32
| U64 -> mul_wide_add_u64
inline_for_extraction noextract
let mul_wide_add2_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add2 a b c_in (LSeq.index (as_seq h0 out) 0))
val mul_wide_add2_u32: mul_wide_add2_t U32
[@CInline]
let mul_wide_add2_u32 a b c_in out =
let out0 = out.(0ul) in
lemma_mul_wide_add a b c_in out0;
let res = to_u64 a *! to_u64 b +! to_u64 c_in +! to_u64 out0 in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul)
val mul_wide_add2_u64: mul_wide_add2_t U64
[@CInline]
let mul_wide_add2_u64 a b c_in out =
let out0 = out.(0ul) in
lemma_mul_wide_add a b c_in out0;
let res = mul64_wide a b +! to_u128 c_in +! to_u128 out0 in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul)
inline_for_extraction noextract
val mul_wide_add2_st: #t:limb_t -> mul_wide_add2_t t | false | false | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide_add2_st: #t:limb_t -> mul_wide_add2_t t | [] | Hacl.Bignum.Base.mul_wide_add2_st | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Base.mul_wide_add2_t t | {
"end_col": 28,
"end_line": 131,
"start_col": 2,
"start_line": 129
} |
Prims.Tot | val mul_wide_add_st: #t:limb_t -> mul_wide_add_t t | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_wide_add_st #t =
match t with
| U32 -> mul_wide_add_u32
| U64 -> mul_wide_add_u64 | val mul_wide_add_st: #t:limb_t -> mul_wide_add_t t
let mul_wide_add_st #t = | false | null | false | match t with
| U32 -> mul_wide_add_u32
| U64 -> mul_wide_add_u64 | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Base.mul_wide_add_u32",
"Hacl.Bignum.Base.mul_wide_add_u64",
"Hacl.Bignum.Base.mul_wide_add_t"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out
inline_for_extraction noextract
let mul_wide_add_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in)
val mul_wide_add_u32: mul_wide_add_t U32
[@CInline]
let mul_wide_add_u32 a b c_in out =
lemma_mul_wide_add a b c_in (u32 0);
let res = to_u64 a *! to_u64 b +! to_u64 c_in in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul)
val mul_wide_add_u64: mul_wide_add_t U64
[@CInline]
let mul_wide_add_u64 a b c_in out =
lemma_mul_wide_add a b c_in (u64 0);
let res = mul64_wide a b +! to_u128 c_in in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul)
inline_for_extraction noextract
val mul_wide_add_st: #t:limb_t -> mul_wide_add_t t | false | false | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide_add_st: #t:limb_t -> mul_wide_add_t t | [] | Hacl.Bignum.Base.mul_wide_add_st | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Base.mul_wide_add_t t | {
"end_col": 27,
"end_line": 91,
"start_col": 2,
"start_line": 89
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_wide_add_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in) | let mul_wide_add_t (t: limb_t) = | false | null | false | a: limb t -> b: limb t -> c_in: limb t -> out: lbuffer (limb t) 1ul
-> Stack (limb t)
(requires fun h -> live h out)
(ensures
fun h0 c_out h1 ->
modifies (loc out) h0 h1 /\ (c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in
) | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Prims.l_and",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.limb",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Sequence.index",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.Base.mul_wide_add"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out
inline_for_extraction noextract | false | true | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide_add_t : t: Hacl.Bignum.Definitions.limb_t -> Type0 | [] | Hacl.Bignum.Base.mul_wide_add_t | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> Type0 | {
"end_col": 67,
"end_line": 65,
"start_col": 4,
"start_line": 58
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_wide_add2_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add2 a b c_in (LSeq.index (as_seq h0 out) 0)) | let mul_wide_add2_t (t: limb_t) = | false | null | false | a: limb t -> b: limb t -> c_in: limb t -> out: lbuffer (limb t) 1ul
-> Stack (limb t)
(requires fun h -> live h out)
(ensures
fun h0 c_out h1 ->
modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) ==
mul_wide_add2 a b c_in (LSeq.index (as_seq h0 out) 0)) | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Prims.l_and",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.limb",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Sequence.index",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.Base.mul_wide_add2"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out
inline_for_extraction noextract
let mul_wide_add_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in)
val mul_wide_add_u32: mul_wide_add_t U32
[@CInline]
let mul_wide_add_u32 a b c_in out =
lemma_mul_wide_add a b c_in (u32 0);
let res = to_u64 a *! to_u64 b +! to_u64 c_in in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul)
val mul_wide_add_u64: mul_wide_add_t U64
[@CInline]
let mul_wide_add_u64 a b c_in out =
lemma_mul_wide_add a b c_in (u64 0);
let res = mul64_wide a b +! to_u128 c_in in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul)
inline_for_extraction noextract
val mul_wide_add_st: #t:limb_t -> mul_wide_add_t t
let mul_wide_add_st #t =
match t with
| U32 -> mul_wide_add_u32
| U64 -> mul_wide_add_u64
inline_for_extraction noextract | false | true | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide_add2_t : t: Hacl.Bignum.Definitions.limb_t -> Type0 | [] | Hacl.Bignum.Base.mul_wide_add2_t | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> Type0 | {
"end_col": 99,
"end_line": 103,
"start_col": 4,
"start_line": 96
} |
|
Prims.Tot | val mul_wide_add_u64: mul_wide_add_t U64 | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_wide_add_u64 a b c_in out =
lemma_mul_wide_add a b c_in (u64 0);
let res = mul64_wide a b +! to_u128 c_in in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul) | val mul_wide_add_u64: mul_wide_add_t U64
let mul_wide_add_u64 a b c_in out = | false | null | false | lemma_mul_wide_add a b c_in (u64 0);
let res = mul64_wide a b +! to_u128 c_in in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul) | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.U64",
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.mul64_wide",
"Lib.IntTypes.to_u128",
"Hacl.Spec.Bignum.Base.lemma_mul_wide_add",
"Lib.IntTypes.u64"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out
inline_for_extraction noextract
let mul_wide_add_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in)
val mul_wide_add_u32: mul_wide_add_t U32
[@CInline]
let mul_wide_add_u32 a b c_in out =
lemma_mul_wide_add a b c_in (u32 0);
let res = to_u64 a *! to_u64 b +! to_u64 c_in in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul)
val mul_wide_add_u64: mul_wide_add_t U64
[@CInline] | false | true | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide_add_u64: mul_wide_add_t U64 | [] | Hacl.Bignum.Base.mul_wide_add_u64 | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Base.mul_wide_add_t Lib.IntTypes.U64 | {
"end_col": 23,
"end_line": 83,
"start_col": 2,
"start_line": 80
} |
Prims.Tot | val mul_wide_add2_u64: mul_wide_add2_t U64 | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_wide_add2_u64 a b c_in out =
let out0 = out.(0ul) in
lemma_mul_wide_add a b c_in out0;
let res = mul64_wide a b +! to_u128 c_in +! to_u128 out0 in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul) | val mul_wide_add2_u64: mul_wide_add2_t U64
let mul_wide_add2_u64 a b c_in out = | false | null | false | let out0 = out.(0ul) in
lemma_mul_wide_add a b c_in out0;
let res = mul64_wide a b +! to_u128 c_in +! to_u128 out0 in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul) | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.U64",
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.mul64_wide",
"Lib.IntTypes.to_u128",
"Hacl.Spec.Bignum.Base.lemma_mul_wide_add",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out
inline_for_extraction noextract
let mul_wide_add_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in)
val mul_wide_add_u32: mul_wide_add_t U32
[@CInline]
let mul_wide_add_u32 a b c_in out =
lemma_mul_wide_add a b c_in (u32 0);
let res = to_u64 a *! to_u64 b +! to_u64 c_in in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul)
val mul_wide_add_u64: mul_wide_add_t U64
[@CInline]
let mul_wide_add_u64 a b c_in out =
lemma_mul_wide_add a b c_in (u64 0);
let res = mul64_wide a b +! to_u128 c_in in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul)
inline_for_extraction noextract
val mul_wide_add_st: #t:limb_t -> mul_wide_add_t t
let mul_wide_add_st #t =
match t with
| U32 -> mul_wide_add_u32
| U64 -> mul_wide_add_u64
inline_for_extraction noextract
let mul_wide_add2_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add2 a b c_in (LSeq.index (as_seq h0 out) 0))
val mul_wide_add2_u32: mul_wide_add2_t U32
[@CInline]
let mul_wide_add2_u32 a b c_in out =
let out0 = out.(0ul) in
lemma_mul_wide_add a b c_in out0;
let res = to_u64 a *! to_u64 b +! to_u64 c_in +! to_u64 out0 in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul)
val mul_wide_add2_u64: mul_wide_add2_t U64 | false | true | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide_add2_u64: mul_wide_add2_t U64 | [] | Hacl.Bignum.Base.mul_wide_add2_u64 | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Base.mul_wide_add2_t Lib.IntTypes.U64 | {
"end_col": 23,
"end_line": 123,
"start_col": 36,
"start_line": 118
} |
Prims.Tot | val mul_wide_add_u32: mul_wide_add_t U32 | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_wide_add_u32 a b c_in out =
lemma_mul_wide_add a b c_in (u32 0);
let res = to_u64 a *! to_u64 b +! to_u64 c_in in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul) | val mul_wide_add_u32: mul_wide_add_t U32
let mul_wide_add_u32 a b c_in out = | false | null | false | lemma_mul_wide_add a b c_in (u32 0);
let res = to_u64 a *! to_u64 b +! to_u64 c_in in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul) | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.U32",
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.to_u32",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.to_u64",
"Hacl.Spec.Bignum.Base.lemma_mul_wide_add",
"Lib.IntTypes.u32"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out
inline_for_extraction noextract
let mul_wide_add_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in)
val mul_wide_add_u32: mul_wide_add_t U32
[@CInline] | false | true | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide_add_u32: mul_wide_add_t U32 | [] | Hacl.Bignum.Base.mul_wide_add_u32 | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Base.mul_wide_add_t Lib.IntTypes.U32 | {
"end_col": 23,
"end_line": 74,
"start_col": 2,
"start_line": 71
} |
Prims.Tot | val mul_wide_add2_u32: mul_wide_add2_t U32 | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_wide_add2_u32 a b c_in out =
let out0 = out.(0ul) in
lemma_mul_wide_add a b c_in out0;
let res = to_u64 a *! to_u64 b +! to_u64 c_in +! to_u64 out0 in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul) | val mul_wide_add2_u32: mul_wide_add2_t U32
let mul_wide_add2_u32 a b c_in out = | false | null | false | let out0 = out.(0ul) in
lemma_mul_wide_add a b c_in out0;
let res = to_u64 a *! to_u64 b +! to_u64 c_in +! to_u64 out0 in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul) | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.U32",
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.to_u32",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.to_u64",
"Hacl.Spec.Bignum.Base.lemma_mul_wide_add",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out
inline_for_extraction noextract
let mul_wide_add_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add a b c_in)
val mul_wide_add_u32: mul_wide_add_t U32
[@CInline]
let mul_wide_add_u32 a b c_in out =
lemma_mul_wide_add a b c_in (u32 0);
let res = to_u64 a *! to_u64 b +! to_u64 c_in in
out.(0ul) <- to_u32 res;
to_u32 (res >>. 32ul)
val mul_wide_add_u64: mul_wide_add_t U64
[@CInline]
let mul_wide_add_u64 a b c_in out =
lemma_mul_wide_add a b c_in (u64 0);
let res = mul64_wide a b +! to_u128 c_in in
out.(0ul) <- to_u64 res;
to_u64 (res >>. 64ul)
inline_for_extraction noextract
val mul_wide_add_st: #t:limb_t -> mul_wide_add_t t
let mul_wide_add_st #t =
match t with
| U32 -> mul_wide_add_u32
| U64 -> mul_wide_add_u64
inline_for_extraction noextract
let mul_wide_add2_t (t:limb_t) =
a:limb t
-> b:limb t
-> c_in:limb t
-> out:lbuffer (limb t) 1ul ->
Stack (limb t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == mul_wide_add2 a b c_in (LSeq.index (as_seq h0 out) 0))
val mul_wide_add2_u32: mul_wide_add2_t U32 | false | true | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide_add2_u32: mul_wide_add2_t U32 | [] | Hacl.Bignum.Base.mul_wide_add2_u32 | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Base.mul_wide_add2_t Lib.IntTypes.U32 | {
"end_col": 23,
"end_line": 113,
"start_col": 36,
"start_line": 108
} |
FStar.HyperStack.ST.Stack | val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subborrow_st c_in a b out =
Lib.IntTypes.Intrinsics.sub_borrow c_in a b out | val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b)
let subborrow_st c_in a b out = | true | null | false | Lib.IntTypes.Intrinsics.sub_borrow c_in a b out | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.Intrinsics.sub_borrow",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out
(**
unsigned char _subborrow_u64 (unsigned char b_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 8-bit borrow b_in (carry flag) to unsigned 64-bit integer b, and subtract the result from
unsigned 64-bit integer a. Store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b) | false | false | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subborrow_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == subborrow c_in a b) | [] | Hacl.Bignum.Base.subborrow_st | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
c_in: Hacl.Spec.Bignum.Base.carry t ->
a: Hacl.Bignum.Definitions.limb t ->
b: Hacl.Bignum.Definitions.limb t ->
out: Lib.Buffer.lbuffer (Hacl.Bignum.Definitions.limb t) 1ul
-> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry t) | {
"end_col": 49,
"end_line": 53,
"start_col": 2,
"start_line": 53
} |
FStar.HyperStack.ST.Stack | val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b) | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let addcarry_st #t c_in a b out =
Lib.IntTypes.Intrinsics.add_carry c_in a b out | val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b)
let addcarry_st #t c_in a b out = | true | null | false | Lib.IntTypes.Intrinsics.add_carry c_in a b out | {
"checked_file": "Hacl.Bignum.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.Intrinsics.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Base.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.lbuffer",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.Intrinsics.add_carry",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC"
] | [] | module Hacl.Bignum.Base
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
include Hacl.Spec.Bignum.Base
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
unsigned char _addcarry_u64 (unsigned char c_in, unsigned __int64 a, unsigned __int64 b, unsigned __int64 * out)
Description
Add unsigned 64-bit integers a and b with unsigned 8-bit carry-in c_in (carry flag),
and store the unsigned 64-bit result in out, and the carry-out in dst (carry or overflow flag).
*)
inline_for_extraction noextract
val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b) | false | false | Hacl.Bignum.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val addcarry_st: #t:limb_t -> c_in:carry t -> a:limb t -> b:limb t -> out:lbuffer (limb t) 1ul ->
Stack (carry t)
(requires fun h -> live h out)
(ensures fun h0 c_out h1 -> modifies (loc out) h0 h1 /\
(c_out, LSeq.index (as_seq h1 out) 0) == addcarry c_in a b) | [] | Hacl.Bignum.Base.addcarry_st | {
"file_name": "code/bignum/Hacl.Bignum.Base.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
c_in: Hacl.Spec.Bignum.Base.carry t ->
a: Hacl.Bignum.Definitions.limb t ->
b: Hacl.Bignum.Definitions.limb t ->
out: Lib.Buffer.lbuffer (Hacl.Bignum.Definitions.limb t) 1ul
-> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry t) | {
"end_col": 48,
"end_line": 35,
"start_col": 2,
"start_line": 35
} |
Prims.GTot | val indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x })
: GTot (x: a { p x }) | [
{
"abbrev": false,
"full_module": "FStar.Squash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x })
: GTot (x: a { p x })
= let w = indefinite_description_tot a p in
let x = Ghost.reveal w in
x | val indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x })
: GTot (x: a { p x })
let indefinite_description_ghost (a: Type) (p: (a -> prop){exists x. p x}) : GTot (x: a{p x}) = | false | null | false | let w = indefinite_description_tot a p in
let x = Ghost.reveal w in
x | {
"checked_file": "FStar.IndefiniteDescription.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.IndefiniteDescription.fst"
} | [
"sometrivial"
] | [
"Prims.prop",
"Prims.l_Exists",
"FStar.Ghost.reveal",
"FStar.Ghost.erased",
"FStar.IndefiniteDescription.indefinite_description_tot"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.IndefiniteDescription
/// Indefinite description is an axiom that allows picking a witness
/// for existentially quantified predicate. See the interface for more
/// context.
///
open FStar.Classical
open FStar.Squash
(** The main axiom:
Given a classical proof of [exists x. p x], we can exhibit an erased
(computationally irrelevant) a witness [x:erased a] validating
[p x].
*)
irreducible
let indefinite_description_tot (a:Type) (p:(a -> prop) { exists x. p x })
: Tot (w:Ghost.erased a{ p w })
= admit() //this is an axiom
(** A version in ghost is easily derivable *)
let indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x }) | false | false | FStar.IndefiniteDescription.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x })
: GTot (x: a { p x }) | [] | FStar.IndefiniteDescription.indefinite_description_ghost | {
"file_name": "ulib/FStar.IndefiniteDescription.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> p: (_: a -> Prims.prop){exists (x: a). p x} -> Prims.GTot (x: a{p x}) | {
"end_col": 5,
"end_line": 42,
"start_col": 3,
"start_line": 40
} |
Prims.GTot | val elim_squash (#p:Type u#a) (s:squash p) : GTot p | [
{
"abbrev": false,
"full_module": "FStar.Squash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let elim_squash (#p:Type u#a) (s:squash p) : GTot p =
let uu : squash (x:p & squash trivial) =
bind_squash s (fun x -> return_squash (| x, return_squash T |)) in
give_proof (return_squash uu);
indefinite_description_ghost p (fun _ -> squash trivial) | val elim_squash (#p:Type u#a) (s:squash p) : GTot p
let elim_squash (#p: Type u#a) (s: squash p) : GTot p = | false | null | false | let uu:squash (x: p & squash trivial) =
bind_squash s (fun x -> return_squash (| x, return_squash T |))
in
give_proof (return_squash uu);
indefinite_description_ghost p (fun _ -> squash trivial) | {
"checked_file": "FStar.IndefiniteDescription.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.IndefiniteDescription.fst"
} | [
"sometrivial"
] | [
"Prims.squash",
"FStar.IndefiniteDescription.indefinite_description_ghost",
"Prims.trivial",
"Prims.prop",
"Prims.unit",
"FStar.Squash.give_proof",
"Prims.dtuple2",
"FStar.Squash.return_squash",
"FStar.Squash.bind_squash",
"Prims.Mkdtuple2",
"Prims.T"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.IndefiniteDescription
/// Indefinite description is an axiom that allows picking a witness
/// for existentially quantified predicate. See the interface for more
/// context.
///
open FStar.Classical
open FStar.Squash
(** The main axiom:
Given a classical proof of [exists x. p x], we can exhibit an erased
(computationally irrelevant) a witness [x:erased a] validating
[p x].
*)
irreducible
let indefinite_description_tot (a:Type) (p:(a -> prop) { exists x. p x })
: Tot (w:Ghost.erased a{ p w })
= admit() //this is an axiom
(** A version in ghost is easily derivable *)
let indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x })
: GTot (x: a { p x })
= let w = indefinite_description_tot a p in
let x = Ghost.reveal w in
x
(** Indefinite description entails the a strong form of the excluded
middle, i.e., one can case-analyze the truth of a proposition
(only in [Ghost]) *)
let strong_excluded_middle (p: Type0) : GTot (b: bool{b = true <==> p}) =
let aux (p: Type0) : Lemma (exists b. b = true <==> p) =
give_proof (bind_squash (get_proof (l_or p (~p)))
(fun (b: l_or p (~p)) ->
bind_squash b
(fun (b': Prims.sum p (~p)) ->
match b' with
| Prims.Left hp ->
give_witness hp;
exists_intro (fun b -> b = true <==> p) true;
get_proof (exists b. b = true <==> p)
| Prims.Right hnp ->
give_witness hnp;
exists_intro (fun b -> b = true <==> p) false;
get_proof (exists b. b = true <==> p))))
in
aux p;
indefinite_description_ghost bool (fun b -> b = true <==> p)
(** We also can combine this with a the classical tautology converting
with a [forall] and an [exists] to extract a witness of validity of [p] from
a classical proof that [p] is not universally invalid.
Note, F*+SMT can easily prove, since it is just classical logic:
[(~(forall n. ~(p n))) ==> (exists n. p n) ] *)
let stronger_markovs_principle (p: (nat -> GTot bool))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) =
indefinite_description_ghost _ (fun n -> p n==true)
(** A variant of the previous lemma, but for a [prop] rather than a
boolean predicate *)
let stronger_markovs_principle_prop (p: (nat -> GTot prop))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) =
indefinite_description_ghost _ p
(** A proof for squash p can be eliminated to get p in the Ghost effect *) | false | false | FStar.IndefiniteDescription.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val elim_squash (#p:Type u#a) (s:squash p) : GTot p | [] | FStar.IndefiniteDescription.elim_squash | {
"file_name": "ulib/FStar.IndefiniteDescription.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: Prims.squash p -> Prims.GTot p | {
"end_col": 58,
"end_line": 89,
"start_col": 53,
"start_line": 85
} |
Prims.Ghost | val stronger_markovs_principle_prop (p: (nat -> GTot prop))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) | [
{
"abbrev": false,
"full_module": "FStar.Squash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let stronger_markovs_principle_prop (p: (nat -> GTot prop))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) =
indefinite_description_ghost _ p | val stronger_markovs_principle_prop (p: (nat -> GTot prop))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n))
let stronger_markovs_principle_prop (p: (nat -> GTot prop))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) = | false | null | false | indefinite_description_ghost _ p | {
"checked_file": "FStar.IndefiniteDescription.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.IndefiniteDescription.fst"
} | [] | [
"Prims.nat",
"Prims.prop",
"FStar.IndefiniteDescription.indefinite_description_ghost",
"Prims.l_not",
"Prims.l_Forall"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.IndefiniteDescription
/// Indefinite description is an axiom that allows picking a witness
/// for existentially quantified predicate. See the interface for more
/// context.
///
open FStar.Classical
open FStar.Squash
(** The main axiom:
Given a classical proof of [exists x. p x], we can exhibit an erased
(computationally irrelevant) a witness [x:erased a] validating
[p x].
*)
irreducible
let indefinite_description_tot (a:Type) (p:(a -> prop) { exists x. p x })
: Tot (w:Ghost.erased a{ p w })
= admit() //this is an axiom
(** A version in ghost is easily derivable *)
let indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x })
: GTot (x: a { p x })
= let w = indefinite_description_tot a p in
let x = Ghost.reveal w in
x
(** Indefinite description entails the a strong form of the excluded
middle, i.e., one can case-analyze the truth of a proposition
(only in [Ghost]) *)
let strong_excluded_middle (p: Type0) : GTot (b: bool{b = true <==> p}) =
let aux (p: Type0) : Lemma (exists b. b = true <==> p) =
give_proof (bind_squash (get_proof (l_or p (~p)))
(fun (b: l_or p (~p)) ->
bind_squash b
(fun (b': Prims.sum p (~p)) ->
match b' with
| Prims.Left hp ->
give_witness hp;
exists_intro (fun b -> b = true <==> p) true;
get_proof (exists b. b = true <==> p)
| Prims.Right hnp ->
give_witness hnp;
exists_intro (fun b -> b = true <==> p) false;
get_proof (exists b. b = true <==> p))))
in
aux p;
indefinite_description_ghost bool (fun b -> b = true <==> p)
(** We also can combine this with a the classical tautology converting
with a [forall] and an [exists] to extract a witness of validity of [p] from
a classical proof that [p] is not universally invalid.
Note, F*+SMT can easily prove, since it is just classical logic:
[(~(forall n. ~(p n))) ==> (exists n. p n) ] *)
let stronger_markovs_principle (p: (nat -> GTot bool))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) =
indefinite_description_ghost _ (fun n -> p n==true)
(** A variant of the previous lemma, but for a [prop] rather than a
boolean predicate *)
let stronger_markovs_principle_prop (p: (nat -> GTot prop)) | false | false | FStar.IndefiniteDescription.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val stronger_markovs_principle_prop (p: (nat -> GTot prop))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) | [] | FStar.IndefiniteDescription.stronger_markovs_principle_prop | {
"file_name": "ulib/FStar.IndefiniteDescription.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: (_: Prims.nat -> Prims.GTot Prims.prop) -> Prims.Ghost Prims.nat | {
"end_col": 36,
"end_line": 80,
"start_col": 4,
"start_line": 80
} |
Prims.Ghost | val stronger_markovs_principle (p: (nat -> GTot bool))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) | [
{
"abbrev": false,
"full_module": "FStar.Squash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let stronger_markovs_principle (p: (nat -> GTot bool))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) =
indefinite_description_ghost _ (fun n -> p n==true) | val stronger_markovs_principle (p: (nat -> GTot bool))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n))
let stronger_markovs_principle (p: (nat -> GTot bool))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) = | false | null | false | indefinite_description_ghost _ (fun n -> p n == true) | {
"checked_file": "FStar.IndefiniteDescription.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.IndefiniteDescription.fst"
} | [] | [
"Prims.nat",
"Prims.bool",
"FStar.IndefiniteDescription.indefinite_description_ghost",
"Prims.eq2",
"Prims.prop",
"Prims.l_not",
"Prims.l_Forall",
"Prims.b2t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.IndefiniteDescription
/// Indefinite description is an axiom that allows picking a witness
/// for existentially quantified predicate. See the interface for more
/// context.
///
open FStar.Classical
open FStar.Squash
(** The main axiom:
Given a classical proof of [exists x. p x], we can exhibit an erased
(computationally irrelevant) a witness [x:erased a] validating
[p x].
*)
irreducible
let indefinite_description_tot (a:Type) (p:(a -> prop) { exists x. p x })
: Tot (w:Ghost.erased a{ p w })
= admit() //this is an axiom
(** A version in ghost is easily derivable *)
let indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x })
: GTot (x: a { p x })
= let w = indefinite_description_tot a p in
let x = Ghost.reveal w in
x
(** Indefinite description entails the a strong form of the excluded
middle, i.e., one can case-analyze the truth of a proposition
(only in [Ghost]) *)
let strong_excluded_middle (p: Type0) : GTot (b: bool{b = true <==> p}) =
let aux (p: Type0) : Lemma (exists b. b = true <==> p) =
give_proof (bind_squash (get_proof (l_or p (~p)))
(fun (b: l_or p (~p)) ->
bind_squash b
(fun (b': Prims.sum p (~p)) ->
match b' with
| Prims.Left hp ->
give_witness hp;
exists_intro (fun b -> b = true <==> p) true;
get_proof (exists b. b = true <==> p)
| Prims.Right hnp ->
give_witness hnp;
exists_intro (fun b -> b = true <==> p) false;
get_proof (exists b. b = true <==> p))))
in
aux p;
indefinite_description_ghost bool (fun b -> b = true <==> p)
(** We also can combine this with a the classical tautology converting
with a [forall] and an [exists] to extract a witness of validity of [p] from
a classical proof that [p] is not universally invalid.
Note, F*+SMT can easily prove, since it is just classical logic:
[(~(forall n. ~(p n))) ==> (exists n. p n) ] *)
let stronger_markovs_principle (p: (nat -> GTot bool)) | false | false | FStar.IndefiniteDescription.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val stronger_markovs_principle (p: (nat -> GTot bool))
: Ghost nat (requires (~(forall (n: nat). ~(p n)))) (ensures (fun n -> p n)) | [] | FStar.IndefiniteDescription.stronger_markovs_principle | {
"file_name": "ulib/FStar.IndefiniteDescription.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: (_: Prims.nat -> Prims.GTot Prims.bool) -> Prims.Ghost Prims.nat | {
"end_col": 55,
"end_line": 74,
"start_col": 4,
"start_line": 74
} |
Prims.GTot | val strong_excluded_middle (p: Type0) : GTot (b: bool{b = true <==> p}) | [
{
"abbrev": false,
"full_module": "FStar.Squash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let strong_excluded_middle (p: Type0) : GTot (b: bool{b = true <==> p}) =
let aux (p: Type0) : Lemma (exists b. b = true <==> p) =
give_proof (bind_squash (get_proof (l_or p (~p)))
(fun (b: l_or p (~p)) ->
bind_squash b
(fun (b': Prims.sum p (~p)) ->
match b' with
| Prims.Left hp ->
give_witness hp;
exists_intro (fun b -> b = true <==> p) true;
get_proof (exists b. b = true <==> p)
| Prims.Right hnp ->
give_witness hnp;
exists_intro (fun b -> b = true <==> p) false;
get_proof (exists b. b = true <==> p))))
in
aux p;
indefinite_description_ghost bool (fun b -> b = true <==> p) | val strong_excluded_middle (p: Type0) : GTot (b: bool{b = true <==> p})
let strong_excluded_middle (p: Type0) : GTot (b: bool{b = true <==> p}) = | false | null | false | let aux (p: Type0) : Lemma (exists b. b = true <==> p) =
give_proof (bind_squash (get_proof (l_or p (~p)))
(fun (b: l_or p (~p)) ->
bind_squash b
(fun (b': Prims.sum p (~p)) ->
match b' with
| Prims.Left hp ->
give_witness hp;
exists_intro (fun b -> b = true <==> p) true;
get_proof (exists b. b = true <==> p)
| Prims.Right hnp ->
give_witness hnp;
exists_intro (fun b -> b = true <==> p) false;
get_proof (exists b. b = true <==> p))))
in
aux p;
indefinite_description_ghost bool (fun b -> b = true <==> p) | {
"checked_file": "FStar.IndefiniteDescription.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.IndefiniteDescription.fst"
} | [
"sometrivial"
] | [
"FStar.IndefiniteDescription.indefinite_description_ghost",
"Prims.bool",
"Prims.l_iff",
"Prims.b2t",
"Prims.op_Equality",
"Prims.prop",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_Exists",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Squash.give_proof",
"FStar.Squash.bind_squash",
"Prims.l_or",
"Prims.l_not",
"FStar.Squash.get_proof",
"Prims.sum",
"FStar.Classical.exists_intro",
"FStar.Classical.give_witness"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.IndefiniteDescription
/// Indefinite description is an axiom that allows picking a witness
/// for existentially quantified predicate. See the interface for more
/// context.
///
open FStar.Classical
open FStar.Squash
(** The main axiom:
Given a classical proof of [exists x. p x], we can exhibit an erased
(computationally irrelevant) a witness [x:erased a] validating
[p x].
*)
irreducible
let indefinite_description_tot (a:Type) (p:(a -> prop) { exists x. p x })
: Tot (w:Ghost.erased a{ p w })
= admit() //this is an axiom
(** A version in ghost is easily derivable *)
let indefinite_description_ghost (a: Type) (p: (a -> prop) { exists x. p x })
: GTot (x: a { p x })
= let w = indefinite_description_tot a p in
let x = Ghost.reveal w in
x
(** Indefinite description entails the a strong form of the excluded
middle, i.e., one can case-analyze the truth of a proposition | false | false | FStar.IndefiniteDescription.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val strong_excluded_middle (p: Type0) : GTot (b: bool{b = true <==> p}) | [] | FStar.IndefiniteDescription.strong_excluded_middle | {
"file_name": "ulib/FStar.IndefiniteDescription.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: Type0 -> Prims.GTot (b: Prims.bool{b = true <==> p}) | {
"end_col": 62,
"end_line": 64,
"start_col": 73,
"start_line": 47
} |
Prims.Tot | val div_mod (#m: pos{1 < m}) (a b: nat_mod m) : nat_mod m | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let div_mod (#m:pos{1 < m}) (a:nat_mod m) (b:nat_mod m) : nat_mod m = mul_mod a (inv_mod b) | val div_mod (#m: pos{1 < m}) (a b: nat_mod m) : nat_mod m
let div_mod (#m: pos{1 < m}) (a b: nat_mod m) : nat_mod m = | false | null | false | mul_mod a (inv_mod b) | {
"checked_file": "Lib.NatMod.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Fermat.fsti.checked",
"FStar.Math.Euclid.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.NatMod.fsti"
} | [
"total"
] | [
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.NatMod.nat_mod",
"Lib.NatMod.mul_mod",
"Lib.NatMod.inv_mod"
] | [] | module Lib.NatMod
open FStar.Mul
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module LE = Lib.Exponentiation.Definition
#set-options "--z3rlimit 10 --fuel 0 --ifuel 0"
let mk_nat_comm_monoid : LE.comm_monoid int = {
LE.one = 1;
LE.mul = FStar.Mul.op_Star;
LE.lemma_one = Math.Lemmas.mul_one_right_is_same;
LE.lemma_mul_assoc = Math.Lemmas.paren_mul_right;
LE.lemma_mul_comm = Math.Lemmas.swap_mul;
}
let rec pow (x:int) (n:nat) : Tot int =
if n = 0 then 1
else x * pow x (n - 1)
val lemma_pow0: a:int -> Lemma (pow a 0 = 1)
val lemma_pow1: a:int -> Lemma (pow a 1 = a)
val lemma_pow_unfold: a:int -> b:pos -> Lemma (a * pow a (b - 1) == pow a b)
val lemma_pow_gt_zero: a:pos -> b:nat -> Lemma (pow a b > 0) [SMTPat (pow a b)]
val lemma_pow_ge_zero: a:nat -> b:nat -> Lemma (pow a b >= 0) [SMTPat (pow a b)]
val lemma_pow_nat_is_pow: a:int -> b:nat ->
Lemma (pow a b == LE.pow mk_nat_comm_monoid a b)
val lemma_pow_zero: b:pos -> Lemma (pow 0 b = 0)
val lemma_pow_one: b:nat -> Lemma (pow 1 b = 1)
val lemma_pow_add: x:int -> n:nat -> m:nat -> Lemma (pow x n * pow x m = pow x (n + m))
val lemma_pow_mul: x:int -> n:nat -> m:nat -> Lemma (pow (pow x n) m = pow x (n * m))
val lemma_pow_double: a:int -> b:nat -> Lemma (pow (a * a) b == pow a (b + b))
val lemma_pow_mul_base: a:int -> b:int -> n:nat -> Lemma (pow a n * pow b n == pow (a * b) n)
val lemma_pow_mod_base: a:int -> b:nat -> n:pos -> Lemma (pow a b % n == pow (a % n) b % n)
let nat_mod (m:pos) = n:nat{n < m}
let one_mod (#m:pos) : nat_mod m = 1 % m
let mul_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = a * b % m
let add_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = (a + b) % m
let sub_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = (a - b) % m
val lemma_mul_mod_one: #m:pos -> a:nat_mod m -> Lemma (mul_mod a one_mod == a)
val lemma_mul_mod_assoc: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod (mul_mod a b) c == mul_mod a (mul_mod b c))
val lemma_mul_mod_comm: #m:pos -> a:nat_mod m -> b:nat_mod m ->
Lemma (mul_mod a b == mul_mod b a)
let mk_nat_mod_comm_monoid (m:pos) : LE.comm_monoid (nat_mod m) = {
LE.one = one_mod;
LE.mul = mul_mod;
LE.lemma_one = lemma_mul_mod_one;
LE.lemma_mul_assoc = lemma_mul_mod_assoc;
LE.lemma_mul_comm = lemma_mul_mod_comm;
}
inline_for_extraction
let rec pow_mod_ (#m:pos{1 < m}) (a:nat_mod m) (b:nat) : Tot (nat_mod m) (decreases b) =
if b = 0 then 1
else
if b % 2 = 0 then pow_mod_ (mul_mod a a) (b / 2)
else mul_mod a (pow_mod_ (mul_mod a a) (b / 2))
val pow_mod: #m:pos{1 < m} -> a:nat_mod m -> b:nat -> nat_mod m
val pow_mod_def: #m:pos{1 < m} -> a:nat_mod m -> b:nat -> Lemma (pow_mod a b == pow_mod_ a b)
val lemma_pow_mod: #m:pos{1 < m} -> a:nat_mod m -> b:nat -> Lemma (pow a b % m == pow_mod #m a b)
val lemma_pow_nat_mod_is_pow: #n:pos{1 < n} -> a:nat_mod n -> b:nat ->
Lemma (pow a b % n == LE.pow (mk_nat_mod_comm_monoid n) a b)
val lemma_add_mod_one: #m:pos -> a:nat_mod m -> Lemma (add_mod a 0 == a)
val lemma_add_mod_assoc: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (add_mod (add_mod a b) c == add_mod a (add_mod b c))
val lemma_add_mod_comm: #m:pos -> a:nat_mod m -> b:nat_mod m ->
Lemma (add_mod a b == add_mod b a)
val lemma_mod_distributivity_add_right: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod a (add_mod b c) == add_mod (mul_mod a b) (mul_mod a c))
val lemma_mod_distributivity_add_left: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod (add_mod a b) c == add_mod (mul_mod a c) (mul_mod b c))
val lemma_mod_distributivity_sub_right: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod a (sub_mod b c) == sub_mod (mul_mod a b) (mul_mod a c))
val lemma_mod_distributivity_sub_left: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod (sub_mod a b) c == sub_mod (mul_mod a c) (mul_mod b c))
let prime = m:pos{1 < m /\ Euclid.is_prime m} | false | false | Lib.NatMod.fsti | {
"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": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val div_mod (#m: pos{1 < m}) (a b: nat_mod m) : nat_mod m | [] | Lib.NatMod.div_mod | {
"file_name": "lib/Lib.NatMod.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.NatMod.nat_mod m -> b: Lib.NatMod.nat_mod m -> Lib.NatMod.nat_mod m | {
"end_col": 91,
"end_line": 115,
"start_col": 70,
"start_line": 115
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let prime = m:pos{1 < m /\ Euclid.is_prime m} | let prime = | false | null | false | m: pos{1 < m /\ Euclid.is_prime m} | {
"checked_file": "Lib.NatMod.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Fermat.fsti.checked",
"FStar.Math.Euclid.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.NatMod.fsti"
} | [
"total"
] | [
"Prims.pos",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Math.Euclid.is_prime"
] | [] | module Lib.NatMod
open FStar.Mul
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module LE = Lib.Exponentiation.Definition
#set-options "--z3rlimit 10 --fuel 0 --ifuel 0"
let mk_nat_comm_monoid : LE.comm_monoid int = {
LE.one = 1;
LE.mul = FStar.Mul.op_Star;
LE.lemma_one = Math.Lemmas.mul_one_right_is_same;
LE.lemma_mul_assoc = Math.Lemmas.paren_mul_right;
LE.lemma_mul_comm = Math.Lemmas.swap_mul;
}
let rec pow (x:int) (n:nat) : Tot int =
if n = 0 then 1
else x * pow x (n - 1)
val lemma_pow0: a:int -> Lemma (pow a 0 = 1)
val lemma_pow1: a:int -> Lemma (pow a 1 = a)
val lemma_pow_unfold: a:int -> b:pos -> Lemma (a * pow a (b - 1) == pow a b)
val lemma_pow_gt_zero: a:pos -> b:nat -> Lemma (pow a b > 0) [SMTPat (pow a b)]
val lemma_pow_ge_zero: a:nat -> b:nat -> Lemma (pow a b >= 0) [SMTPat (pow a b)]
val lemma_pow_nat_is_pow: a:int -> b:nat ->
Lemma (pow a b == LE.pow mk_nat_comm_monoid a b)
val lemma_pow_zero: b:pos -> Lemma (pow 0 b = 0)
val lemma_pow_one: b:nat -> Lemma (pow 1 b = 1)
val lemma_pow_add: x:int -> n:nat -> m:nat -> Lemma (pow x n * pow x m = pow x (n + m))
val lemma_pow_mul: x:int -> n:nat -> m:nat -> Lemma (pow (pow x n) m = pow x (n * m))
val lemma_pow_double: a:int -> b:nat -> Lemma (pow (a * a) b == pow a (b + b))
val lemma_pow_mul_base: a:int -> b:int -> n:nat -> Lemma (pow a n * pow b n == pow (a * b) n)
val lemma_pow_mod_base: a:int -> b:nat -> n:pos -> Lemma (pow a b % n == pow (a % n) b % n)
let nat_mod (m:pos) = n:nat{n < m}
let one_mod (#m:pos) : nat_mod m = 1 % m
let mul_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = a * b % m
let add_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = (a + b) % m
let sub_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = (a - b) % m
val lemma_mul_mod_one: #m:pos -> a:nat_mod m -> Lemma (mul_mod a one_mod == a)
val lemma_mul_mod_assoc: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod (mul_mod a b) c == mul_mod a (mul_mod b c))
val lemma_mul_mod_comm: #m:pos -> a:nat_mod m -> b:nat_mod m ->
Lemma (mul_mod a b == mul_mod b a)
let mk_nat_mod_comm_monoid (m:pos) : LE.comm_monoid (nat_mod m) = {
LE.one = one_mod;
LE.mul = mul_mod;
LE.lemma_one = lemma_mul_mod_one;
LE.lemma_mul_assoc = lemma_mul_mod_assoc;
LE.lemma_mul_comm = lemma_mul_mod_comm;
}
inline_for_extraction
let rec pow_mod_ (#m:pos{1 < m}) (a:nat_mod m) (b:nat) : Tot (nat_mod m) (decreases b) =
if b = 0 then 1
else
if b % 2 = 0 then pow_mod_ (mul_mod a a) (b / 2)
else mul_mod a (pow_mod_ (mul_mod a a) (b / 2))
val pow_mod: #m:pos{1 < m} -> a:nat_mod m -> b:nat -> nat_mod m
val pow_mod_def: #m:pos{1 < m} -> a:nat_mod m -> b:nat -> Lemma (pow_mod a b == pow_mod_ a b)
val lemma_pow_mod: #m:pos{1 < m} -> a:nat_mod m -> b:nat -> Lemma (pow a b % m == pow_mod #m a b)
val lemma_pow_nat_mod_is_pow: #n:pos{1 < n} -> a:nat_mod n -> b:nat ->
Lemma (pow a b % n == LE.pow (mk_nat_mod_comm_monoid n) a b)
val lemma_add_mod_one: #m:pos -> a:nat_mod m -> Lemma (add_mod a 0 == a)
val lemma_add_mod_assoc: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (add_mod (add_mod a b) c == add_mod a (add_mod b c))
val lemma_add_mod_comm: #m:pos -> a:nat_mod m -> b:nat_mod m ->
Lemma (add_mod a b == add_mod b a)
val lemma_mod_distributivity_add_right: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod a (add_mod b c) == add_mod (mul_mod a b) (mul_mod a c))
val lemma_mod_distributivity_add_left: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod (add_mod a b) c == add_mod (mul_mod a c) (mul_mod b c))
val lemma_mod_distributivity_sub_right: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod a (sub_mod b c) == sub_mod (mul_mod a b) (mul_mod a c))
val lemma_mod_distributivity_sub_left: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod (sub_mod a b) c == sub_mod (mul_mod a c) (mul_mod b c)) | false | true | Lib.NatMod.fsti | {
"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": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val prime : Type0 | [] | Lib.NatMod.prime | {
"file_name": "lib/Lib.NatMod.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 45,
"end_line": 113,
"start_col": 12,
"start_line": 113
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_mod (m:pos) = n:nat{n < m} | let nat_mod (m: pos) = | false | null | false | n: nat{n < m} | {
"checked_file": "Lib.NatMod.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Fermat.fsti.checked",
"FStar.Math.Euclid.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.NatMod.fsti"
} | [
"total"
] | [
"Prims.pos",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan"
] | [] | module Lib.NatMod
open FStar.Mul
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module LE = Lib.Exponentiation.Definition
#set-options "--z3rlimit 10 --fuel 0 --ifuel 0"
let mk_nat_comm_monoid : LE.comm_monoid int = {
LE.one = 1;
LE.mul = FStar.Mul.op_Star;
LE.lemma_one = Math.Lemmas.mul_one_right_is_same;
LE.lemma_mul_assoc = Math.Lemmas.paren_mul_right;
LE.lemma_mul_comm = Math.Lemmas.swap_mul;
}
let rec pow (x:int) (n:nat) : Tot int =
if n = 0 then 1
else x * pow x (n - 1)
val lemma_pow0: a:int -> Lemma (pow a 0 = 1)
val lemma_pow1: a:int -> Lemma (pow a 1 = a)
val lemma_pow_unfold: a:int -> b:pos -> Lemma (a * pow a (b - 1) == pow a b)
val lemma_pow_gt_zero: a:pos -> b:nat -> Lemma (pow a b > 0) [SMTPat (pow a b)]
val lemma_pow_ge_zero: a:nat -> b:nat -> Lemma (pow a b >= 0) [SMTPat (pow a b)]
val lemma_pow_nat_is_pow: a:int -> b:nat ->
Lemma (pow a b == LE.pow mk_nat_comm_monoid a b)
val lemma_pow_zero: b:pos -> Lemma (pow 0 b = 0)
val lemma_pow_one: b:nat -> Lemma (pow 1 b = 1)
val lemma_pow_add: x:int -> n:nat -> m:nat -> Lemma (pow x n * pow x m = pow x (n + m))
val lemma_pow_mul: x:int -> n:nat -> m:nat -> Lemma (pow (pow x n) m = pow x (n * m))
val lemma_pow_double: a:int -> b:nat -> Lemma (pow (a * a) b == pow a (b + b))
val lemma_pow_mul_base: a:int -> b:int -> n:nat -> Lemma (pow a n * pow b n == pow (a * b) n)
val lemma_pow_mod_base: a:int -> b:nat -> n:pos -> Lemma (pow a b % n == pow (a % n) b % n) | false | true | Lib.NatMod.fsti | {
"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": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat_mod : m: Prims.pos -> Type0 | [] | Lib.NatMod.nat_mod | {
"file_name": "lib/Lib.NatMod.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Prims.pos -> Type0 | {
"end_col": 34,
"end_line": 51,
"start_col": 22,
"start_line": 51
} |
|
Prims.Tot | val mk_nat_mod_comm_monoid (m: pos) : LE.comm_monoid (nat_mod m) | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_nat_mod_comm_monoid (m:pos) : LE.comm_monoid (nat_mod m) = {
LE.one = one_mod;
LE.mul = mul_mod;
LE.lemma_one = lemma_mul_mod_one;
LE.lemma_mul_assoc = lemma_mul_mod_assoc;
LE.lemma_mul_comm = lemma_mul_mod_comm;
} | val mk_nat_mod_comm_monoid (m: pos) : LE.comm_monoid (nat_mod m)
let mk_nat_mod_comm_monoid (m: pos) : LE.comm_monoid (nat_mod m) = | false | null | false | {
LE.one = one_mod;
LE.mul = mul_mod;
LE.lemma_one = lemma_mul_mod_one;
LE.lemma_mul_assoc = lemma_mul_mod_assoc;
LE.lemma_mul_comm = lemma_mul_mod_comm
} | {
"checked_file": "Lib.NatMod.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Math.Fermat.fsti.checked",
"FStar.Math.Euclid.fsti.checked"
],
"interface_file": false,
"source_file": "Lib.NatMod.fsti"
} | [
"total"
] | [
"Prims.pos",
"Lib.Exponentiation.Definition.Mkcomm_monoid",
"Lib.NatMod.nat_mod",
"Lib.NatMod.one_mod",
"Lib.NatMod.mul_mod",
"Lib.NatMod.lemma_mul_mod_one",
"Lib.NatMod.lemma_mul_mod_assoc",
"Lib.NatMod.lemma_mul_mod_comm",
"Lib.Exponentiation.Definition.comm_monoid"
] | [] | module Lib.NatMod
open FStar.Mul
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module LE = Lib.Exponentiation.Definition
#set-options "--z3rlimit 10 --fuel 0 --ifuel 0"
let mk_nat_comm_monoid : LE.comm_monoid int = {
LE.one = 1;
LE.mul = FStar.Mul.op_Star;
LE.lemma_one = Math.Lemmas.mul_one_right_is_same;
LE.lemma_mul_assoc = Math.Lemmas.paren_mul_right;
LE.lemma_mul_comm = Math.Lemmas.swap_mul;
}
let rec pow (x:int) (n:nat) : Tot int =
if n = 0 then 1
else x * pow x (n - 1)
val lemma_pow0: a:int -> Lemma (pow a 0 = 1)
val lemma_pow1: a:int -> Lemma (pow a 1 = a)
val lemma_pow_unfold: a:int -> b:pos -> Lemma (a * pow a (b - 1) == pow a b)
val lemma_pow_gt_zero: a:pos -> b:nat -> Lemma (pow a b > 0) [SMTPat (pow a b)]
val lemma_pow_ge_zero: a:nat -> b:nat -> Lemma (pow a b >= 0) [SMTPat (pow a b)]
val lemma_pow_nat_is_pow: a:int -> b:nat ->
Lemma (pow a b == LE.pow mk_nat_comm_monoid a b)
val lemma_pow_zero: b:pos -> Lemma (pow 0 b = 0)
val lemma_pow_one: b:nat -> Lemma (pow 1 b = 1)
val lemma_pow_add: x:int -> n:nat -> m:nat -> Lemma (pow x n * pow x m = pow x (n + m))
val lemma_pow_mul: x:int -> n:nat -> m:nat -> Lemma (pow (pow x n) m = pow x (n * m))
val lemma_pow_double: a:int -> b:nat -> Lemma (pow (a * a) b == pow a (b + b))
val lemma_pow_mul_base: a:int -> b:int -> n:nat -> Lemma (pow a n * pow b n == pow (a * b) n)
val lemma_pow_mod_base: a:int -> b:nat -> n:pos -> Lemma (pow a b % n == pow (a % n) b % n)
let nat_mod (m:pos) = n:nat{n < m}
let one_mod (#m:pos) : nat_mod m = 1 % m
let mul_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = a * b % m
let add_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = (a + b) % m
let sub_mod (#m:pos) (a:nat_mod m) (b:nat_mod m) : nat_mod m = (a - b) % m
val lemma_mul_mod_one: #m:pos -> a:nat_mod m -> Lemma (mul_mod a one_mod == a)
val lemma_mul_mod_assoc: #m:pos -> a:nat_mod m -> b:nat_mod m -> c:nat_mod m ->
Lemma (mul_mod (mul_mod a b) c == mul_mod a (mul_mod b c))
val lemma_mul_mod_comm: #m:pos -> a:nat_mod m -> b:nat_mod m ->
Lemma (mul_mod a b == mul_mod b a) | false | false | Lib.NatMod.fsti | {
"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": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_nat_mod_comm_monoid (m: pos) : LE.comm_monoid (nat_mod m) | [] | Lib.NatMod.mk_nat_mod_comm_monoid | {
"file_name": "lib/Lib.NatMod.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Prims.pos -> Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod m) | {
"end_col": 41,
"end_line": 71,
"start_col": 2,
"start_line": 67
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.