file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Spec.Exponentiation.fsti | Spec.Exponentiation.one_st | val one_st : t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type | let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one) | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 55,
"start_col": 0,
"start_line": 52
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.to_comm_monoid",
"Prims.unit",
"Prims.l_True",
"Prims.eq2",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl",
"Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__one",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid"
] | [] | false | false | false | true | true | let one_st (t: Type) (to: to_comm_monoid t) =
| unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) | false |
|
Hacl.EC.K256.fst | Hacl.EC.K256.point_add | val point_add (p q out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\
P.point_inv h p /\ P.point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) | val point_add (p q out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\
P.point_inv h p /\ P.point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) | let point_add p q out =
PA.point_add out p q | {
"file_name": "code/k256/Hacl.EC.K256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 285,
"start_col": 0,
"start_line": 284
} | module Hacl.EC.K256
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module S = Spec.K256
module F = Hacl.K256.Field
module Q = Hacl.K256.Scalar
module FI = Hacl.Impl.K256.Finv
module P = Hacl.Impl.K256.Point
module PA = Hacl.Impl.K256.PointAdd
module PD = Hacl.Impl.K256.PointDouble
module PM = Hacl.Impl.K256.PointMul
module BL = Hacl.Spec.K256.Field52.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@@ CPrologue
"/*******************************************************************************
Verified field arithmetic modulo p = 2^256 - 0x1000003D1.
This is a 64-bit optimized version, where a field element in radix-2^{52} is
represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5].
*******************************************************************************/\n";
Comment "Write the additive identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_zero: f:F.felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero)
let mk_felem_zero f =
Math.Lemmas.small_mod S.zero S.prime;
F.set_zero f
[@@ Comment "Write the multiplicative identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_one: f:F.felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one)
let mk_felem_one f =
Math.Lemmas.small_mod S.one S.prime;
F.set_one f
[@@ Comment "Write `a + b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_add (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b))
let felem_add a b out =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b);
F.fadd out a b;
let h1 = ST.get () in
assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4));
BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out);
F.fnormalize_weak out out
[@@ Comment "Write `a - b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_sub (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b))
let felem_sub a b out =
let h0 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2);
F.fsub out a b (u64 2);
let h1 = ST.get () in
assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6));
BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out);
F.fnormalize_weak out out
[@@ Comment "Write `a * b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_mul (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b))
let felem_mul a b out =
F.fmul out a b
[@@ Comment "Write `a * a mod p` in `out`.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are either disjoint or equal"]
val felem_sqr (a out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h out /\ eq_or_disjoint out a /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a))
let felem_sqr a out =
F.fsqr out a
[@@ Comment "Write `a ^ (p - 2) mod p` in `out`.
The function computes modular multiplicative inverse if `a` <> zero.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_inv (a out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.finv (F.feval h0 a))
let felem_inv a out =
FI.finv out a
[@@ Comment "Load a bid-endian field element from memory.
The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32].
The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `b` and `out` are disjoint"]
val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit
(requires fun h -> live h b /\ live h out /\ disjoint b out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime)
let felem_load b out =
F.load_felem out b
[@@ Comment "Serialize a field element into big-endian memory.
The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5].
The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a))
let felem_store a out =
push_frame ();
let tmp = F.create_felem () in
let h0 = ST.get () in
BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a);
F.fnormalize tmp a;
F.store_felem out tmp;
pop_frame ()
[@@ CPrologue
"/*******************************************************************************
Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7.
This is a 64-bit optimized version, where a group element in projective coordinates
is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15].
*******************************************************************************/\n";
Comment "Write the point at infinity (additive identity) in `p`.
The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."]
val mk_point_at_inf: p:P.point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf)
let mk_point_at_inf p =
P.make_point_at_inf p
[@@ Comment "Write the base point (generator) in `p`.
The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."]
val mk_base_point: p:P.point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
P.point_inv h1 p /\ P.point_eval h1 p == S.g)
let mk_base_point p =
P.make_g p
[@@ Comment "Write `-p` in `out` (point negation).
The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p` and `out` are either disjoint or equal"]
val point_negate (p out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint out p /\
P.point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.point_negate (P.point_eval h0 p))
let point_negate p out =
P.point_negate out p
[@@ Comment "Write `p + q` in `out` (point addition).
The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p`, `q`, and `out` are either pairwise disjoint or equal"]
val point_add (p q out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\
P.point_inv h p /\ P.point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.PointMul.fsti.checked",
"Hacl.Impl.K256.PointDouble.fst.checked",
"Hacl.Impl.K256.PointAdd.fst.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"Hacl.Impl.K256.Finv.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.EC.K256.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointMul",
"short_module": "PM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointDouble",
"short_module": "PD"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointAdd",
"short_module": "PA"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.Point",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.K256.Scalar",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "Hacl.K256.Field",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.K256.Point.point -> q: Hacl.Impl.K256.Point.point -> out: Hacl.Impl.K256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.K256.Point.point",
"Hacl.Impl.K256.PointAdd.point_add",
"Prims.unit"
] | [] | false | true | false | false | false | let point_add p q out =
| PA.point_add out p q | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.sqr_st | val sqr_st : t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type | let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 69,
"start_col": 0,
"start_line": 66
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.to_comm_monoid",
"Prims.l_True",
"Prims.eq2",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl",
"Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid"
] | [] | false | false | false | true | true | let sqr_st (t: Type) (to: to_comm_monoid t) =
| x: t
-> Pure t
(requires True)
(ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) | false |
|
FStar.InteractiveHelpers.Tutorial.fst | FStar.InteractiveHelpers.Tutorial.split_ex1 | val split_ex1 (x y z: nat) : unit | val split_ex1 (x y z: nat) : unit | let split_ex1 (x y z : nat) : unit =
assert( (* <- Try C-c C-e C-s anywhere inside the assert *)
pred1 x y z /\
pred2 x y z /\
pred3 x y z /\
pred4 x y z /\
pred5 x y z /\
pred6 x y z) | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.Tutorial.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 16,
"end_line": 222,
"start_col": 0,
"start_line": 215
} | module FStar.InteractiveHelpers.Tutorial
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers.Tutorial.Definitions
/// WARNING: if a command fails, it is very likely because of the below issue
/// The extended mode requires the FStar.InteractiveHelpers module to run meta-processing
/// functions on the code the user is working on. F* needs to know which modules
/// to load from the very start and won't load additional modules on-demand (you
/// will need to restart the F* mode), which means that if you intend to use the
/// extended mode while working on a file, you have to make sure F* will load
/// FStar.InteractiveHelpers:
module FI = FStar.InteractiveHelpers
/// alternatively if you're not afraid of shadowing:
/// open FStar.InteractiveHelpers
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Basic commands *)
(**** Rolling admit (C-S-r) *)
/// A very common technique used when incrementally working on a proof is the
/// "rolling-admit" technique, which consists in inserting an admit in the
/// a function which doesn't typecheck and moving it around until we
/// identify the exact piece of code which makes verification fail.
/// This technique is made simpler by the [fem-roll-admit command] (C-S-r).
/// Try typing C-S-r anywhere below to insert/move an admit:
let simpl_ex1 (x : nat) =
let y = 4 in
let z = 3 in
let w : w:nat{w >= 10} =
if x > 3 then
begin
assert(y + x > 7);
let x' = x + 1 in
assert(y + x' > 8);
let x'' = 2 * (y + x') in
assert(x'' > 16);
assert(x'' >= 10);
2 * x'
end
else 12
in
assert(
x >= 0 /\
y >= 0);
let w' = 2 * w + z in
w'
(**** Switch between asserts/assumes (C-S-s) *)
/// People often write functions and proofs incrementally, by keeping an admit
/// at the very end and adding function calls or assertions one at a time,
/// type-checking with F* at every code change to make sure that it is legal.
/// However, when such functions or proofs become long, whenever we query F*,
/// it takes a lot of time to recheck all the already known-to-succeed proof
/// obligations, before getting to the new (interesting) ones. A common way of
/// mitigating this problem is to convert the assertions to assumptions once we
/// know they succeed.
/// Try calling fem-switch-assert-assume (C-S-s) in the below function.
/// Note that it operates either on the assertion under the pointer, or on the
/// current selection.
let simpl_ex2 (x : nat) =
let x1 = x + 1 in
assert(x1 = x + 1);
let x2 = 3 * (x1 + 1) in
assert_norm(237 * 486 = 115182);
assert(x2 = 3 * (x + 2));
assert(x2 % 3 = 0);
assert_norm(8 * 4 < 40);
let x3 = 2 * x2 + 6 in
assert(x3 = 6 * (x + 2) + 6);
let assertion = True in
assert(x3 = 6 * (x + 3));
assert(x3 % 3 = 0);
x3
(*** Advanced commands *)
(**** Insert context/proof obligations information *)
(**** C-c C-e C-e *)
/// If often happens that we want to know what the precondition which fails at
/// some specific place is exactly, or if, once instantiated, what the postcondition
/// of some lemma is indeed what we believe it is, because it fails to prove some
/// obligation for example, etc. In other words: we sometimes feel blind when
/// working in F*, and the workarounds (mostly copy-pasting and instantiating by hand
/// the relevant pre/postconditions) are often painful.
/// The effectful term analysis command (C-c C-e C-e) addresses this issue.
/// Try testing the fem-insert-pre-post command on the let-bindings and the return result
let ci_ex1 (x y : nat) : z:int{z % 3 = 0} =
(* Preconditions:
* Type C-c C-e C-e below to insert:
* [> assert(x + 4 > 3); *)
let x1 = f1 (x + 4) y in (* <- Put your pointer after the 'in' and type C-c C-e C-e *)
(* Postconditions: *)
let x2 = f2 x1 y in (* <- Put your pointer after the 'in' and type C-c C-e C-e *)
(* Type C-c C-e C-e above to insert:
* [> assert(has_type x2 nat);
* [> assert(x2 >= 8);
* [> assert(x2 % 2 = 0); *)
(* Typing obligations:
* Type C-c C-e C-e below to insert:
* [> assert(Prims.has_type (x2 <: Prims.nat) Prims.int);
* [> assert(x2 % 2 = 0);
* Note that the assertion gives indications about the parameter
* known type, the target type and the (potential) refinement.
* Also note that the type obligations are not introduced when
* they are trivial (if the original type and the target type are
* exactly the same, syntactically).
* WARNING: `has_type` is very low level and shouldn't be used in user proofs.
* In the future, we intend to remove the assertions containing `has_type`,
* and only introduce assertions for the refinements.
*)
let x3 = f4 x2 in (* <- Put your pointer on the left and type C-c C-e C-e *)
(* Current goal:
* Type C-c C-e C-e below to insert:
* [> assert(Prims.has_type (3 * (x1 + x2 + x3)) Prims.int);
* [> assert(3 * (x1 + x2 + x3) % 3 = 0); *)
3 * (x1 + x2 + x3) (* <- Put your pointer on the left and type C-c C-e C-e *)
/// Note that you can use the "--print_implicits" option to adjust the output.
/// Some proof obligations indeed sometimes fail while the user is certain to
/// have the appropriate hypothesis in his context, because F* did not infer the
/// same implicits for the proof obligation and the proposition, a problem the user
/// often doesn't see. Debugging such issues can be a nightmare.
#push-options "--print_implicits"
let ci_ex1_ (x : nat) : unit =
let y = x in
assert(x == y); (* <- Use C-c C-e C-e here *)
()
#pop-options
/// You may need to know the "global" assumptions. In order to get those,
/// put the pointer close enough to the beginning of the function and type `C-c C-e C-g`
let ci_ex2 (x : nat{x % 2 = 0}) (y : int{y % 3 = 0 /\ x + y % 5 = 0}) :
Pure int
(requires (x + y >= 0))
(ensures (fun z -> z >= 0)) =
(* [> assert(Prims.has_type x Prims.nat); *)
(* [> assert(x % 2 = 0); *)
(* [> assert(Prims.has_type y Prims.int); *)
(* [> assert(y % 3 = 0 /\ x + y % 5 = 0); *)
(* [> assert(x + y >= 0); *)
let z = x + y in
z
/// Those commands also work on effectful terms. They may need to
/// introduce variables in the context. For instance, when dealing with pres/posts
/// of stateful terms, it will look for state variables with which to instantiate
/// those pre/posts, but might not be able to find suitable variables.
/// In this case, it introduces fresh variables (easy to recognize because they are
/// preceded by "__") and abstracts them away, to indicate the user that he needs
/// to provide those variables.
///
/// It leads to assertions of the form:
/// [> assert((fun __x0 __x1 -> pred __x0 __x1) __x0 __x1)
///
/// As (C-c C-e C-e) performs simple normalization (to remove abstractions,
/// for instance) on the terms it manipulates, you can manually rewrite this
/// assert to:
/// [> assert((fun __x0 __x1 -> pred __x0 __x1) x y)
///
/// then apply (C-c C-e C-e) on the above assertion to get:
/// [> assert(pred x y)
///
/// Try this on the stateful calls in the below function:
let ci_ex3 (r1 r2 : B.buffer int) :
ST.Stack int (requires (fun _ -> True)) (ensures (fun _ _ _ -> True)) =
(**) let h0 = ST.get () in
let n1 = sf1 r1 in (* <- Try C-c C-e C-e here *)
(* [> assert(
[> (fun __h1_0 ->
[> LowStar.Monotonic.Buffer.live h0 r1 /\
[> LowStar.Monotonic.Buffer.as_seq h0 r1 == LowStar.Monotonic.Buffer.as_seq __h1_0 r1 /\
[> n1 =
[> FStar.List.Tot.Base.fold_left (fun x y -> x + y)
[> 0
[> (FStar.Seq.Properties.seq_to_list (LowStar.Monotonic.Buffer.as_seq h0 r1))) __h1_0); *)
(**) let h1 = ST.get () in
let n2 = sf1 r2 in
(**) let h2 = ST.get () in
n1 + n2
/// It may happen that the command needs to introduce assertions using variables
/// which are shadowed at that point. In this case, it "abstracts" them, like what
/// is done in the previous example. This way, the user still has an assertion
/// he can investigate, and where the problematic variables are clearly indicated
/// if he wants to work with it.
let ci_ex4 (x : int{x % 2 = 0}) :
Pure int
(requires True)
(ensures (fun x' -> x' % 2 = 0 /\ x' >= x)) =
let x = x + 4 in (* We shadow the original ``x`` here *)
x (* <- Try C-c C-e C-e here *)
(**** Split conjunctions *)
/// Proof obligations are often written in the form of big conjunctions, and
/// F* may not always be precise enough to indicate which part of the conjunction
/// fails. The user then often has to "split" the conjunctions by hand, by
/// introducing one assertion per conjunct.
/// The fem-split-assert-assume-conjuncts command (C-c C-e C-s) automates the process. | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Tutorial.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.InteractiveHelpers",
"short_module": "FI"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.nat -> y: Prims.nat -> z: Prims.nat -> Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims._assert",
"Prims.l_and",
"FStar.InteractiveHelpers.Tutorial.Definitions.pred1",
"FStar.InteractiveHelpers.Tutorial.Definitions.pred2",
"FStar.InteractiveHelpers.Tutorial.Definitions.pred3",
"FStar.InteractiveHelpers.Tutorial.Definitions.pred4",
"FStar.InteractiveHelpers.Tutorial.Definitions.pred5",
"FStar.InteractiveHelpers.Tutorial.Definitions.pred6",
"Prims.unit"
] | [] | false | false | false | true | false | let split_ex1 (x y z: nat) : unit =
| assert (pred1 x y z /\ pred2 x y z /\ pred3 x y z /\ pred4 x y z /\ pred5 x y z /\ pred6 x y z) | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.mul_st | val mul_st : t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type | let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 62,
"start_col": 0,
"start_line": 59
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.to_comm_monoid",
"Prims.l_True",
"Prims.eq2",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl",
"Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid"
] | [] | false | false | false | true | true | let mul_st (t: Type) (to: to_comm_monoid t) =
| x: t -> y: t
-> Pure t
(requires True)
(ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) | false |
|
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_rl | val exp_rl (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t | val exp_rl (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t | let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 93,
"start_col": 0,
"start_line": 90
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
a: t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits}
-> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Pervasives.Native.tuple2",
"Lib.LoopCombinators.repeati",
"Spec.Exponentiation.exp_rl_f",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__one"
] | [] | false | false | false | false | false | let exp_rl (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t =
| let one = k.one () in
let acc, c = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_mont_ladder_swap | val exp_mont_ladder_swap (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits})
: t | val exp_mont_ladder_swap (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits})
: t | let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let (r0, r1) = S.cswap sw r0 r1 in
r0 | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 114,
"start_col": 0,
"start_line": 111
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b)
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
a: t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits}
-> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Pervasives.Native.tuple2",
"Lib.Exponentiation.cswap",
"FStar.Pervasives.Native.tuple3",
"Lib.LoopCombinators.repeati",
"Spec.Exponentiation.exp_mont_ladder_swap_f",
"FStar.Pervasives.Native.Mktuple3",
"Spec.Exponentiation.one"
] | [] | false | false | false | false | false | let exp_mont_ladder_swap (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits})
: t =
| let r0, r1, sw = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let r0, r1 = S.cswap sw r0 r1 in
r0 | false |
Hacl.Impl.Frodo.KEM.Decaps.fst | Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec1 | val crypto_kem_dec1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
live h bp_matrix /\ live h c_matrix /\
loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | val crypto_kem_dec1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
live h bp_matrix /\ live h c_matrix /\
loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | let crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix =
push_frame ();
let mu_decode = create (bytes_mu a) (u8 0) in
crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode;
clear_words_u8 mu_decode;
pop_frame () | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 382,
"start_col": 0,
"start_line": 377
} | module Hacl.Impl.Frodo.KEM.Decaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.KEM.Encaps
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module FP = Spec.Frodo.Params
module KG = Hacl.Impl.Frodo.KEM.KeyGen
module S = Spec.Frodo.KEM.Decaps
module M = Spec.Matrix
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val get_bp_c_matrices:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ct /\ live h bp_matrix /\ live h c_matrix /\
disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\
(as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct))
let get_bp_c_matrices a ct bp_matrix c_matrix =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix;
frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix
inline_for_extraction noextract
val frodo_mu_decode:
a:FP.frodo_alg
-> s_bytes:lbytes (secretmatrixbytes_len a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h s_bytes /\ live h bp_matrix /\
live h c_matrix /\ live h mu_decode /\
disjoint mu_decode s_bytes /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0))
(ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\
as_seq h1 mu_decode ==
S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode =
push_frame();
let s_matrix = matrix_create (params_n a) params_nbar in
let m_matrix = matrix_create params_nbar params_nbar in
matrix_from_lbytes s_bytes s_matrix;
matrix_mul_s bp_matrix s_matrix m_matrix;
matrix_sub c_matrix m_matrix;
frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode;
clear_matrix s_matrix;
clear_matrix m_matrix;
pop_frame()
inline_for_extraction noextract
val get_bpp_cp_matrices_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix;
loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk)
(as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix))
let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix =
FP.expand_crypto_secretkeybytes a;
FP.expand_crypto_publickeybytes a;
let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix;
frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix;
mod_pow2 (params_logq a) bpp_matrix;
mod_pow2 (params_logq a) cp_matrix
#push-options "--z3rlimit 150"
inline_for_extraction noextract
val get_bpp_cp_matrices:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk))
let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix =
push_frame ();
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_dec_kp_s_cond:
a:FP.frodo_alg
-> bp_matrix:matrix_t params_nbar (params_n a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h bp_matrix /\ live h bpp_matrix /\
live h c_matrix /\ live h cp_matrix)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix)
(as_matrix h0 c_matrix) (as_matrix h0 cp_matrix))
let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix =
let b1 = matrix_eq bp_matrix bpp_matrix in
let b2 = matrix_eq c_matrix cp_matrix in
b1 &. b2
inline_for_extraction noextract
val crypto_kem_dec_kp_s:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se /\
live h c_matrix /\ live h sk /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk])
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix =
push_frame ();
let bpp_matrix = matrix_create params_nbar (params_n a) in
let cp_matrix = matrix_create params_nbar params_nbar in
get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix;
let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in
pop_frame ();
mask
inline_for_extraction noextract
val crypto_kem_dec_ss0:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)}
-> kp:lbytes (crypto_bytes a)
-> s:lbytes (crypto_bytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h kp /\ live h s /\ live h ss /\
disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\
disjoint kp s)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s))
let crypto_kem_dec_ss0 a ct mask kp s ss =
push_frame ();
let kp_s = create (crypto_bytes a) (u8 0) in
Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s;
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let ss_init = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init;
frodo_shake a ss_init_len ss_init (crypto_bytes a) ss;
clear_words_u8 ss_init;
clear_words_u8 kp_s;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_seed_se_k:
a:FP.frodo_alg
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\ live h seed_se_k /\
disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk))
let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k =
push_frame ();
let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in
let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in
let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in
concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode;
frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_ss1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
let s = sub sk 0ul (crypto_bytes a) in
let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in
crypto_kem_dec_ss0 a ct mask kp s ss
inline_for_extraction noextract
val crypto_kem_dec_ss2:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss =
push_frame ();
let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in
crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k;
crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss;
clear_words_u8 seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_mu:
a:FP.frodo_alg
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h sk /\ live h mu_decode /\
live h bp_matrix /\ live h c_matrix /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\
loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix])
(ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\
as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk)
(as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode =
FP.expand_crypto_secretkeybytes a;
let s_bytes = sub sk (crypto_bytes a +! crypto_publickeybytes a) (secretmatrixbytes_len a) in
frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode
inline_for_extraction noextract
val crypto_kem_dec0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\ live h mu_decode /\
live h bp_matrix /\ live h c_matrix /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\
loc_pairwise_disjoint [loc ss; loc ct; loc sk;
loc mu_decode; loc bp_matrix; loc c_matrix])
(ensures fun h0 _ h1 -> modifies (loc ss |+| loc mu_decode) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode =
crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode;
crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss
inline_for_extraction noextract
val crypto_kem_dec1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
live h bp_matrix /\ live h c_matrix /\
loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Decaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Decaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM.Encaps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) ->
bp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
c_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.clear_words_u8",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec0",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.create",
"Lib.IntTypes.uint8",
"Lib.IntTypes.u8",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix =
| push_frame ();
let mu_decode = create (bytes_mu a) (u8 0) in
crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode;
clear_words_u8 mu_decode;
pop_frame () | false |
Hacl.EC.K256.fst | Hacl.EC.K256.is_point_valid | val is_point_valid: b:lbuffer uint8 64ul -> Stack bool
(requires fun h -> live h b)
(ensures fun h0 res h1 -> modifies0 h0 h1 /\
res <==> (S.point_inv_bytes (as_seq h0 b))) | val is_point_valid: b:lbuffer uint8 64ul -> Stack bool
(requires fun h -> live h b)
(ensures fun h0 res h1 -> modifies0 h0 h1 /\
res <==> (S.point_inv_bytes (as_seq h0 b))) | let is_point_valid b =
push_frame ();
let p = P.create_aff_point () in
let res = P.aff_point_load_vartime p b in
pop_frame ();
res | {
"file_name": "code/k256/Hacl.EC.K256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 400,
"start_col": 0,
"start_line": 395
} | module Hacl.EC.K256
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module S = Spec.K256
module F = Hacl.K256.Field
module Q = Hacl.K256.Scalar
module FI = Hacl.Impl.K256.Finv
module P = Hacl.Impl.K256.Point
module PA = Hacl.Impl.K256.PointAdd
module PD = Hacl.Impl.K256.PointDouble
module PM = Hacl.Impl.K256.PointMul
module BL = Hacl.Spec.K256.Field52.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@@ CPrologue
"/*******************************************************************************
Verified field arithmetic modulo p = 2^256 - 0x1000003D1.
This is a 64-bit optimized version, where a field element in radix-2^{52} is
represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5].
*******************************************************************************/\n";
Comment "Write the additive identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_zero: f:F.felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero)
let mk_felem_zero f =
Math.Lemmas.small_mod S.zero S.prime;
F.set_zero f
[@@ Comment "Write the multiplicative identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_one: f:F.felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one)
let mk_felem_one f =
Math.Lemmas.small_mod S.one S.prime;
F.set_one f
[@@ Comment "Write `a + b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_add (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b))
let felem_add a b out =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b);
F.fadd out a b;
let h1 = ST.get () in
assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4));
BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out);
F.fnormalize_weak out out
[@@ Comment "Write `a - b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_sub (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b))
let felem_sub a b out =
let h0 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2);
F.fsub out a b (u64 2);
let h1 = ST.get () in
assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6));
BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out);
F.fnormalize_weak out out
[@@ Comment "Write `a * b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_mul (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b))
let felem_mul a b out =
F.fmul out a b
[@@ Comment "Write `a * a mod p` in `out`.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are either disjoint or equal"]
val felem_sqr (a out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h out /\ eq_or_disjoint out a /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a))
let felem_sqr a out =
F.fsqr out a
[@@ Comment "Write `a ^ (p - 2) mod p` in `out`.
The function computes modular multiplicative inverse if `a` <> zero.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_inv (a out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.finv (F.feval h0 a))
let felem_inv a out =
FI.finv out a
[@@ Comment "Load a bid-endian field element from memory.
The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32].
The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `b` and `out` are disjoint"]
val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit
(requires fun h -> live h b /\ live h out /\ disjoint b out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime)
let felem_load b out =
F.load_felem out b
[@@ Comment "Serialize a field element into big-endian memory.
The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5].
The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a))
let felem_store a out =
push_frame ();
let tmp = F.create_felem () in
let h0 = ST.get () in
BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a);
F.fnormalize tmp a;
F.store_felem out tmp;
pop_frame ()
[@@ CPrologue
"/*******************************************************************************
Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7.
This is a 64-bit optimized version, where a group element in projective coordinates
is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15].
*******************************************************************************/\n";
Comment "Write the point at infinity (additive identity) in `p`.
The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."]
val mk_point_at_inf: p:P.point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf)
let mk_point_at_inf p =
P.make_point_at_inf p
[@@ Comment "Write the base point (generator) in `p`.
The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."]
val mk_base_point: p:P.point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
P.point_inv h1 p /\ P.point_eval h1 p == S.g)
let mk_base_point p =
P.make_g p
[@@ Comment "Write `-p` in `out` (point negation).
The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p` and `out` are either disjoint or equal"]
val point_negate (p out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint out p /\
P.point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.point_negate (P.point_eval h0 p))
let point_negate p out =
P.point_negate out p
[@@ Comment "Write `p + q` in `out` (point addition).
The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p`, `q`, and `out` are either pairwise disjoint or equal"]
val point_add (p q out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\
P.point_inv h p /\ P.point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q))
let point_add p q out =
PA.point_add out p q
[@@ Comment "Write `p + p` in `out` (point doubling).
The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p` and `out` are either disjoint or equal"]
val point_double (p out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint p out /\
P.point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p))
let point_double p out =
PD.point_double out p
[@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication).
The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32].
The function first loads a bid-endian scalar element from `scalar` and
then computes a point multiplication.
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `scalar`, `p`, and `out` are pairwise disjoint"]
val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit
(requires fun h ->
live h scalar /\ live h p /\ live h out /\
disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\
P.point_inv h p /\
BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
S.to_aff_point (P.point_eval h1 out) ==
S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p)))
let point_mul scalar p out =
push_frame ();
let scalar_q = Q.create_qelem () in
Q.load_qelem scalar_q scalar;
PM.point_mul out scalar_q p;
pop_frame ()
[@@ Comment "Convert a point from projective coordinates to its raw form.
The argument `p` points to a point of 15 limbs in size, i.e., uint64_t[15].
The outparam `out` points to 64 bytes of valid memory, i.e., uint8_t[64].
The function first converts a given point `p` from projective to affine coordinates
and then writes [ `x`; `y` ] in `out`.
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p` and `out` are disjoint."]
val point_store: p:P.point -> out:lbuffer uint8 64ul -> Stack unit
(requires fun h ->
live h out /\ live h p /\ disjoint p out /\
P.point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == S.point_store (P.point_eval h0 p))
let point_store p out =
P.point_store out p
[@@ Comment "Convert a point to projective coordinates from its raw form.
The argument `b` points to 64 bytes of valid memory, i.e., uint8_t[64].
The outparam `out` points to a point of 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `b` is valid point, i.e., x < prime and y < prime and (x, y) is on the curve
• `b` and `out` are disjoint."]
val point_load: b:lbuffer uint8 64ul -> out:P.point -> Stack unit
(requires fun h ->
live h out /\ live h b /\ disjoint b out /\
S.point_inv_bytes (as_seq h b))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.load_point_nocheck (as_seq h0 b))
let point_load b out =
P.load_point_nocheck out b
[@@ Comment "Check whether a point is valid.
The function returns `true` if a point is valid and `false` otherwise.
The argument `b` points to 64 bytes of valid memory, i.e., uint8_t[64].
The point (x || y) is valid:
• x < prime and y < prime
• (x, y) is on the curve.
This function is NOT constant-time."]
val is_point_valid: b:lbuffer uint8 64ul -> Stack bool
(requires fun h -> live h b)
(ensures fun h0 res h1 -> modifies0 h0 h1 /\
res <==> (S.point_inv_bytes (as_seq h0 b))) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.PointMul.fsti.checked",
"Hacl.Impl.K256.PointDouble.fst.checked",
"Hacl.Impl.K256.PointAdd.fst.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"Hacl.Impl.K256.Finv.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.EC.K256.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointMul",
"short_module": "PM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointDouble",
"short_module": "PD"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointAdd",
"short_module": "PA"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.Point",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.K256.Scalar",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "Hacl.K256.Field",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Impl.K256.Point.aff_point_load_vartime",
"Hacl.Impl.K256.Point.aff_point",
"Hacl.Impl.K256.Point.create_aff_point",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let is_point_valid b =
| push_frame ();
let p = P.create_aff_point () in
let res = P.aff_point_load_vartime p b in
pop_frame ();
res | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_rl_f | val exp_rl_f : k: Spec.Exponentiation.concrete_ops t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits} ->
i: Prims.nat{i < bBits} ->
_: (t * t)
-> t * t | let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c) | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 10,
"end_line": 87,
"start_col": 0,
"start_line": 81
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits} ->
i: Prims.nat{i < bBits} ->
_: (t * t)
-> t * t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__sqr",
"Prims.op_Equality",
"Prims.int",
"Lib.Exponentiation.get_ith_bit",
"Prims.bool",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul"
] | [] | false | false | false | false | false | let exp_rl_f
(#t: Type)
(k: concrete_ops t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(i: nat{i < bBits})
(acc, c: tuple2 t t)
: tuple2 t t =
| let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c) | false |
|
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_pow2 | val exp_pow2 (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t | val exp_pow2 (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t | let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
Loops.repeat b k.sqr a | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 24,
"end_line": 122,
"start_col": 0,
"start_line": 121
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b)
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit)
let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let (r0, r1) = S.cswap sw r0 r1 in
r0
val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Spec.Exponentiation.concrete_ops t -> a: t -> b: Prims.nat -> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Lib.LoopCombinators.repeat",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__sqr"
] | [] | false | false | false | true | false | let exp_pow2 (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t =
| Loops.repeat b k.sqr a | false |
Hacl.EC.K256.fst | Hacl.EC.K256.felem_store | val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) | val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) | let felem_store a out =
push_frame ();
let tmp = F.create_felem () in
let h0 = ST.get () in
BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a);
F.fnormalize tmp a;
F.store_felem out tmp;
pop_frame () | {
"file_name": "code/k256/Hacl.EC.K256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 214,
"start_col": 0,
"start_line": 207
} | module Hacl.EC.K256
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module S = Spec.K256
module F = Hacl.K256.Field
module Q = Hacl.K256.Scalar
module FI = Hacl.Impl.K256.Finv
module P = Hacl.Impl.K256.Point
module PA = Hacl.Impl.K256.PointAdd
module PD = Hacl.Impl.K256.PointDouble
module PM = Hacl.Impl.K256.PointMul
module BL = Hacl.Spec.K256.Field52.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@@ CPrologue
"/*******************************************************************************
Verified field arithmetic modulo p = 2^256 - 0x1000003D1.
This is a 64-bit optimized version, where a field element in radix-2^{52} is
represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5].
*******************************************************************************/\n";
Comment "Write the additive identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_zero: f:F.felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero)
let mk_felem_zero f =
Math.Lemmas.small_mod S.zero S.prime;
F.set_zero f
[@@ Comment "Write the multiplicative identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_one: f:F.felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one)
let mk_felem_one f =
Math.Lemmas.small_mod S.one S.prime;
F.set_one f
[@@ Comment "Write `a + b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_add (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b))
let felem_add a b out =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b);
F.fadd out a b;
let h1 = ST.get () in
assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4));
BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out);
F.fnormalize_weak out out
[@@ Comment "Write `a - b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_sub (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b))
let felem_sub a b out =
let h0 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2);
F.fsub out a b (u64 2);
let h1 = ST.get () in
assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6));
BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out);
F.fnormalize_weak out out
[@@ Comment "Write `a * b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_mul (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b))
let felem_mul a b out =
F.fmul out a b
[@@ Comment "Write `a * a mod p` in `out`.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are either disjoint or equal"]
val felem_sqr (a out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h out /\ eq_or_disjoint out a /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a))
let felem_sqr a out =
F.fsqr out a
[@@ Comment "Write `a ^ (p - 2) mod p` in `out`.
The function computes modular multiplicative inverse if `a` <> zero.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_inv (a out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.finv (F.feval h0 a))
let felem_inv a out =
FI.finv out a
[@@ Comment "Load a bid-endian field element from memory.
The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32].
The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `b` and `out` are disjoint"]
val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit
(requires fun h -> live h b /\ live h out /\ disjoint b out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime)
let felem_load b out =
F.load_felem out b
[@@ Comment "Serialize a field element into big-endian memory.
The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5].
The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.PointMul.fsti.checked",
"Hacl.Impl.K256.PointDouble.fst.checked",
"Hacl.Impl.K256.PointAdd.fst.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"Hacl.Impl.K256.Finv.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.EC.K256.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointMul",
"short_module": "PM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointDouble",
"short_module": "PD"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointAdd",
"short_module": "PA"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.Point",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.K256.Scalar",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "Hacl.K256.Field",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Hacl.K256.Field.felem -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.K256.Field.store_felem",
"Hacl.K256.Field.fnormalize",
"Hacl.Spec.K256.Field52.Lemmas.normalize5_lemma",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Hacl.K256.Field.as_felem5",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let felem_store a out =
| push_frame ();
let tmp = F.create_felem () in
let h0 = ST.get () in
BL.normalize5_lemma (1, 1, 1, 1, 2) (F.as_felem5 h0 a);
F.fnormalize tmp a;
F.store_felem out tmp;
pop_frame () | false |
OPLSS.MAC.fst | OPLSS.MAC.loc | val loc : k: OPLSS.MAC.key -> Prims.GTot LowStar.Monotonic.Buffer.loc | let loc (k:key) = B.loc_mreference k.log | {
"file_name": "examples/crypto/OPLSS.MAC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 36,
"start_col": 0,
"start_line": 36
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module OPLSS.MAC
(* This module idealizes HMACSHA1 as an UF-CMA MAC *)
open OPLSS
open FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module HS = FStar.HyperStack
/// The UF-CMA log associates messages with tags
type log_entry =
| Entry: msg:HMACSHA1.msg
-> tag:HMACSHA1.tag
-> log_entry
/// A key packages a raw HMACSHA1 key with the ideal UF-CMA log
noeq
type key =
| Key: raw:HMACSHA1.sha1_key
-> log:Log.t log_entry
-> key | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"OPLSS.Log.fst.checked",
"OPLSS.Ideal.fsti.checked",
"OPLSS.HMACSHA1.fst.checked",
"OPLSS.Flag.fsti.checked",
"OPLSS.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "OPLSS.MAC.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: OPLSS.MAC.key -> Prims.GTot LowStar.Monotonic.Buffer.loc | Prims.GTot | [
"sometrivial"
] | [] | [
"OPLSS.MAC.key",
"LowStar.Monotonic.Buffer.loc_mreference",
"FStar.Seq.Base.seq",
"OPLSS.MAC.log_entry",
"OPLSS.Log.grows",
"OPLSS.MAC.__proj__Key__item__log",
"LowStar.Monotonic.Buffer.loc"
] | [] | false | false | false | false | false | let loc (k: key) =
| B.loc_mreference k.log | false |
|
Hacl.Impl.Frodo.KEM.Decaps.fst | Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss1 | val crypto_kem_dec_ss1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | val crypto_kem_dec_ss1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
let s = sub sk 0ul (crypto_bytes a) in
let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in
crypto_kem_dec_ss0 a ct mask kp s ss | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 278,
"start_col": 0,
"start_line": 272
} | module Hacl.Impl.Frodo.KEM.Decaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.KEM.Encaps
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module FP = Spec.Frodo.Params
module KG = Hacl.Impl.Frodo.KEM.KeyGen
module S = Spec.Frodo.KEM.Decaps
module M = Spec.Matrix
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val get_bp_c_matrices:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ct /\ live h bp_matrix /\ live h c_matrix /\
disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\
(as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct))
let get_bp_c_matrices a ct bp_matrix c_matrix =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix;
frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix
inline_for_extraction noextract
val frodo_mu_decode:
a:FP.frodo_alg
-> s_bytes:lbytes (secretmatrixbytes_len a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h s_bytes /\ live h bp_matrix /\
live h c_matrix /\ live h mu_decode /\
disjoint mu_decode s_bytes /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0))
(ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\
as_seq h1 mu_decode ==
S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode =
push_frame();
let s_matrix = matrix_create (params_n a) params_nbar in
let m_matrix = matrix_create params_nbar params_nbar in
matrix_from_lbytes s_bytes s_matrix;
matrix_mul_s bp_matrix s_matrix m_matrix;
matrix_sub c_matrix m_matrix;
frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode;
clear_matrix s_matrix;
clear_matrix m_matrix;
pop_frame()
inline_for_extraction noextract
val get_bpp_cp_matrices_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix;
loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk)
(as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix))
let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix =
FP.expand_crypto_secretkeybytes a;
FP.expand_crypto_publickeybytes a;
let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix;
frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix;
mod_pow2 (params_logq a) bpp_matrix;
mod_pow2 (params_logq a) cp_matrix
#push-options "--z3rlimit 150"
inline_for_extraction noextract
val get_bpp_cp_matrices:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk))
let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix =
push_frame ();
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_dec_kp_s_cond:
a:FP.frodo_alg
-> bp_matrix:matrix_t params_nbar (params_n a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h bp_matrix /\ live h bpp_matrix /\
live h c_matrix /\ live h cp_matrix)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix)
(as_matrix h0 c_matrix) (as_matrix h0 cp_matrix))
let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix =
let b1 = matrix_eq bp_matrix bpp_matrix in
let b2 = matrix_eq c_matrix cp_matrix in
b1 &. b2
inline_for_extraction noextract
val crypto_kem_dec_kp_s:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se /\
live h c_matrix /\ live h sk /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk])
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix =
push_frame ();
let bpp_matrix = matrix_create params_nbar (params_n a) in
let cp_matrix = matrix_create params_nbar params_nbar in
get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix;
let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in
pop_frame ();
mask
inline_for_extraction noextract
val crypto_kem_dec_ss0:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)}
-> kp:lbytes (crypto_bytes a)
-> s:lbytes (crypto_bytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h kp /\ live h s /\ live h ss /\
disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\
disjoint kp s)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s))
let crypto_kem_dec_ss0 a ct mask kp s ss =
push_frame ();
let kp_s = create (crypto_bytes a) (u8 0) in
Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s;
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let ss_init = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init;
frodo_shake a ss_init_len ss_init (crypto_bytes a) ss;
clear_words_u8 ss_init;
clear_words_u8 kp_s;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_seed_se_k:
a:FP.frodo_alg
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\ live h seed_se_k /\
disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk))
let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k =
push_frame ();
let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in
let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in
let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in
concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode;
frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_ss1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Decaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Decaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM.Encaps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) ->
mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
seed_se_k: Hacl.Impl.Matrix.lbytes (2ul *! Hacl.Impl.Frodo.Params.crypto_bytes a) ->
bp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
c_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss0",
"Prims.unit",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_kp_s",
"Lib.IntTypes.uint16",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.Buffer.sub",
"Lib.IntTypes.uint8"
] | [] | false | true | false | false | false | let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss =
| let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
let s = sub sk 0ul (crypto_bytes a) in
let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in
crypto_kem_dec_ss0 a ct mask kp s ss | false |
Hacl.Spec.Bignum.ModInv.fst | Hacl.Spec.Bignum.ModInv.bn_check_mod_inv_prime | val bn_check_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> a:lbignum t len ->
res:limb t{
let b =
bn_v n % 2 = 1 && 1 < bn_v n &&
0 < bn_v a && bn_v a < bn_v n in
v res == (if b then v (ones t SEC) else v (zeros t SEC))} | val bn_check_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> a:lbignum t len ->
res:limb t{
let b =
bn_v n % 2 = 1 && 1 < bn_v n &&
0 < bn_v a && bn_v a < bn_v n in
v res == (if b then v (ones t SEC) else v (zeros t SEC))} | let bn_check_mod_inv_prime #t #len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask a in
BN.bn_is_zero_mask_lemma a;
let m1' = lognot m1 in
lognot_lemma m1;
let m2 = BN.bn_lt_mask a n in
BN.bn_lt_mask_lemma a n;
logand_ones (m0 &. m1');
logand_zeros (m0 &. m1');
logand_ones m0;
logand_zeros m0;
m0 &. m1' &. m2 | {
"file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 74,
"start_col": 0,
"start_line": 62
} | module Hacl.Spec.Bignum.ModInv
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.LoopCombinators
open Hacl.Spec.Bignum.Definitions
open Hacl.Spec.Bignum
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module BE = Hacl.Spec.Bignum.Exponentiation
module BM = Hacl.Spec.Bignum.Montgomery
module BN = Hacl.Spec.Bignum
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
#push-options "--fuel 1"
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
let rec pow_eq a n =
if n = 0 then ()
else pow_eq a (n - 1)
#pop-options
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} ->
Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1)
let mod_inv_prime_lemma n a =
Math.Lemmas.small_mod a n;
assert (a == a % n);
assert (a <> 0 /\ a % n <> 0);
calc (==) {
Lib.NatMod.pow_mod #n a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) }
Lib.NatMod.pow a (n - 2) % n * a % n;
(==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n }
Lib.NatMod.pow a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 }
Lib.NatMod.pow a (n - 1) % n;
(==) { pow_eq a (n - 1) }
Fermat.pow a (n - 1) % n;
(==) { Fermat.fermat_alt n a }
1;
}
//pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked
val bn_check_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> a:lbignum t len ->
res:limb t{
let b =
bn_v n % 2 = 1 && 1 < bn_v n &&
0 < bn_v a && bn_v a < bn_v n in
v res == (if b then v (ones t SEC) else v (zeros t SEC))} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.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",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len
-> res:
Hacl.Spec.Bignum.Definitions.limb t
{ let b =
Hacl.Spec.Bignum.Definitions.bn_v n % 2 = 1 && 1 < Hacl.Spec.Bignum.Definitions.bn_v n &&
0 < Hacl.Spec.Bignum.Definitions.bn_v a &&
Hacl.Spec.Bignum.Definitions.bn_v a < Hacl.Spec.Bignum.Definitions.bn_v n
in
Lib.IntTypes.v res ==
(match b with
| true -> Lib.IntTypes.v (Lib.IntTypes.ones t Lib.IntTypes.SEC)
| _ -> Lib.IntTypes.v (Lib.IntTypes.zeros t Lib.IntTypes.SEC)) } | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.SEC",
"Prims.unit",
"Lib.IntTypes.logand_zeros",
"Lib.IntTypes.logand_ones",
"Hacl.Spec.Bignum.bn_lt_mask_lemma",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.bn_lt_mask",
"Lib.IntTypes.lognot_lemma",
"Lib.IntTypes.int_t",
"Lib.IntTypes.lognot",
"Hacl.Spec.Bignum.bn_is_zero_mask_lemma",
"Hacl.Spec.Bignum.bn_is_zero_mask",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"Prims.op_Modulus",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_LessThan",
"Lib.IntTypes.ones",
"Prims.bool",
"Lib.IntTypes.zeros",
"Hacl.Spec.Bignum.Montgomery.bn_check_modulus",
"Lib.IntTypes.range_t"
] | [] | false | false | false | false | false | let bn_check_mod_inv_prime #t #len n a =
| let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask a in
BN.bn_is_zero_mask_lemma a;
let m1' = lognot m1 in
lognot_lemma m1;
let m2 = BN.bn_lt_mask a n in
BN.bn_lt_mask_lemma a n;
logand_ones (m0 &. m1');
logand_zeros (m0 &. m1');
logand_ones m0;
logand_zeros m0;
m0 &. m1' &. m2 | false |
Hacl.Spec.Bignum.ModInv.fst | Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_pre | val bn_mod_inv_prime_pre : n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len
-> Prims.logical | let bn_mod_inv_prime_pre
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(a:lbignum t len)
=
bn_v n % 2 = 1 /\ 1 < bn_v n /\
0 < bn_v a /\ bn_v a < bn_v n /\
Euclid.is_prime (bn_v n) | {
"file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 105,
"start_col": 0,
"start_line": 97
} | module Hacl.Spec.Bignum.ModInv
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.LoopCombinators
open Hacl.Spec.Bignum.Definitions
open Hacl.Spec.Bignum
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module BE = Hacl.Spec.Bignum.Exponentiation
module BM = Hacl.Spec.Bignum.Montgomery
module BN = Hacl.Spec.Bignum
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
#push-options "--fuel 1"
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
let rec pow_eq a n =
if n = 0 then ()
else pow_eq a (n - 1)
#pop-options
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} ->
Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1)
let mod_inv_prime_lemma n a =
Math.Lemmas.small_mod a n;
assert (a == a % n);
assert (a <> 0 /\ a % n <> 0);
calc (==) {
Lib.NatMod.pow_mod #n a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) }
Lib.NatMod.pow a (n - 2) % n * a % n;
(==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n }
Lib.NatMod.pow a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 }
Lib.NatMod.pow a (n - 1) % n;
(==) { pow_eq a (n - 1) }
Fermat.pow a (n - 1) % n;
(==) { Fermat.fermat_alt n a }
1;
}
//pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked
val bn_check_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> a:lbignum t len ->
res:limb t{
let b =
bn_v n % 2 = 1 && 1 < bn_v n &&
0 < bn_v a && bn_v a < bn_v n in
v res == (if b then v (ones t SEC) else v (zeros t SEC))}
let bn_check_mod_inv_prime #t #len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask a in
BN.bn_is_zero_mask_lemma a;
let m1' = lognot m1 in
lognot_lemma m1;
let m2 = BN.bn_lt_mask a n in
BN.bn_lt_mask_lemma a n;
logand_ones (m0 &. m1');
logand_zeros (m0 &. m1');
logand_ones m0;
logand_zeros m0;
m0 &. m1' &. m2
val bn_mod_inv_prime_n2:
#t:limb_t
-> #len:size_pos
-> n:lbignum t len ->
Pure (lbignum t len)
(requires 1 < bn_v n)
(ensures fun res ->
bn_v res == bn_v n - 2)
let bn_mod_inv_prime_n2 #t #len n =
let c, n2 = bn_sub1 n (uint #t 2) in
bn_sub1_lemma n (uint #t 2);
assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2);
bn_eval_bound n2 len;
bn_eval_bound n len;
assert (v c = 0);
assert (bn_v n2 == bn_v n - 2);
n2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.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",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_LessThan",
"FStar.Math.Euclid.is_prime",
"Prims.logical"
] | [] | false | false | false | false | true | let bn_mod_inv_prime_pre (#t: limb_t) (#len: BN.bn_len t) (n a: lbignum t len) =
| bn_v n % 2 = 1 /\ 1 < bn_v n /\ 0 < bn_v a /\ bn_v a < bn_v n /\ Euclid.is_prime (bn_v n) | false |
|
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_mont_ladder_swap_f | val exp_mont_ladder_swap_f : k: Spec.Exponentiation.concrete_ops t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits} ->
i: Prims.nat{i < bBits} ->
_: ((t * t) * Prims.nat)
-> (t * t) * Prims.nat | let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit) | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 108,
"start_col": 0,
"start_line": 100
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits} ->
i: Prims.nat{i < bBits} ->
_: ((t * t) * Prims.nat)
-> (t * t) * Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__sqr",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul",
"Lib.Exponentiation.cswap",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_Addition",
"Lib.Exponentiation.get_ith_bit",
"Prims.op_Subtraction"
] | [] | false | false | false | false | false | let exp_mont_ladder_swap_f
(#t: Type)
(k: concrete_ops t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(i: nat{i < bBits})
(r0, r1, privbit: tuple3 t t nat)
: tuple3 t t nat =
| let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit) | false |
|
Hacl.Spec.Bignum.ModInv.fst | Hacl.Spec.Bignum.ModInv.pow_eq | val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) | val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) | let rec pow_eq a n =
if n = 0 then ()
else pow_eq a (n - 1) | {
"file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 25,
"start_col": 0,
"start_line": 23
} | module Hacl.Spec.Bignum.ModInv
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.LoopCombinators
open Hacl.Spec.Bignum.Definitions
open Hacl.Spec.Bignum
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module BE = Hacl.Spec.Bignum.Exponentiation
module BM = Hacl.Spec.Bignum.Montgomery
module BN = Hacl.Spec.Bignum
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
#push-options "--fuel 1" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.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",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Prims.nat -> n: Prims.nat
-> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.pow a n == Lib.NatMod.pow a n) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Hacl.Spec.Bignum.ModInv.pow_eq",
"Prims.op_Subtraction",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec pow_eq a n =
| if n = 0 then () else pow_eq a (n - 1) | false |
Hacl.Spec.Bignum.ModInv.fst | Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_n2 | val bn_mod_inv_prime_n2:
#t:limb_t
-> #len:size_pos
-> n:lbignum t len ->
Pure (lbignum t len)
(requires 1 < bn_v n)
(ensures fun res ->
bn_v res == bn_v n - 2) | val bn_mod_inv_prime_n2:
#t:limb_t
-> #len:size_pos
-> n:lbignum t len ->
Pure (lbignum t len)
(requires 1 < bn_v n)
(ensures fun res ->
bn_v res == bn_v n - 2) | let bn_mod_inv_prime_n2 #t #len n =
let c, n2 = bn_sub1 n (uint #t 2) in
bn_sub1_lemma n (uint #t 2);
assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2);
bn_eval_bound n2 len;
bn_eval_bound n len;
assert (v c = 0);
assert (bn_v n2 == bn_v n - 2);
n2 | {
"file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 94,
"start_col": 0,
"start_line": 86
} | module Hacl.Spec.Bignum.ModInv
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.LoopCombinators
open Hacl.Spec.Bignum.Definitions
open Hacl.Spec.Bignum
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module BE = Hacl.Spec.Bignum.Exponentiation
module BM = Hacl.Spec.Bignum.Montgomery
module BN = Hacl.Spec.Bignum
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
#push-options "--fuel 1"
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
let rec pow_eq a n =
if n = 0 then ()
else pow_eq a (n - 1)
#pop-options
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} ->
Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1)
let mod_inv_prime_lemma n a =
Math.Lemmas.small_mod a n;
assert (a == a % n);
assert (a <> 0 /\ a % n <> 0);
calc (==) {
Lib.NatMod.pow_mod #n a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) }
Lib.NatMod.pow a (n - 2) % n * a % n;
(==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n }
Lib.NatMod.pow a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 }
Lib.NatMod.pow a (n - 1) % n;
(==) { pow_eq a (n - 1) }
Fermat.pow a (n - 1) % n;
(==) { Fermat.fermat_alt n a }
1;
}
//pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked
val bn_check_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> a:lbignum t len ->
res:limb t{
let b =
bn_v n % 2 = 1 && 1 < bn_v n &&
0 < bn_v a && bn_v a < bn_v n in
v res == (if b then v (ones t SEC) else v (zeros t SEC))}
let bn_check_mod_inv_prime #t #len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask a in
BN.bn_is_zero_mask_lemma a;
let m1' = lognot m1 in
lognot_lemma m1;
let m2 = BN.bn_lt_mask a n in
BN.bn_lt_mask_lemma a n;
logand_ones (m0 &. m1');
logand_zeros (m0 &. m1');
logand_ones m0;
logand_zeros m0;
m0 &. m1' &. m2
val bn_mod_inv_prime_n2:
#t:limb_t
-> #len:size_pos
-> n:lbignum t len ->
Pure (lbignum t len)
(requires 1 < bn_v n)
(ensures fun res ->
bn_v res == bn_v n - 2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.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",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Hacl.Spec.Bignum.Definitions.lbignum t len
-> Prims.Pure (Hacl.Spec.Bignum.Definitions.lbignum t len) | Prims.Pure | [] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Base.carry",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_Subtraction",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.bn_sub1_lemma",
"Lib.IntTypes.uint",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_sub1"
] | [] | false | false | false | false | false | let bn_mod_inv_prime_n2 #t #len n =
| let c, n2 = bn_sub1 n (uint #t 2) in
bn_sub1_lemma n (uint #t 2);
assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2);
bn_eval_bound n2 len;
bn_eval_bound n len;
assert (v c = 0);
assert (bn_v n2 == bn_v n - 2);
n2 | false |
Vale.Curve25519.FastUtil_helpers.fsti | Vale.Curve25519.FastUtil_helpers.int_canon | val int_canon : _: _ -> FStar.Tactics.Effect.Tac Prims.unit | let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring () | {
"file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastUtil_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 10,
"start_col": 0,
"start_line": 10
} | module Vale.Curve25519.FastUtil_helpers
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Mul
open FStar.Tactics
open FStar.Tactics.CanonCommSemiring
open Vale.Curve25519.Fast_defs | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.Fast_defs.fst.checked",
"prims.fst.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Curve25519.FastUtil_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommSemiring",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: _ -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Tactics.CanonCommSemiring.int_semiring",
"Prims.unit",
"FStar.Stubs.Tactics.V1.Builtins.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"Prims.Nil"
] | [] | false | true | false | false | false | let int_canon =
| fun _ ->
norm [delta; zeta; iota];
int_semiring () | false |
|
Hacl.Spec.Bignum.ModInv.fst | Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime | val bn_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> nBits:size_nat
-> n:lbignum t len
-> a:lbignum t len ->
Pure (lbignum t len)
(requires
bn_mod_inv_prime_pre n a /\
nBits / bits t < len /\ pow2 nBits < bn_v n)
(ensures fun res ->
bn_v res * bn_v a % bn_v n = 1) | val bn_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> nBits:size_nat
-> n:lbignum t len
-> a:lbignum t len ->
Pure (lbignum t len)
(requires
bn_mod_inv_prime_pre n a /\
nBits / bits t < len /\ pow2 nBits < bn_v n)
(ensures fun res ->
bn_v res * bn_v a % bn_v n = 1) | let bn_mod_inv_prime #t #len nBits n a =
let r2, mu = BM.bn_mont_precomp nBits n in
let res = bn_mod_inv_prime_precomp #t #len n mu r2 a in
mod_inv_prime_lemma (bn_v n) (bn_v a);
res | {
"file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 149,
"start_col": 0,
"start_line": 145
} | module Hacl.Spec.Bignum.ModInv
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.LoopCombinators
open Hacl.Spec.Bignum.Definitions
open Hacl.Spec.Bignum
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module BE = Hacl.Spec.Bignum.Exponentiation
module BM = Hacl.Spec.Bignum.Montgomery
module BN = Hacl.Spec.Bignum
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
#push-options "--fuel 1"
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
let rec pow_eq a n =
if n = 0 then ()
else pow_eq a (n - 1)
#pop-options
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} ->
Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1)
let mod_inv_prime_lemma n a =
Math.Lemmas.small_mod a n;
assert (a == a % n);
assert (a <> 0 /\ a % n <> 0);
calc (==) {
Lib.NatMod.pow_mod #n a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) }
Lib.NatMod.pow a (n - 2) % n * a % n;
(==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n }
Lib.NatMod.pow a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 }
Lib.NatMod.pow a (n - 1) % n;
(==) { pow_eq a (n - 1) }
Fermat.pow a (n - 1) % n;
(==) { Fermat.fermat_alt n a }
1;
}
//pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked
val bn_check_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> a:lbignum t len ->
res:limb t{
let b =
bn_v n % 2 = 1 && 1 < bn_v n &&
0 < bn_v a && bn_v a < bn_v n in
v res == (if b then v (ones t SEC) else v (zeros t SEC))}
let bn_check_mod_inv_prime #t #len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask a in
BN.bn_is_zero_mask_lemma a;
let m1' = lognot m1 in
lognot_lemma m1;
let m2 = BN.bn_lt_mask a n in
BN.bn_lt_mask_lemma a n;
logand_ones (m0 &. m1');
logand_zeros (m0 &. m1');
logand_ones m0;
logand_zeros m0;
m0 &. m1' &. m2
val bn_mod_inv_prime_n2:
#t:limb_t
-> #len:size_pos
-> n:lbignum t len ->
Pure (lbignum t len)
(requires 1 < bn_v n)
(ensures fun res ->
bn_v res == bn_v n - 2)
let bn_mod_inv_prime_n2 #t #len n =
let c, n2 = bn_sub1 n (uint #t 2) in
bn_sub1_lemma n (uint #t 2);
assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2);
bn_eval_bound n2 len;
bn_eval_bound n len;
assert (v c = 0);
assert (bn_v n2 == bn_v n - 2);
n2
let bn_mod_inv_prime_pre
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(a:lbignum t len)
=
bn_v n % 2 = 1 /\ 1 < bn_v n /\
0 < bn_v a /\ bn_v a < bn_v n /\
Euclid.is_prime (bn_v n)
val bn_mod_inv_prime_precomp:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t len ->
Pure (lbignum t len)
(requires
bn_mod_inv_prime_pre n a /\
bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\
(1 + bn_v n * v mu) % pow2 (bits t) == 0)
(ensures fun res ->
bn_v res * bn_v a % bn_v n = 1)
let bn_mod_inv_prime_precomp #t #len n mu r2 a =
let n2 = bn_mod_inv_prime_n2 n in
bn_eval_bound n len;
let res = BE.bn_mod_exp_vartime_precompr2 len n r2 a (bits t * len) n2 in
assert (bn_v res == Lib.NatMod.pow_mod #(bn_v n) (bn_v a) (bn_v n2));
mod_inv_prime_lemma (bn_v n) (bn_v a);
res
val bn_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> nBits:size_nat
-> n:lbignum t len
-> a:lbignum t len ->
Pure (lbignum t len)
(requires
bn_mod_inv_prime_pre n a /\
nBits / bits t < len /\ pow2 nBits < bn_v n)
(ensures fun res ->
bn_v res * bn_v a % bn_v n = 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.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",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
nBits: Lib.IntTypes.size_nat ->
n: Hacl.Spec.Bignum.Definitions.lbignum t len ->
a: Hacl.Spec.Bignum.Definitions.lbignum t len
-> Prims.Pure (Hacl.Spec.Bignum.Definitions.lbignum t len) | Prims.Pure | [] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.unit",
"Hacl.Spec.Bignum.ModInv.mod_inv_prime_lemma",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_precomp",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Montgomery.bn_mont_precomp"
] | [] | false | false | false | false | false | let bn_mod_inv_prime #t #len nBits n a =
| let r2, mu = BM.bn_mont_precomp nBits n in
let res = bn_mod_inv_prime_precomp #t #len n mu r2 a in
mod_inv_prime_lemma (bn_v n) (bn_v a);
res | false |
RandomTapes.fst | RandomTapes.minus | val minus : int -> int -> Tot int | val minus : int -> int -> Tot int | let minus x y = y - x | {
"file_name": "examples/rel/RandomTapes.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 21,
"end_line": 34,
"start_col": 0,
"start_line": 34
} | (*
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 RandomTapes
open Rel
open Bijection
(* Experimenting with random tapes *)
type random_tape = int -> Tot int
val sample : random_tape -> int -> Tot int
let sample r i = r i
type rel_random_tape (b:(int -> Tot bij)) = r:(rel random_tape){forall i. b i (R?.l r i) = R?.r r i}
val id : bij #int #int
let id x = x | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"Bijection.fst.checked"
],
"interface_file": false,
"source_file": "RandomTapes.fst"
} | [
{
"abbrev": false,
"full_module": "Bijection",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> y: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_Subtraction"
] | [] | false | false | false | true | false | let minus x y =
| y - x | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.mul_acc_pow_a_bits_l | val mul_acc_pow_a_bits_l
(#t: Type)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t | val mul_acc_pow_a_bits_l
(#t: Type)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t | let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t
=
let bits_l = S.get_bits_l bBits b l i in
k.mul acc (pow k a bits_l) | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 156,
"start_col": 0,
"start_line": 152
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b)
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit)
let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let (r0, r1) = S.cswap sw r0 r1 in
r0
val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b)
let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
Loops.repeat b k.sqr a
val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b)
[@(strict_on_arguments [3])]
let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
if b = 0 then k.one ()
else k.mul a (pow k a (b - 1))
val pow_eq0: #t:Type -> k:concrete_ops t -> a:t ->
Lemma (pow k a 0 == k.one ())
val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos ->
Lemma (pow k a i == k.mul a (pow k a (i - 1)))
val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b)
let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t
=
let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in
pow k a bits_c | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
a: t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits} ->
l: Prims.pos ->
i: Prims.nat{i < bBits / l} ->
acc: t
-> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.pos",
"Prims.op_Division",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul",
"Spec.Exponentiation.pow",
"Lib.Exponentiation.get_bits_l"
] | [] | false | false | false | false | false | let mul_acc_pow_a_bits_l
(#t: Type)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t =
| let bits_l = S.get_bits_l bBits b l i in
k.mul acc (pow k a bits_l) | false |
OPLSS.MAC.fst | OPLSS.MAC.log | val log : k: OPLSS.MAC.key -> h: FStar.Monotonic.HyperStack.mem
-> Prims.GTot (FStar.Seq.Base.seq OPLSS.MAC.log_entry) | let log (k:key) (h:HS.mem) = Log.entries k.log h | {
"file_name": "examples/crypto/OPLSS.MAC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 48,
"end_line": 37,
"start_col": 0,
"start_line": 37
} | (*
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 OPLSS.MAC
(* This module idealizes HMACSHA1 as an UF-CMA MAC *)
open OPLSS
open FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module HS = FStar.HyperStack
/// The UF-CMA log associates messages with tags
type log_entry =
| Entry: msg:HMACSHA1.msg
-> tag:HMACSHA1.tag
-> log_entry
/// A key packages a raw HMACSHA1 key with the ideal UF-CMA log
noeq
type key =
| Key: raw:HMACSHA1.sha1_key
-> log:Log.t log_entry
-> key | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"OPLSS.Log.fst.checked",
"OPLSS.Ideal.fsti.checked",
"OPLSS.HMACSHA1.fst.checked",
"OPLSS.Flag.fsti.checked",
"OPLSS.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "OPLSS.MAC.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: OPLSS.MAC.key -> h: FStar.Monotonic.HyperStack.mem
-> Prims.GTot (FStar.Seq.Base.seq OPLSS.MAC.log_entry) | Prims.GTot | [
"sometrivial"
] | [] | [
"OPLSS.MAC.key",
"FStar.Monotonic.HyperStack.mem",
"OPLSS.Log.entries",
"OPLSS.MAC.log_entry",
"OPLSS.MAC.__proj__Key__item__log",
"FStar.Seq.Base.seq"
] | [] | false | false | false | false | false | let log (k: key) (h: HS.mem) =
| Log.entries k.log h | false |
|
RandomTapes.fst | RandomTapes.sample | val sample : random_tape -> int -> Tot int | val sample : random_tape -> int -> Tot int | let sample r i = r i | {
"file_name": "examples/rel/RandomTapes.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 21,
"end_line": 26,
"start_col": 0,
"start_line": 26
} | (*
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 RandomTapes
open Rel
open Bijection
(* Experimenting with random tapes *)
type random_tape = int -> Tot int | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"Bijection.fst.checked"
],
"interface_file": false,
"source_file": "RandomTapes.fst"
} | [
{
"abbrev": false,
"full_module": "Bijection",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: RandomTapes.random_tape -> i: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"RandomTapes.random_tape",
"Prims.int"
] | [] | false | false | false | true | false | let sample r i =
| r i | false |
Steel.ST.Array.fsti | Steel.ST.Array.array | val array ([@@@ strictly_positive]elt: Type0) : Tot Type0 | val array ([@@@ strictly_positive]elt: Type0) : Tot Type0 | let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 84,
"end_line": 76,
"start_col": 0,
"start_line": 75
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | elt: Type0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.dtuple2",
"Steel.ST.Array.ptr",
"FStar.Ghost.erased",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"FStar.Ghost.reveal",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base"
] | [] | false | false | false | true | true | let array ([@@@ strictly_positive]elt: Type0) : Tot Type0 =
| (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) | false |
RandomTapes.fst | RandomTapes.otp | val otp : int -> random_tape -> int -> Tot int | val otp : int -> random_tape -> int -> Tot int | let otp n r i = n + r i | {
"file_name": "examples/rel/RandomTapes.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 42,
"start_col": 0,
"start_line": 42
} | (*
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 RandomTapes
open Rel
open Bijection
(* Experimenting with random tapes *)
type random_tape = int -> Tot int
val sample : random_tape -> int -> Tot int
let sample r i = r i
type rel_random_tape (b:(int -> Tot bij)) = r:(rel random_tape){forall i. b i (R?.l r i) = R?.r r i}
val id : bij #int #int
let id x = x
val minus : int -> int -> Tot int
let minus x y = y - x
(* Proving the function used is a bijection *)
val add : int -> Tot (bij #int #int)
let add x = cut (inverses (op_Addition x) (minus x)); op_Addition x
(* Definition of a simple one time pad *) | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"Bijection.fst.checked"
],
"interface_file": false,
"source_file": "RandomTapes.fst"
} | [
{
"abbrev": false,
"full_module": "Bijection",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.int -> r: RandomTapes.random_tape -> i: Prims.int -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"RandomTapes.random_tape",
"Prims.op_Addition"
] | [] | false | false | false | true | false | let otp n r i =
| n + r i | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_double_fw_f | val exp_double_fw_f
(#t: Type)
(k: concrete_ops t)
(a1: t)
(bBits: nat)
(b1: nat{b1 < pow2 bBits})
(a2: t)
(b2: nat{b2 < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t | val exp_double_fw_f
(#t: Type)
(k: concrete_ops t)
(a1: t)
(bBits: nat)
(b1: nat{b1 < pow2 bBits})
(a2: t)
(b2: nat{b2 < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t | let exp_double_fw_f (#t:Type) (k:concrete_ops t)
(a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits})
(a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos)
(i:nat{i < bBits / l}) (acc:t) : t
=
let acc1 = exp_fw_f k a2 bBits b2 l i acc in
mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1 | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 196,
"start_col": 0,
"start_line": 190
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b)
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit)
let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let (r0, r1) = S.cswap sw r0 r1 in
r0
val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b)
let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
Loops.repeat b k.sqr a
val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b)
[@(strict_on_arguments [3])]
let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
if b = 0 then k.one ()
else k.mul a (pow k a (b - 1))
val pow_eq0: #t:Type -> k:concrete_ops t -> a:t ->
Lemma (pow k a 0 == k.one ())
val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos ->
Lemma (pow k a i == k.mul a (pow k a (i - 1)))
val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b)
let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t
=
let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in
pow k a bits_c
let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t
=
let bits_l = S.get_bits_l bBits b l i in
k.mul acc (pow k a bits_l)
let exp_fw_f (#t:Type) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos)
(i:nat{i < bBits / l}) (acc:t) : t
=
let acc1 = exp_pow2 k acc l in
mul_acc_pow_a_bits_l k a bBits b l i acc1
let exp_fw (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t =
let acc0 = if bBits % l = 0 then one () else exp_fw_acc0 k a bBits b l in
Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0
val exp_fw_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos ->
Lemma (k.to.refl (exp_fw k a bBits b l) == S.exp_fw k.to.comm_monoid (k.to.refl a) bBits b l)
/// Multi-Exponentiation
// Double exponentiation [a1^b1 `mul` a2^b2]
//-------------------------------------------
let exp_double_fw_acc0 (#t:Type) (k:concrete_ops t)
(a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits})
(a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t
=
let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in
let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in
k.mul acc_a1 acc_a2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
a1: t ->
bBits: Prims.nat ->
b1: Prims.nat{b1 < Prims.pow2 bBits} ->
a2: t ->
b2: Prims.nat{b2 < Prims.pow2 bBits} ->
l: Prims.pos ->
i: Prims.nat{i < bBits / l} ->
acc: t
-> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.pos",
"Prims.op_Division",
"Spec.Exponentiation.mul_acc_pow_a_bits_l",
"Spec.Exponentiation.exp_fw_f"
] | [] | false | false | false | false | false | let exp_double_fw_f
(#t: Type)
(k: concrete_ops t)
(a1: t)
(bBits: nat)
(b1: nat{b1 < pow2 bBits})
(a2: t)
(b2: nat{b2 < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t =
| let acc1 = exp_fw_f k a2 bBits b2 l i acc in
mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1 | false |
RandomTapes.fst | RandomTapes.otp2 | val otp2 : int -> int -> random_tape -> int -> int -> Tot (int * int) | val otp2 : int -> int -> random_tape -> int -> int -> Tot (int * int) | let otp2 n m r i j = (n + r i, m + r j) | {
"file_name": "examples/rel/RandomTapes.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 39,
"end_line": 58,
"start_col": 0,
"start_line": 58
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module RandomTapes
open Rel
open Bijection
(* Experimenting with random tapes *)
type random_tape = int -> Tot int
val sample : random_tape -> int -> Tot int
let sample r i = r i
type rel_random_tape (b:(int -> Tot bij)) = r:(rel random_tape){forall i. b i (R?.l r i) = R?.r r i}
val id : bij #int #int
let id x = x
val minus : int -> int -> Tot int
let minus x y = y - x
(* Proving the function used is a bijection *)
val add : int -> Tot (bij #int #int)
let add x = cut (inverses (op_Addition x) (minus x)); op_Addition x
(* Definition of a simple one time pad *)
val otp : int -> random_tape -> int -> Tot int
let otp n r i = n + r i
(* Random tape used for relational verification *)
val otp_rand : x:(rel int) -> int -> Tot (bij #int #int)
let otp_rand x i = if i = 0 then
add (R?.l x - R?.r x)
else
id
(* otp perfectly hides input *)
val otp_eq : x:(rel int) -> r:(rel_random_tape (otp_rand x)) ->
Lemma (r_eq(lift3 otp x r (R 0 0)))
let otp_eq x r = ()
(* Same thing for a pair of values *) | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"Bijection.fst.checked"
],
"interface_file": false,
"source_file": "RandomTapes.fst"
} | [
{
"abbrev": false,
"full_module": "Bijection",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.int -> m: Prims.int -> r: RandomTapes.random_tape -> i: Prims.int -> j: Prims.int
-> Prims.int * Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"RandomTapes.random_tape",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Addition",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | true | false | let otp2 n m r i j =
| (n + r i, m + r j) | false |
Steel.ST.Array.fsti | Steel.ST.Array.ptr_of | val ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) | val ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) | let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 19,
"end_line": 91,
"start_col": 0,
"start_line": 86
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Steel.ST.Array.array elt -> Steel.ST.Array.ptr elt | Prims.Tot | [
"total"
] | [] | [
"Steel.ST.Array.array",
"Steel.ST.Array.ptr",
"FStar.Ghost.erased",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"FStar.Ghost.reveal",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base"
] | [] | false | false | false | true | false | let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) =
| match a with | (| p , _ |) -> p | false |
RandomTapes.fst | RandomTapes.otp_rand | val otp_rand : x:(rel int) -> int -> Tot (bij #int #int) | val otp_rand : x:(rel int) -> int -> Tot (bij #int #int) | let otp_rand x i = if i = 0 then
add (R?.l x - R?.r x)
else
id | {
"file_name": "examples/rel/RandomTapes.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 49,
"start_col": 0,
"start_line": 46
} | (*
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 RandomTapes
open Rel
open Bijection
(* Experimenting with random tapes *)
type random_tape = int -> Tot int
val sample : random_tape -> int -> Tot int
let sample r i = r i
type rel_random_tape (b:(int -> Tot bij)) = r:(rel random_tape){forall i. b i (R?.l r i) = R?.r r i}
val id : bij #int #int
let id x = x
val minus : int -> int -> Tot int
let minus x y = y - x
(* Proving the function used is a bijection *)
val add : int -> Tot (bij #int #int)
let add x = cut (inverses (op_Addition x) (minus x)); op_Addition x
(* Definition of a simple one time pad *)
val otp : int -> random_tape -> int -> Tot int
let otp n r i = n + r i
(* Random tape used for relational verification *) | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"Bijection.fst.checked"
],
"interface_file": false,
"source_file": "RandomTapes.fst"
} | [
{
"abbrev": false,
"full_module": "Bijection",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Rel.rel Prims.int -> i: Prims.int -> Bijection.bij | Prims.Tot | [
"total"
] | [] | [
"Rel.rel",
"Prims.int",
"Prims.op_Equality",
"RandomTapes.add",
"Prims.op_Subtraction",
"Rel.__proj__R__item__l",
"Rel.__proj__R__item__r",
"Prims.bool",
"RandomTapes.id",
"Bijection.bij"
] | [] | false | false | false | true | false | let otp_rand x i =
| if i = 0 then add (R?.l x - R?.r x) else id | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.pow | val pow (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t | val pow (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t | let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
if b = 0 then k.one ()
else k.mul a (pow k a (b - 1)) | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 132,
"start_col": 0,
"start_line": 130
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b)
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit)
let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let (r0, r1) = S.cswap sw r0 r1 in
r0
val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b)
let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
Loops.repeat b k.sqr a
val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Spec.Exponentiation.concrete_ops t -> a: t -> b: Prims.nat -> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__one",
"Prims.bool",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul",
"Spec.Exponentiation.pow",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | false | false | true | false | let rec pow (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t =
| if b = 0 then k.one () else k.mul a (pow k a (b - 1)) | false |
OPLSS.MAC.fst | OPLSS.MAC.verify | val verify (k: key) (m: HMACSHA1.msg) (t: HMACSHA1.tag)
: ST bool
(requires invariant k)
(ensures
fun h0 b h1 ->
invariant k h1 /\ h0 == h1 /\
(b <==>
t == HMACSHA1.hmac_sha1 k.raw m /\
(Flag.reveal Ideal.uf_cma ==> (log k h1) `Log.has` (Entry m t)))) | val verify (k: key) (m: HMACSHA1.msg) (t: HMACSHA1.tag)
: ST bool
(requires invariant k)
(ensures
fun h0 b h1 ->
invariant k h1 /\ h0 == h1 /\
(b <==>
t == HMACSHA1.hmac_sha1 k.raw m /\
(Flag.reveal Ideal.uf_cma ==> (log k h1) `Log.has` (Entry m t)))) | let verify (k:key) (m:HMACSHA1.msg) (t:HMACSHA1.tag)
: ST bool
(requires
invariant k)
(ensures fun h0 b h1 ->
invariant k h1 /\
h0 == h1 /\
(b <==> t == HMACSHA1.hmac_sha1 k.raw m /\
(Flag.reveal Ideal.uf_cma ==> log k h1 `Log.has` Entry m t)))
= let verified = (t = HMACSHA1.hmac_sha1 k.raw m) in
//CRYPTO HYPOTHESIS
// Correction of Errors in HMACSHA1 can
// only be observed with negligible probability
if Flag.idealizing Ideal.uf_cma
then let found = Some? (Log.find k.log (fun e -> e.msg = m && e.tag = t)) in
verified && found
else verified | {
"file_name": "examples/crypto/OPLSS.MAC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 100,
"start_col": 0,
"start_line": 84
} | (*
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 OPLSS.MAC
(* This module idealizes HMACSHA1 as an UF-CMA MAC *)
open OPLSS
open FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module HS = FStar.HyperStack
/// The UF-CMA log associates messages with tags
type log_entry =
| Entry: msg:HMACSHA1.msg
-> tag:HMACSHA1.tag
-> log_entry
/// A key packages a raw HMACSHA1 key with the ideal UF-CMA log
noeq
type key =
| Key: raw:HMACSHA1.sha1_key
-> log:Log.t log_entry
-> key
let loc (k:key) = B.loc_mreference k.log
let log (k:key) (h:HS.mem) = Log.entries k.log h
/// The invariant is simply that the log is live
let invariant (k:key) (h:HS.mem) : Type =
HS.contains h k.log
/// Generating a new MAC'ing key
/// - satisfying the invariant
/// - allocating _fresh_ state for the log
/// - intializing it to the empty log
let keygen ()
: ST key
(requires fun _ -> True)
(ensures fun h0 k h1 ->
invariant k h1 /\
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (Log.fp k.log) h0 h1 /\
log k h1 == Seq.empty)
= let raw = random HMACSHA1.keysize in
let l = Log.new_log #log_entry in
Key raw l
/// `mac k m`:
/// Concretely, it's just HMACSHA1
/// But, ideally, it also appends a new entry in the log
let mac (k:key) (m:HMACSHA1.msg)
: ST HMACSHA1.tag
(requires
invariant k)
(ensures fun h0 t h1 ->
invariant k h1 /\
B.modifies (Log.fp k.log) h0 h1 /\
t == HMACSHA1.hmac_sha1 k.raw m /\
(if Flag.reveal Ideal.uf_cma
then log k h1 == Seq.snoc (log k h0) (Entry m t)
else log k h1 == log k h0))
= let t = HMACSHA1.hmac_sha1 k.raw m in
//CRYPTO HYPOTHESIS
// () ~ (Log.add k.log Entry m t)
//The log is private
if Flag.idealizing Ideal.uf_cma
then Log.add k.log (Entry m t);
t
/// `verify k m`
/// Concretely, just an HMACSHA1 verify | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"OPLSS.Log.fst.checked",
"OPLSS.Ideal.fsti.checked",
"OPLSS.HMACSHA1.fst.checked",
"OPLSS.Flag.fsti.checked",
"OPLSS.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "OPLSS.MAC.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: OPLSS.MAC.key -> m: OPLSS.HMACSHA1.msg -> t: OPLSS.HMACSHA1.tag
-> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"OPLSS.MAC.key",
"OPLSS.HMACSHA1.msg",
"OPLSS.HMACSHA1.tag",
"OPLSS.Flag.idealizing",
"OPLSS.Ideal.uf_cma",
"Prims.op_AmpAmp",
"Prims.bool",
"FStar.Pervasives.Native.uu___is_Some",
"OPLSS.MAC.log_entry",
"FStar.Pervasives.Native.option",
"OPLSS.Log.find",
"OPLSS.MAC.__proj__Key__item__log",
"Prims.op_Equality",
"OPLSS.MAC.__proj__Entry__item__msg",
"OPLSS.MAC.__proj__Entry__item__tag",
"OPLSS.HMACSHA1.hmac_sha1",
"OPLSS.MAC.__proj__Key__item__raw",
"OPLSS.MAC.invariant",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Prims.eq2",
"Prims.l_iff",
"Prims.b2t",
"Prims.l_imp",
"OPLSS.Flag.reveal",
"OPLSS.Log.has",
"OPLSS.MAC.log",
"OPLSS.MAC.Entry"
] | [] | false | true | false | false | false | let verify (k: key) (m: HMACSHA1.msg) (t: HMACSHA1.tag)
: ST bool
(requires invariant k)
(ensures
fun h0 b h1 ->
invariant k h1 /\ h0 == h1 /\
(b <==>
t == HMACSHA1.hmac_sha1 k.raw m /\
(Flag.reveal Ideal.uf_cma ==> (log k h1) `Log.has` (Entry m t)))) =
| let verified = (t = HMACSHA1.hmac_sha1 k.raw m) in
if Flag.idealizing Ideal.uf_cma
then
let found = Some? (Log.find k.log (fun e -> e.msg = m && e.tag = t)) in
verified && found
else verified | false |
RandomTapes.fst | RandomTapes.otp2_rand | val otp2_rand : x:(rel int) -> y:(rel int) -> int -> Tot (bij #int #int) | val otp2_rand : x:(rel int) -> y:(rel int) -> int -> Tot (bij #int #int) | let otp2_rand x y i =
match i with
| 0 -> add (R?.l x - R?.r x)
| 1 -> add (R?.l y - R?.r y)
| _ -> id | {
"file_name": "examples/rel/RandomTapes.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 65,
"start_col": 0,
"start_line": 61
} | (*
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 RandomTapes
open Rel
open Bijection
(* Experimenting with random tapes *)
type random_tape = int -> Tot int
val sample : random_tape -> int -> Tot int
let sample r i = r i
type rel_random_tape (b:(int -> Tot bij)) = r:(rel random_tape){forall i. b i (R?.l r i) = R?.r r i}
val id : bij #int #int
let id x = x
val minus : int -> int -> Tot int
let minus x y = y - x
(* Proving the function used is a bijection *)
val add : int -> Tot (bij #int #int)
let add x = cut (inverses (op_Addition x) (minus x)); op_Addition x
(* Definition of a simple one time pad *)
val otp : int -> random_tape -> int -> Tot int
let otp n r i = n + r i
(* Random tape used for relational verification *)
val otp_rand : x:(rel int) -> int -> Tot (bij #int #int)
let otp_rand x i = if i = 0 then
add (R?.l x - R?.r x)
else
id
(* otp perfectly hides input *)
val otp_eq : x:(rel int) -> r:(rel_random_tape (otp_rand x)) ->
Lemma (r_eq(lift3 otp x r (R 0 0)))
let otp_eq x r = ()
(* Same thing for a pair of values *)
val otp2 : int -> int -> random_tape -> int -> int -> Tot (int * int)
let otp2 n m r i j = (n + r i, m + r j) | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"Bijection.fst.checked"
],
"interface_file": false,
"source_file": "RandomTapes.fst"
} | [
{
"abbrev": false,
"full_module": "Bijection",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Rel.rel Prims.int -> y: Rel.rel Prims.int -> i: Prims.int -> Bijection.bij | Prims.Tot | [
"total"
] | [] | [
"Rel.rel",
"Prims.int",
"RandomTapes.add",
"Prims.op_Subtraction",
"Rel.__proj__R__item__l",
"Rel.__proj__R__item__r",
"RandomTapes.id",
"Bijection.bij"
] | [] | false | false | false | true | false | let otp2_rand x y i =
| match i with
| 0 -> add (R?.l x - R?.r x)
| 1 -> add (R?.l y - R?.r y)
| _ -> id | false |
OPLSS.MAC.fst | OPLSS.MAC.keygen | val keygen: Prims.unit
-> ST key
(requires fun _ -> True)
(ensures
fun h0 k h1 ->
invariant k h1 /\ B.modifies B.loc_none h0 h1 /\ B.fresh_loc (Log.fp k.log) h0 h1 /\
log k h1 == Seq.empty) | val keygen: Prims.unit
-> ST key
(requires fun _ -> True)
(ensures
fun h0 k h1 ->
invariant k h1 /\ B.modifies B.loc_none h0 h1 /\ B.fresh_loc (Log.fp k.log) h0 h1 /\
log k h1 == Seq.empty) | let keygen ()
: ST key
(requires fun _ -> True)
(ensures fun h0 k h1 ->
invariant k h1 /\
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (Log.fp k.log) h0 h1 /\
log k h1 == Seq.empty)
= let raw = random HMACSHA1.keysize in
let l = Log.new_log #log_entry in
Key raw l | {
"file_name": "examples/crypto/OPLSS.MAC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 57,
"start_col": 0,
"start_line": 47
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module OPLSS.MAC
(* This module idealizes HMACSHA1 as an UF-CMA MAC *)
open OPLSS
open FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module HS = FStar.HyperStack
/// The UF-CMA log associates messages with tags
type log_entry =
| Entry: msg:HMACSHA1.msg
-> tag:HMACSHA1.tag
-> log_entry
/// A key packages a raw HMACSHA1 key with the ideal UF-CMA log
noeq
type key =
| Key: raw:HMACSHA1.sha1_key
-> log:Log.t log_entry
-> key
let loc (k:key) = B.loc_mreference k.log
let log (k:key) (h:HS.mem) = Log.entries k.log h
/// The invariant is simply that the log is live
let invariant (k:key) (h:HS.mem) : Type =
HS.contains h k.log
/// Generating a new MAC'ing key
/// - satisfying the invariant
/// - allocating _fresh_ state for the log | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"OPLSS.Log.fst.checked",
"OPLSS.Ideal.fsti.checked",
"OPLSS.HMACSHA1.fst.checked",
"OPLSS.Flag.fsti.checked",
"OPLSS.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "OPLSS.MAC.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.HyperStack.ST.ST OPLSS.MAC.key | FStar.HyperStack.ST.ST | [] | [] | [
"Prims.unit",
"OPLSS.MAC.Key",
"OPLSS.MAC.key",
"OPLSS.Log.t",
"OPLSS.MAC.log_entry",
"OPLSS.Log.new_log",
"OPLSS.lbytes",
"OPLSS.HMACSHA1.keysize",
"OPLSS.random",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_True",
"Prims.l_and",
"OPLSS.MAC.invariant",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"LowStar.Monotonic.Buffer.fresh_loc",
"OPLSS.Log.fp",
"OPLSS.MAC.__proj__Key__item__log",
"Prims.eq2",
"FStar.Seq.Base.seq",
"OPLSS.MAC.log",
"FStar.Seq.Base.empty"
] | [] | false | true | false | false | false | let keygen ()
: ST key
(requires fun _ -> True)
(ensures
fun h0 k h1 ->
invariant k h1 /\ B.modifies B.loc_none h0 h1 /\ B.fresh_loc (Log.fp k.log) h0 h1 /\
log k h1 == Seq.empty) =
| let raw = random HMACSHA1.keysize in
let l = Log.new_log #log_entry in
Key raw l | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_fw_f | val exp_fw_f
(#t: Type)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t | val exp_fw_f
(#t: Type)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t | let exp_fw_f (#t:Type) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos)
(i:nat{i < bBits / l}) (acc:t) : t
=
let acc1 = exp_pow2 k acc l in
mul_acc_pow_a_bits_l k a bBits b l i acc1 | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 164,
"start_col": 0,
"start_line": 159
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b)
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit)
let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let (r0, r1) = S.cswap sw r0 r1 in
r0
val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b)
let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
Loops.repeat b k.sqr a
val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b)
[@(strict_on_arguments [3])]
let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
if b = 0 then k.one ()
else k.mul a (pow k a (b - 1))
val pow_eq0: #t:Type -> k:concrete_ops t -> a:t ->
Lemma (pow k a 0 == k.one ())
val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos ->
Lemma (pow k a i == k.mul a (pow k a (i - 1)))
val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b)
let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t
=
let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in
pow k a bits_c
let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t
=
let bits_l = S.get_bits_l bBits b l i in
k.mul acc (pow k a bits_l) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
a: t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits} ->
l: Prims.pos ->
i: Prims.nat{i < bBits / l} ->
acc: t
-> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.pos",
"Prims.op_Division",
"Spec.Exponentiation.mul_acc_pow_a_bits_l",
"Spec.Exponentiation.exp_pow2"
] | [] | false | false | false | false | false | let exp_fw_f
(#t: Type)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t =
| let acc1 = exp_pow2 k acc l in
mul_acc_pow_a_bits_l k a bBits b l i acc1 | false |
Hacl.Spec.Bignum.ModInv.fst | Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_precomp | val bn_mod_inv_prime_precomp:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t len ->
Pure (lbignum t len)
(requires
bn_mod_inv_prime_pre n a /\
bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\
(1 + bn_v n * v mu) % pow2 (bits t) == 0)
(ensures fun res ->
bn_v res * bn_v a % bn_v n = 1) | val bn_mod_inv_prime_precomp:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t len ->
Pure (lbignum t len)
(requires
bn_mod_inv_prime_pre n a /\
bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\
(1 + bn_v n * v mu) % pow2 (bits t) == 0)
(ensures fun res ->
bn_v res * bn_v a % bn_v n = 1) | let bn_mod_inv_prime_precomp #t #len n mu r2 a =
let n2 = bn_mod_inv_prime_n2 n in
bn_eval_bound n len;
let res = BE.bn_mod_exp_vartime_precompr2 len n r2 a (bits t * len) n2 in
assert (bn_v res == Lib.NatMod.pow_mod #(bn_v n) (bn_v a) (bn_v n2));
mod_inv_prime_lemma (bn_v n) (bn_v a);
res | {
"file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 129,
"start_col": 0,
"start_line": 123
} | module Hacl.Spec.Bignum.ModInv
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.LoopCombinators
open Hacl.Spec.Bignum.Definitions
open Hacl.Spec.Bignum
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module BE = Hacl.Spec.Bignum.Exponentiation
module BM = Hacl.Spec.Bignum.Montgomery
module BN = Hacl.Spec.Bignum
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
#push-options "--fuel 1"
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
let rec pow_eq a n =
if n = 0 then ()
else pow_eq a (n - 1)
#pop-options
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} ->
Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1)
let mod_inv_prime_lemma n a =
Math.Lemmas.small_mod a n;
assert (a == a % n);
assert (a <> 0 /\ a % n <> 0);
calc (==) {
Lib.NatMod.pow_mod #n a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) }
Lib.NatMod.pow a (n - 2) % n * a % n;
(==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n }
Lib.NatMod.pow a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 }
Lib.NatMod.pow a (n - 1) % n;
(==) { pow_eq a (n - 1) }
Fermat.pow a (n - 1) % n;
(==) { Fermat.fermat_alt n a }
1;
}
//pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked
val bn_check_mod_inv_prime:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> a:lbignum t len ->
res:limb t{
let b =
bn_v n % 2 = 1 && 1 < bn_v n &&
0 < bn_v a && bn_v a < bn_v n in
v res == (if b then v (ones t SEC) else v (zeros t SEC))}
let bn_check_mod_inv_prime #t #len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask a in
BN.bn_is_zero_mask_lemma a;
let m1' = lognot m1 in
lognot_lemma m1;
let m2 = BN.bn_lt_mask a n in
BN.bn_lt_mask_lemma a n;
logand_ones (m0 &. m1');
logand_zeros (m0 &. m1');
logand_ones m0;
logand_zeros m0;
m0 &. m1' &. m2
val bn_mod_inv_prime_n2:
#t:limb_t
-> #len:size_pos
-> n:lbignum t len ->
Pure (lbignum t len)
(requires 1 < bn_v n)
(ensures fun res ->
bn_v res == bn_v n - 2)
let bn_mod_inv_prime_n2 #t #len n =
let c, n2 = bn_sub1 n (uint #t 2) in
bn_sub1_lemma n (uint #t 2);
assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2);
bn_eval_bound n2 len;
bn_eval_bound n len;
assert (v c = 0);
assert (bn_v n2 == bn_v n - 2);
n2
let bn_mod_inv_prime_pre
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(a:lbignum t len)
=
bn_v n % 2 = 1 /\ 1 < bn_v n /\
0 < bn_v a /\ bn_v a < bn_v n /\
Euclid.is_prime (bn_v n)
val bn_mod_inv_prime_precomp:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t len ->
Pure (lbignum t len)
(requires
bn_mod_inv_prime_pre n a /\
bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\
(1 + bn_v n * v mu) % pow2 (bits t) == 0)
(ensures fun res ->
bn_v res * bn_v a % bn_v n = 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.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",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n: Hacl.Spec.Bignum.Definitions.lbignum t len ->
mu: Hacl.Spec.Bignum.Definitions.limb t ->
r2: Hacl.Spec.Bignum.Definitions.lbignum t len ->
a: Hacl.Spec.Bignum.Definitions.lbignum t len
-> Prims.Pure (Hacl.Spec.Bignum.Definitions.lbignum t len) | Prims.Pure | [] | [] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.unit",
"Hacl.Spec.Bignum.ModInv.mod_inv_prime_lemma",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Lib.NatMod.pow_mod",
"Hacl.Spec.Bignum.Exponentiation.bn_mod_exp_vartime_precompr2",
"FStar.Mul.op_Star",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_n2"
] | [] | false | false | false | false | false | let bn_mod_inv_prime_precomp #t #len n mu r2 a =
| let n2 = bn_mod_inv_prime_n2 n in
bn_eval_bound n len;
let res = BE.bn_mod_exp_vartime_precompr2 len n r2 a (bits t * len) n2 in
assert (bn_v res == Lib.NatMod.pow_mod #(bn_v n) (bn_v a) (bn_v n2));
mod_inv_prime_lemma (bn_v n) (bn_v a);
res | false |
RandomTapes.fst | RandomTapes.add | val add : int -> Tot (bij #int #int) | val add : int -> Tot (bij #int #int) | let add x = cut (inverses (op_Addition x) (minus x)); op_Addition x | {
"file_name": "examples/rel/RandomTapes.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 67,
"end_line": 38,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module RandomTapes
open Rel
open Bijection
(* Experimenting with random tapes *)
type random_tape = int -> Tot int
val sample : random_tape -> int -> Tot int
let sample r i = r i
type rel_random_tape (b:(int -> Tot bij)) = r:(rel random_tape){forall i. b i (R?.l r i) = R?.r r i}
val id : bij #int #int
let id x = x
val minus : int -> int -> Tot int
let minus x y = y - x
(* Proving the function used is a bijection *) | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"Bijection.fst.checked"
],
"interface_file": false,
"source_file": "RandomTapes.fst"
} | [
{
"abbrev": false,
"full_module": "Bijection",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.int -> Bijection.bij | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_Addition",
"Prims.unit",
"Prims.cut",
"Bijection.inverses",
"RandomTapes.minus",
"Bijection.bij"
] | [] | false | false | false | true | false | let add x =
| cut (inverses (op_Addition x) (minus x));
op_Addition x | false |
Hacl.Spec.Bignum.ModInv.fst | Hacl.Spec.Bignum.ModInv.mod_inv_prime_lemma | val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} ->
Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) | val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} ->
Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) | let mod_inv_prime_lemma n a =
Math.Lemmas.small_mod a n;
assert (a == a % n);
assert (a <> 0 /\ a % n <> 0);
calc (==) {
Lib.NatMod.pow_mod #n a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) }
Lib.NatMod.pow a (n - 2) % n * a % n;
(==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n }
Lib.NatMod.pow a (n - 2) * a % n;
(==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 }
Lib.NatMod.pow a (n - 1) % n;
(==) { pow_eq a (n - 1) }
Fermat.pow a (n - 1) % n;
(==) { Fermat.fermat_alt n a }
1;
} | {
"file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 48,
"start_col": 0,
"start_line": 31
} | module Hacl.Spec.Bignum.ModInv
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.LoopCombinators
open Hacl.Spec.Bignum.Definitions
open Hacl.Spec.Bignum
module Fermat = FStar.Math.Fermat
module Euclid = FStar.Math.Euclid
module BE = Hacl.Spec.Bignum.Exponentiation
module BM = Hacl.Spec.Bignum.Montgomery
module BN = Hacl.Spec.Bignum
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
#push-options "--fuel 1"
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
let rec pow_eq a n =
if n = 0 then ()
else pow_eq a (n - 1)
#pop-options
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} ->
Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.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",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "FStar.Math.Euclid",
"short_module": "Euclid"
},
{
"abbrev": true,
"full_module": "FStar.Math.Fermat",
"short_module": "Fermat"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat{1 < n /\ FStar.Math.Euclid.is_prime n} -> a: Prims.pos{a < n}
-> FStar.Pervasives.Lemma (ensures Lib.NatMod.pow_mod a (n - 2) * a % n = 1) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Math.Euclid.is_prime",
"Prims.pos",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Lib.NatMod.pow_mod",
"Prims.op_Subtraction",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Math.Fermat.pow",
"Lib.NatMod.pow",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Lib.NatMod.lemma_pow_mod",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l",
"Lib.NatMod.lemma_pow_add",
"Lib.NatMod.lemma_pow1",
"Hacl.Spec.Bignum.ModInv.pow_eq",
"FStar.Math.Fermat.fermat_alt",
"Prims._assert",
"Prims.op_disEquality",
"FStar.Math.Lemmas.small_mod"
] | [] | false | false | true | false | false | let mod_inv_prime_lemma n a =
| Math.Lemmas.small_mod a n;
assert (a == a % n);
assert (a <> 0 /\ a % n <> 0);
calc ( == ) {
Lib.NatMod.pow_mod #n a (n - 2) * a % n;
( == ) { Lib.NatMod.lemma_pow_mod #n a (n - 2) }
(Lib.NatMod.pow a (n - 2) % n) * a % n;
( == ) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n }
Lib.NatMod.pow a (n - 2) * a % n;
( == ) { (Lib.NatMod.lemma_pow1 a;
Lib.NatMod.lemma_pow_add a (n - 2) 1) }
Lib.NatMod.pow a (n - 1) % n;
( == ) { pow_eq a (n - 1) }
Fermat.pow a (n - 1) % n;
( == ) { Fermat.fermat_alt n a }
1;
} | false |
RandomTapes.fst | RandomTapes.id | val id : bij #int #int | val id : bij #int #int | let id x = x | {
"file_name": "examples/rel/RandomTapes.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 12,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | (*
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 RandomTapes
open Rel
open Bijection
(* Experimenting with random tapes *)
type random_tape = int -> Tot int
val sample : random_tape -> int -> Tot int
let sample r i = r i
type rel_random_tape (b:(int -> Tot bij)) = r:(rel random_tape){forall i. b i (R?.l r i) = R?.r r i} | {
"checked_file": "/",
"dependencies": [
"Rel.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"Bijection.fst.checked"
],
"interface_file": false,
"source_file": "RandomTapes.fst"
} | [
{
"abbrev": false,
"full_module": "Bijection",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Bijection.bij | Prims.Tot | [
"total"
] | [] | [
"Prims.int"
] | [] | false | false | false | true | false | let id x =
| x | false |
Steel.ST.Array.fsti | Steel.ST.Array.length | val length (#elt: Type) (a: array elt) : GTot nat | val length (#elt: Type) (a: array elt) : GTot nat | let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 8,
"end_line": 103,
"start_col": 0,
"start_line": 102
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes, | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Steel.ST.Array.array elt -> Prims.GTot Prims.nat | Prims.GTot | [
"sometrivial"
] | [] | [
"Steel.ST.Array.array",
"FStar.Ghost.reveal",
"Prims.nat",
"FStar.Pervasives.dsnd",
"Steel.ST.Array.ptr",
"FStar.Ghost.erased",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base"
] | [] | false | false | false | false | false | let length (#elt: Type) (a: array elt) : GTot nat =
| dsnd a | false |
Steel.ST.Array.fsti | Steel.ST.Array.is_full_array | val is_full_array (#elt: Type) (a: array elt) : Tot prop | val is_full_array (#elt: Type) (a: array elt) : Tot prop | let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a)) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 40,
"end_line": 188,
"start_col": 0,
"start_line": 187
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name. | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Steel.ST.Array.array elt -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Steel.ST.Array.array",
"Prims.eq2",
"Prims.nat",
"Steel.ST.Array.length",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base",
"Steel.ST.Array.ptr_of",
"Prims.prop"
] | [] | false | false | false | true | true | let is_full_array (#elt: Type) (a: array elt) : Tot prop =
| length a == base_len (base (ptr_of a)) | false |
Hacl.EC.K256.fst | Hacl.EC.K256.point_mul | val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit
(requires fun h ->
live h scalar /\ live h p /\ live h out /\
disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\
P.point_inv h p /\
BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
S.to_aff_point (P.point_eval h1 out) ==
S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p))) | val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit
(requires fun h ->
live h scalar /\ live h p /\ live h out /\
disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\
P.point_inv h p /\
BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
S.to_aff_point (P.point_eval h1 out) ==
S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p))) | let point_mul scalar p out =
push_frame ();
let scalar_q = Q.create_qelem () in
Q.load_qelem scalar_q scalar;
PM.point_mul out scalar_q p;
pop_frame () | {
"file_name": "code/k256/Hacl.EC.K256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 333,
"start_col": 0,
"start_line": 328
} | module Hacl.EC.K256
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module S = Spec.K256
module F = Hacl.K256.Field
module Q = Hacl.K256.Scalar
module FI = Hacl.Impl.K256.Finv
module P = Hacl.Impl.K256.Point
module PA = Hacl.Impl.K256.PointAdd
module PD = Hacl.Impl.K256.PointDouble
module PM = Hacl.Impl.K256.PointMul
module BL = Hacl.Spec.K256.Field52.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@@ CPrologue
"/*******************************************************************************
Verified field arithmetic modulo p = 2^256 - 0x1000003D1.
This is a 64-bit optimized version, where a field element in radix-2^{52} is
represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5].
*******************************************************************************/\n";
Comment "Write the additive identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_zero: f:F.felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero)
let mk_felem_zero f =
Math.Lemmas.small_mod S.zero S.prime;
F.set_zero f
[@@ Comment "Write the multiplicative identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_one: f:F.felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one)
let mk_felem_one f =
Math.Lemmas.small_mod S.one S.prime;
F.set_one f
[@@ Comment "Write `a + b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_add (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b))
let felem_add a b out =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b);
F.fadd out a b;
let h1 = ST.get () in
assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4));
BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out);
F.fnormalize_weak out out
[@@ Comment "Write `a - b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_sub (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b))
let felem_sub a b out =
let h0 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2);
F.fsub out a b (u64 2);
let h1 = ST.get () in
assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6));
BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out);
F.fnormalize_weak out out
[@@ Comment "Write `a * b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_mul (a b out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\
F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b))
let felem_mul a b out =
F.fmul out a b
[@@ Comment "Write `a * a mod p` in `out`.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are either disjoint or equal"]
val felem_sqr (a out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h out /\ eq_or_disjoint out a /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a))
let felem_sqr a out =
F.fsqr out a
[@@ Comment "Write `a ^ (p - 2) mod p` in `out`.
The function computes modular multiplicative inverse if `a` <> zero.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_inv (a out:F.felem) : Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == S.finv (F.feval h0 a))
let felem_inv a out =
FI.finv out a
[@@ Comment "Load a bid-endian field element from memory.
The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32].
The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `b` and `out` are disjoint"]
val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit
(requires fun h -> live h b /\ live h out /\ disjoint b out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F.inv_lazy_reduced2 h1 out /\
F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime)
let felem_load b out =
F.load_felem out b
[@@ Comment "Serialize a field element into big-endian memory.
The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5].
The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F.inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a))
let felem_store a out =
push_frame ();
let tmp = F.create_felem () in
let h0 = ST.get () in
BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a);
F.fnormalize tmp a;
F.store_felem out tmp;
pop_frame ()
[@@ CPrologue
"/*******************************************************************************
Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7.
This is a 64-bit optimized version, where a group element in projective coordinates
is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15].
*******************************************************************************/\n";
Comment "Write the point at infinity (additive identity) in `p`.
The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."]
val mk_point_at_inf: p:P.point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf)
let mk_point_at_inf p =
P.make_point_at_inf p
[@@ Comment "Write the base point (generator) in `p`.
The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."]
val mk_base_point: p:P.point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
P.point_inv h1 p /\ P.point_eval h1 p == S.g)
let mk_base_point p =
P.make_g p
[@@ Comment "Write `-p` in `out` (point negation).
The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p` and `out` are either disjoint or equal"]
val point_negate (p out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint out p /\
P.point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.point_negate (P.point_eval h0 p))
let point_negate p out =
P.point_negate out p
[@@ Comment "Write `p + q` in `out` (point addition).
The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p`, `q`, and `out` are either pairwise disjoint or equal"]
val point_add (p q out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\
P.point_inv h p /\ P.point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q))
let point_add p q out =
PA.point_add out p q
[@@ Comment "Write `p + p` in `out` (point doubling).
The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p` and `out` are either disjoint or equal"]
val point_double (p out:P.point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint p out /\
P.point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p))
let point_double p out =
PD.point_double out p
[@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication).
The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15].
The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32].
The function first loads a bid-endian scalar element from `scalar` and
then computes a point multiplication.
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `scalar`, `p`, and `out` are pairwise disjoint"]
val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit
(requires fun h ->
live h scalar /\ live h p /\ live h out /\
disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\
P.point_inv h p /\
BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
P.point_inv h1 out /\
S.to_aff_point (P.point_eval h1 out) ==
S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p))) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.PointMul.fsti.checked",
"Hacl.Impl.K256.PointDouble.fst.checked",
"Hacl.Impl.K256.PointAdd.fst.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"Hacl.Impl.K256.Finv.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.EC.K256.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointMul",
"short_module": "PM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointDouble",
"short_module": "PD"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.PointAdd",
"short_module": "PA"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.Point",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.K256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.K256.Scalar",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "Hacl.K256.Field",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
scalar: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
p: Hacl.Impl.K256.Point.point ->
out: Hacl.Impl.K256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.K256.Point.point",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.K256.PointMul.point_mul",
"Hacl.K256.Scalar.load_qelem",
"Hacl.K256.Scalar.qelem",
"Hacl.K256.Scalar.create_qelem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let point_mul scalar p out =
| push_frame ();
let scalar_q = Q.create_qelem () in
Q.load_qelem scalar_q scalar;
PM.point_mul out scalar_q p;
pop_frame () | false |
OPLSS.MAC.fst | OPLSS.MAC.mac | val mac (k: key) (m: HMACSHA1.msg)
: ST HMACSHA1.tag
(requires invariant k)
(ensures
fun h0 t h1 ->
invariant k h1 /\ B.modifies (Log.fp k.log) h0 h1 /\ t == HMACSHA1.hmac_sha1 k.raw m /\
(if Flag.reveal Ideal.uf_cma
then log k h1 == Seq.snoc (log k h0) (Entry m t)
else log k h1 == log k h0)) | val mac (k: key) (m: HMACSHA1.msg)
: ST HMACSHA1.tag
(requires invariant k)
(ensures
fun h0 t h1 ->
invariant k h1 /\ B.modifies (Log.fp k.log) h0 h1 /\ t == HMACSHA1.hmac_sha1 k.raw m /\
(if Flag.reveal Ideal.uf_cma
then log k h1 == Seq.snoc (log k h0) (Entry m t)
else log k h1 == log k h0)) | let mac (k:key) (m:HMACSHA1.msg)
: ST HMACSHA1.tag
(requires
invariant k)
(ensures fun h0 t h1 ->
invariant k h1 /\
B.modifies (Log.fp k.log) h0 h1 /\
t == HMACSHA1.hmac_sha1 k.raw m /\
(if Flag.reveal Ideal.uf_cma
then log k h1 == Seq.snoc (log k h0) (Entry m t)
else log k h1 == log k h0))
= let t = HMACSHA1.hmac_sha1 k.raw m in
//CRYPTO HYPOTHESIS
// () ~ (Log.add k.log Entry m t)
//The log is private
if Flag.idealizing Ideal.uf_cma
then Log.add k.log (Entry m t);
t | {
"file_name": "examples/crypto/OPLSS.MAC.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 79,
"start_col": 0,
"start_line": 62
} | (*
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 OPLSS.MAC
(* This module idealizes HMACSHA1 as an UF-CMA MAC *)
open OPLSS
open FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
module HS = FStar.HyperStack
/// The UF-CMA log associates messages with tags
type log_entry =
| Entry: msg:HMACSHA1.msg
-> tag:HMACSHA1.tag
-> log_entry
/// A key packages a raw HMACSHA1 key with the ideal UF-CMA log
noeq
type key =
| Key: raw:HMACSHA1.sha1_key
-> log:Log.t log_entry
-> key
let loc (k:key) = B.loc_mreference k.log
let log (k:key) (h:HS.mem) = Log.entries k.log h
/// The invariant is simply that the log is live
let invariant (k:key) (h:HS.mem) : Type =
HS.contains h k.log
/// Generating a new MAC'ing key
/// - satisfying the invariant
/// - allocating _fresh_ state for the log
/// - intializing it to the empty log
let keygen ()
: ST key
(requires fun _ -> True)
(ensures fun h0 k h1 ->
invariant k h1 /\
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (Log.fp k.log) h0 h1 /\
log k h1 == Seq.empty)
= let raw = random HMACSHA1.keysize in
let l = Log.new_log #log_entry in
Key raw l
/// `mac k m`:
/// Concretely, it's just HMACSHA1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"OPLSS.Log.fst.checked",
"OPLSS.Ideal.fsti.checked",
"OPLSS.HMACSHA1.fst.checked",
"OPLSS.Flag.fsti.checked",
"OPLSS.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "OPLSS.MAC.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: OPLSS.MAC.key -> m: OPLSS.HMACSHA1.msg -> FStar.HyperStack.ST.ST OPLSS.HMACSHA1.tag | FStar.HyperStack.ST.ST | [] | [] | [
"OPLSS.MAC.key",
"OPLSS.HMACSHA1.msg",
"OPLSS.HMACSHA1.tag",
"Prims.unit",
"OPLSS.Flag.idealizing",
"OPLSS.Ideal.uf_cma",
"OPLSS.Log.add",
"OPLSS.MAC.log_entry",
"OPLSS.MAC.__proj__Key__item__log",
"OPLSS.MAC.Entry",
"Prims.bool",
"OPLSS.HMACSHA1.hmac_sha1",
"OPLSS.MAC.__proj__Key__item__raw",
"OPLSS.MAC.invariant",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"OPLSS.Log.fp",
"Prims.eq2",
"OPLSS.Flag.reveal",
"FStar.Seq.Base.seq",
"OPLSS.MAC.log",
"FStar.Seq.Properties.snoc",
"Prims.logical"
] | [] | false | true | false | false | false | let mac (k: key) (m: HMACSHA1.msg)
: ST HMACSHA1.tag
(requires invariant k)
(ensures
fun h0 t h1 ->
invariant k h1 /\ B.modifies (Log.fp k.log) h0 h1 /\ t == HMACSHA1.hmac_sha1 k.raw m /\
(if Flag.reveal Ideal.uf_cma
then log k h1 == Seq.snoc (log k h0) (Entry m t)
else log k h1 == log k h0)) =
| let t = HMACSHA1.hmac_sha1 k.raw m in
if Flag.idealizing Ideal.uf_cma then Log.add k.log (Entry m t);
t | false |
Steel.ST.Array.fsti | Steel.ST.Array.read | val read : a: Steel.ST.Array.array t -> i: FStar.SizeT.t -> Steel.ST.Effect.ST t | let read #t #p = index #t #p | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 28,
"end_line": 268,
"start_col": 0,
"start_line": 268
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Steel.ST.Array.array t -> i: FStar.SizeT.t -> Steel.ST.Effect.ST t | Steel.ST.Effect.ST | [] | [] | [
"Steel.FractionalPermission.perm",
"Steel.ST.Array.index",
"Steel.ST.Array.array",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"FStar.SizeT.t",
"Steel.ST.Array.pts_to",
"FStar.Ghost.reveal",
"Steel.Effect.Common.vprop",
"Prims.l_or",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.SizeT.v",
"Steel.ST.Array.length",
"FStar.Seq.Base.length",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.index"
] | [] | false | true | false | false | false | let read #t #p =
| index #t #p | false |
|
Hacl.Impl.Curve25519.AddAndDouble.fst | Hacl.Impl.Curve25519.AddAndDouble.point_double | val point_double:
#s:field_spec
-> nq:point s
-> tmp1:lbuffer (limb s) (4ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 nq /\ live h0 tmp1 /\ live h0 tmp2 /\
disjoint nq tmp1 /\ disjoint nq tmp2 /\ disjoint tmp1 tmp2 /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq))
(ensures fun h0 _ h1 ->
modifies (loc nq |+| loc tmp1 |+| loc tmp2) h0 h1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == P.double (fget_xz h0 nq)) | val point_double:
#s:field_spec
-> nq:point s
-> tmp1:lbuffer (limb s) (4ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 nq /\ live h0 tmp1 /\ live h0 tmp2 /\
disjoint nq tmp1 /\ disjoint nq tmp2 /\ disjoint tmp1 tmp2 /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq))
(ensures fun h0 _ h1 ->
modifies (loc nq |+| loc tmp1 |+| loc tmp2) h0 h1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == P.double (fget_xz h0 nq)) | let point_double #s nq tmp1 tmp2 =
let x2 = sub nq 0ul (nlimb s) in
let z2 = sub nq (nlimb s) (nlimb s) in
let a : felem s = sub tmp1 0ul (nlimb s) in
let b : felem s = sub tmp1 (nlimb s) (nlimb s) in
let d : felem s = sub tmp1 (2ul *! nlimb s) (nlimb s) in
let c : felem s = sub tmp1 (3ul *! nlimb s) (nlimb s) in
let ab : felem2 s = sub tmp1 0ul (2ul *! nlimb s) in
let dc : felem2 s = sub tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
let h0 = ST.get () in
assert (gsub nq 0ul (nlimb s) == x2);
assert (gsub nq (nlimb s) (nlimb s) == z2);
assert (gsub ab 0ul (nlimb s) == a);
assert (gsub ab (nlimb s) (nlimb s) == b);
assert (gsub dc 0ul (nlimb s) == d);
assert (gsub dc (nlimb s) (nlimb s) == c);
fadd a x2 z2; // a = x2 + z2
fsub b x2 z2; // b = x2 - z2
(* CAN RUN IN PARALLEL *)
//fsqr d a; // d = aa = a^2
//fsqr c b; // c = bb = b^2
fsqr2 dc ab tmp2; // d|c = aa | bb
copy_felem a c; // a = bb
fsub c d c; // c = e = aa - bb
assert_norm (121665 < pow2 17);
fmul1 b c (u64 121665); // b = e * 121665
fadd b b d; // b = (e * 121665) + aa
(* CAN RUN IN PARALLEL *)
//fmul x2 d a; // x2 = aa * bb
//fmul z2 c b; // z2 = e * (aa + (e * 121665))
fmul2 nq dc ab tmp2 | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.AddAndDouble.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 245,
"start_col": 0,
"start_line": 210
} | module Hacl.Impl.Curve25519.AddAndDouble
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
module ST = FStar.HyperStack.ST
module F51 = Hacl.Impl.Curve25519.Field51
module F64 = Hacl.Impl.Curve25519.Field64
module P = Spec.Curve25519
module S = Hacl.Spec.Curve25519.AddAndDouble
#reset-options "--z3rlimit 300 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq' --record_options"
inline_for_extraction noextract
let point (s:field_spec) = lbuffer (limb s) (nlimb s +! nlimb s)
(* NEEDED ONLY FOR WRAPPERS *)
inline_for_extraction noextract
let point51 = lbuffer uint64 10ul
inline_for_extraction noextract
let point64 = lbuffer uint64 8ul
(* NEEDED ONLY FOR WRAPPERS *)
let get_x #s (p:point s) = gsub p 0ul (nlimb s)
let get_z #s (p:point s) = gsub p (nlimb s) (nlimb s)
let fget_x (#s:field_spec) (h:mem) (p:point s) = feval h (gsub p 0ul (nlimb s))
let fget_z (#s:field_spec) (h:mem) (p:point s) = feval h (gsub p (nlimb s) (nlimb s))
let fget_xz (#s:field_spec) (h:mem) (p:point s) = fget_x h p, fget_z h p
val point_post_sub_t:#s:field_spec -> h:mem -> f:felem s -> Type0
let point_post_sub_t #s h f =
match s with
| M51 -> F51.felem_fits h f (9, 10, 9, 9, 9)
| M64 -> True
val point_post_add_t:#s:field_spec -> h:mem -> f:felem s -> Type0
let point_post_add_t #s h f =
match s with
| M51 -> F51.felem_fits h f (2, 4, 2, 2, 2)
| M64 -> True
val point_add_and_double0:
#s:field_spec
-> nq_p1:point s
-> ab:lbuffer (limb s) (2ul *! nlimb s)
-> dc:lbuffer (limb s) (2ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 nq_p1 /\ live h0 ab /\ live h0 dc /\ live h0 tmp2 /\
disjoint nq_p1 ab /\ disjoint nq_p1 dc /\ disjoint nq_p1 tmp2 /\
disjoint ab dc /\ disjoint ab tmp2 /\ disjoint dc tmp2 /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1) /\
point_post_add_t h0 (gsub ab 0ul (nlimb s)) /\
point_post_sub_t h0 (gsub ab (nlimb s) (nlimb s)))
(ensures fun h0 _ h1 ->
modifies (loc nq_p1 |+| loc dc |+| loc tmp2) h0 h1 /\
point_post_add_t h1 (get_x nq_p1) /\ point_post_sub_t h1 (get_z nq_p1) /\
fget_xz h1 nq_p1 == S.add_and_double1_0 (fget_x h0 ab) (fget_z h0 ab) (fget_xz h0 nq_p1))
[@ Meta.Attribute.inline_ ]
let point_add_and_double0 #s nq_p1 ab dc tmp2 =
let x3 = sub nq_p1 0ul (nlimb s) in
let z3 = sub nq_p1 (nlimb s) (nlimb s) in
let a : felem s = sub ab 0ul (nlimb s) in
let b : felem s = sub ab (nlimb s) (nlimb s) in
let d : felem s = sub dc 0ul (nlimb s) in
let c : felem s = sub dc (nlimb s) (nlimb s) in
fadd c x3 z3; // c = x3 + z3
fsub d x3 z3; // d = x3 - z3
(* CAN RUN IN PARALLEL *)
//fmul d d a; // d = da = d * a
//fmul c c b; // c = cb = c * b
fmul2 dc dc ab tmp2; // d|c = d*a|c*b
fadd x3 d c; // x3 = da + cb
fsub z3 d c // z3 = da - cb
val point_add_and_double1:
#s:field_spec
-> nq:point s
-> nq_p1:point s
-> tmp1:lbuffer (limb s) (4ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 nq /\ live h0 nq_p1 /\ live h0 tmp1 /\ live h0 tmp2 /\
disjoint nq nq_p1 /\ disjoint nq tmp1 /\ disjoint nq tmp2 /\
disjoint nq_p1 tmp1 /\ disjoint nq_p1 tmp2 /\ disjoint tmp1 tmp2 /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
point_post_add_t h0 (gsub tmp1 0ul (nlimb s)) /\
point_post_sub_t h0 (gsub tmp1 (nlimb s) (nlimb s)) /\
point_post_add_t h0 (get_x nq_p1) /\ point_post_sub_t h0 (get_z nq_p1))
(ensures fun h0 _ h1 ->
modifies (loc nq |+| loc nq_p1 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\
(fget_xz h1 nq, fget_xz h1 nq_p1) ==
S.add_and_double1_1 (feval h0 (gsub tmp1 0ul (nlimb s)))
(feval h0 (gsub tmp1 (nlimb s) (nlimb s))) (fget_xz h0 nq_p1))
[@ Meta.Attribute.inline_ ]
let point_add_and_double1 #s nq nq_p1 tmp1 tmp2 =
let x2 = sub nq 0ul (nlimb s) in
let z2 = sub nq (nlimb s) (nlimb s) in
let x3 = sub nq_p1 0ul (nlimb s) in
let z3 = sub nq_p1 (nlimb s) (nlimb s) in
let a : felem s = sub tmp1 0ul (nlimb s) in
let b : felem s = sub tmp1 (nlimb s) (nlimb s) in
let d : felem s = sub tmp1 (2ul *! nlimb s) (nlimb s) in
let c : felem s = sub tmp1 (3ul *! nlimb s) (nlimb s) in
let ab : felem2 s = sub tmp1 0ul (2ul *! nlimb s) in
let dc : felem2 s = sub tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
(* CAN RUN IN PARALLEL *)
//fsqr d a; // d = aa = a^2
//fsqr c b; // c = bb = b^2
fsqr2 dc ab tmp2; // d|c = aa | bb
(* CAN RUN IN PARALLEL *)
//fsqr x3 x3; // x3 = (da + cb) ^ 2
//fsqr z3 z3; // z3 = (da - cb) ^ 2
fsqr2 nq_p1 nq_p1 tmp2; // x3|z3 = x3*x3|z3*z3
copy_felem a c; // a = bb
fsub c d c; // c = e = aa - bb
assert_norm (121665 < pow2 17);
fmul1 b c (u64 121665); // b = e * 121665
fadd b b d; // b = (e * 121665) + aa
(* CAN RUN IN PARALLEL *)
//fmul x2 d a; // x2 = aa * bb
//fmul z2 c b; // z2 = e * (aa + (e * 121665))
fmul2 nq dc ab tmp2 // x2|z2 = aa * bb | e * (aa + (e * 121665))
val point_add_and_double:
#s:field_spec
-> q:point s
-> p01_tmp1:lbuffer (limb s) (8ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
live h0 q /\ live h0 p01_tmp1 /\ live h0 tmp2 /\
disjoint q p01_tmp1 /\ disjoint q tmp2 /\ disjoint p01_tmp1 tmp2 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1))
(ensures fun h0 _ h1 -> (
let nq = gsub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
modifies (loc p01_tmp1 |+| loc tmp2) h0 h1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1) /\
(let p2, p3 = P.add_and_double (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1) in
fget_xz h1 nq == p2 /\ fget_xz h1 nq_p1 == p3)))
#push-options "--z3rlimit 450"
[@ Meta.Attribute.specialize ]
let point_add_and_double #s q p01_tmp1 tmp2 =
let h0 = ST.get () in
let nq : point s = sub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 : point s = sub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
let tmp1 = sub p01_tmp1 (4ul *! nlimb s) (4ul *! nlimb s) in
let x1 = sub q 0ul (nlimb s) in
let x2 = sub nq 0ul (nlimb s) in
let z2 = sub nq (nlimb s) (nlimb s) in
let z3 = sub nq_p1 (nlimb s) (nlimb s) in
let a : felem s = sub tmp1 0ul (nlimb s) in
let b : felem s = sub tmp1 (nlimb s) (nlimb s) in
let ab : felem2 s = sub tmp1 0ul (2ul *! nlimb s) in
let dc : felem2 s = sub tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
fadd a x2 z2; // a = x2 + z2
fsub b x2 z2; // b = x2 - z2
point_add_and_double0 #s nq_p1 ab dc tmp2;
point_add_and_double1 #s nq nq_p1 tmp1 tmp2;
fmul z3 z3 x1 tmp2; // z3 = x1 * (da - cb) ^ 2
S.lemma_add_and_double (fget_xz h0 q) (fget_xz h0 nq) (fget_xz h0 nq_p1)
#pop-options
val point_double:
#s:field_spec
-> nq:point s
-> tmp1:lbuffer (limb s) (4ul *! nlimb s)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 nq /\ live h0 tmp1 /\ live h0 tmp2 /\
disjoint nq tmp1 /\ disjoint nq tmp2 /\ disjoint tmp1 tmp2 /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq))
(ensures fun h0 _ h1 ->
modifies (loc nq |+| loc tmp1 |+| loc tmp2) h0 h1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
fget_xz h1 nq == P.double (fget_xz h0 nq)) | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.Field64.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.AddAndDouble.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field64",
"short_module": "F64"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "F51"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
nq: Hacl.Impl.Curve25519.AddAndDouble.point s ->
tmp1:
Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s)
(4ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s) ->
tmp2: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.AddAndDouble.point",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Hacl.Impl.Curve25519.Fields.Core.fmul2",
"Prims.unit",
"Hacl.Impl.Curve25519.Fields.Core.fadd",
"Hacl.Impl.Curve25519.Fields.Core.fmul1",
"Lib.IntTypes.u64",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Hacl.Impl.Curve25519.Fields.Core.fsub",
"Hacl.Impl.Curve25519.Fields.copy_felem",
"Hacl.Impl.Curve25519.Fields.Core.fsqr2",
"Prims._assert",
"Prims.eq2",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.gsub",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Plus_Bang",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Lib.Buffer.sub",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | false | true | false | false | false | let point_double #s nq tmp1 tmp2 =
| let x2 = sub nq 0ul (nlimb s) in
let z2 = sub nq (nlimb s) (nlimb s) in
let a:felem s = sub tmp1 0ul (nlimb s) in
let b:felem s = sub tmp1 (nlimb s) (nlimb s) in
let d:felem s = sub tmp1 (2ul *! nlimb s) (nlimb s) in
let c:felem s = sub tmp1 (3ul *! nlimb s) (nlimb s) in
let ab:felem2 s = sub tmp1 0ul (2ul *! nlimb s) in
let dc:felem2 s = sub tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
let h0 = ST.get () in
assert (gsub nq 0ul (nlimb s) == x2);
assert (gsub nq (nlimb s) (nlimb s) == z2);
assert (gsub ab 0ul (nlimb s) == a);
assert (gsub ab (nlimb s) (nlimb s) == b);
assert (gsub dc 0ul (nlimb s) == d);
assert (gsub dc (nlimb s) (nlimb s) == c);
fadd a x2 z2;
fsub b x2 z2;
fsqr2 dc ab tmp2;
copy_felem a c;
fsub c d c;
assert_norm (121665 < pow2 17);
fmul1 b c (u64 121665);
fadd b b d;
fmul2 nq dc ab tmp2 | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_fw_acc0 | val exp_fw_acc0
(#t: Type0)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos{bBits % l <> 0})
: t | val exp_fw_acc0
(#t: Type0)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos{bBits % l <> 0})
: t | let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t
=
let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in
pow k a bits_c | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 149,
"start_col": 0,
"start_line": 145
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b)
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit)
let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let (r0, r1) = S.cswap sw r0 r1 in
r0
val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b)
let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
Loops.repeat b k.sqr a
val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b)
[@(strict_on_arguments [3])]
let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
if b = 0 then k.one ()
else k.mul a (pow k a (b - 1))
val pow_eq0: #t:Type -> k:concrete_ops t -> a:t ->
Lemma (pow k a 0 == k.one ())
val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos ->
Lemma (pow k a i == k.mul a (pow k a (i - 1)))
val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
a: t ->
bBits: Prims.nat ->
b: Prims.nat{b < Prims.pow2 bBits} ->
l: Prims.pos{bBits % l <> 0}
-> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.pos",
"Prims.op_disEquality",
"Prims.int",
"Prims.op_Modulus",
"Spec.Exponentiation.pow",
"Lib.Exponentiation.get_ith_lbits",
"FStar.Mul.op_Star",
"Prims.op_Division"
] | [] | false | false | false | false | false | let exp_fw_acc0
(#t: Type0)
(k: concrete_ops t)
(a: t)
(bBits: nat)
(b: nat{b < pow2 bBits})
(l: pos{bBits % l <> 0})
: t =
| let bits_c = S.get_ith_lbits bBits b ((bBits / l) * l) l in
pow k a bits_c | false |
Spec.Exponentiation.fsti | Spec.Exponentiation.exp_four_fw_f | val exp_four_fw_f
(#t: Type)
(k: concrete_ops t)
(a1: t)
(bBits: nat)
(b1: nat{b1 < pow2 bBits})
(a2: t)
(b2: nat{b2 < pow2 bBits})
(a3: t)
(b3: nat{b3 < pow2 bBits})
(a4: t)
(b4: nat{b4 < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t | val exp_four_fw_f
(#t: Type)
(k: concrete_ops t)
(a1: t)
(bBits: nat)
(b1: nat{b1 < pow2 bBits})
(a2: t)
(b2: nat{b2 < pow2 bBits})
(a3: t)
(b3: nat{b3 < pow2 bBits})
(a4: t)
(b4: nat{b4 < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t | let exp_four_fw_f (#t:Type) (k:concrete_ops t)
(a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits})
(a2:t) (b2:nat{b2 < pow2 bBits})
(a3:t) (b3:nat{b3 < pow2 bBits})
(a4:t) (b4:nat{b4 < pow2 bBits})
(l:pos) (i:nat{i < bBits / l}) (acc:t) : t
=
let acc = exp_fw_f k a4 bBits b4 l i acc in
let acc = mul_acc_pow_a_bits_l k a3 bBits b3 l i acc in
let acc = mul_acc_pow_a_bits_l k a2 bBits b2 l i acc in
let acc = mul_acc_pow_a_bits_l k a1 bBits b1 l i acc in
acc | {
"file_name": "specs/Spec.Exponentiation.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 243,
"start_col": 0,
"start_line": 232
} | module Spec.Exponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module S = Lib.Exponentiation
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(**
This is a specification for generic exponentiation defined as
a repeated application of a commutative monoid operation.
• Modular Exponentiation: repeated modular multiplication
• Elliptic Curve Scalar Multiplication: repeated point addition
In hacl-star, in order to obtain a verified C implementation,
we split our proofs into three steps:
• high-level specification (lib/Lib.Exponentiation)
• low-level specification (specs/Spec.Exponentiation)
• low-star implementation (code/bignum/Hacl.Impl.Exponentiation)
For example, to efficiently compute the EC scalar multiplication
for Ed25519, we use point addition and doubling formulas in
projective coordinates (see specs/Spec.Ed25519).
• we first prove that (points on the curve, aff_point_add) forms
a commutative monoid (`mk_ed25519_comm_monoid`)
• we then prove the relation between point addition and doubling
formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`)
• finally, we can obtain any implementation of exponentiation,
e.g., a double fixed-window method, by providing the corresponding
instance of the `concrete_ops` type class (`point_mul_double`)
Another example is using Montgomery arithmetic (code/bignum) to compute
a modular exponentiation (lib/Lib.NatMod).
*)
inline_for_extraction
class to_comm_monoid (t:Type) = {
a_spec: Type;
comm_monoid: S.comm_monoid a_spec;
refl: x:t -> a_spec;
}
inline_for_extraction
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t
(requires True)
(ensures fun one ->
to.refl one == to.comm_monoid.S.one)
inline_for_extraction
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
inline_for_extraction
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t
(requires True)
(ensures fun xy ->
to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
inline_for_extraction
class concrete_ops (t:Type) = {
to: to_comm_monoid t;
one: one_st t to;
mul: mul_st t to;
sqr: sqr_st t to;
}
let exp_rl_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t
=
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in
let c = k.sqr c in
(acc, c)
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let one = k.one () in
let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in
acc
val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b)
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t)
(bBits:nat) (b:nat{b < pow2 bBits})
(i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat
=
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in
let sw = (bit + privbit) % 2 in
let r0, r1 = S.cswap sw r0 r1 in
let r0, r1 = (k.sqr r0, k.mul r1 r0) in
(r0, r1, bit)
let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t =
let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in
let (r0, r1) = S.cswap sw r0 r1 in
r0
val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} ->
Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b)
let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
Loops.repeat b k.sqr a
val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b)
[@(strict_on_arguments [3])]
let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t =
if b = 0 then k.one ()
else k.mul a (pow k a (b - 1))
val pow_eq0: #t:Type -> k:concrete_ops t -> a:t ->
Lemma (pow k a 0 == k.one ())
val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos ->
Lemma (pow k a i == k.mul a (pow k a (i - 1)))
val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat ->
Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b)
let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t
=
let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in
pow k a bits_c
let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t
=
let bits_l = S.get_bits_l bBits b l i in
k.mul acc (pow k a bits_l)
let exp_fw_f (#t:Type) (k:concrete_ops t) (a:t)
(bBits:nat) (b:nat{b < pow2 bBits}) (l:pos)
(i:nat{i < bBits / l}) (acc:t) : t
=
let acc1 = exp_pow2 k acc l in
mul_acc_pow_a_bits_l k a bBits b l i acc1
let exp_fw (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t =
let acc0 = if bBits % l = 0 then one () else exp_fw_acc0 k a bBits b l in
Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0
val exp_fw_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos ->
Lemma (k.to.refl (exp_fw k a bBits b l) == S.exp_fw k.to.comm_monoid (k.to.refl a) bBits b l)
/// Multi-Exponentiation
// Double exponentiation [a1^b1 `mul` a2^b2]
//-------------------------------------------
let exp_double_fw_acc0 (#t:Type) (k:concrete_ops t)
(a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits})
(a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t
=
let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in
let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in
k.mul acc_a1 acc_a2
let exp_double_fw_f (#t:Type) (k:concrete_ops t)
(a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits})
(a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos)
(i:nat{i < bBits / l}) (acc:t) : t
=
let acc1 = exp_fw_f k a2 bBits b2 l i acc in
mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1
let exp_double_fw (#t:Type) (k:concrete_ops t)
(a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits})
(a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) : t
=
let acc0 =
if bBits % l = 0 then one ()
else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in
Loops.repeati (bBits / l)
(exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0
val exp_double_fw_lemma: #t:Type -> k:concrete_ops t
-> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits}
-> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos ->
Lemma (k.to.refl (exp_double_fw k a1 bBits b1 a2 b2 l) ==
S.exp_double_fw k.to.comm_monoid (k.to.refl a1) bBits b1 (k.to.refl a2) b2 l)
// [a1^b1 `mul` a2^b2 `mul` a3^b3 `mul` a4^b4]
//----------------------------------------------
let exp_four_fw_acc0 (#t:Type) (k:concrete_ops t)
(a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits})
(a2:t) (b2:nat{b2 < pow2 bBits})
(a3:t) (b3:nat{b3 < pow2 bBits})
(a4:t) (b4:nat{b4 < pow2 bBits})
(l:pos{bBits % l <> 0}) : t
=
let acc_a12 = exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in
let acc_a34 = exp_double_fw_acc0 k a3 bBits b3 a4 b4 l in
k.mul acc_a12 acc_a34 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Exponentiation.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "S"
},
{
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.Exponentiation.concrete_ops t ->
a1: t ->
bBits: Prims.nat ->
b1: Prims.nat{b1 < Prims.pow2 bBits} ->
a2: t ->
b2: Prims.nat{b2 < Prims.pow2 bBits} ->
a3: t ->
b3: Prims.nat{b3 < Prims.pow2 bBits} ->
a4: t ->
b4: Prims.nat{b4 < Prims.pow2 bBits} ->
l: Prims.pos ->
i: Prims.nat{i < bBits / l} ->
acc: t
-> t | Prims.Tot | [
"total"
] | [] | [
"Spec.Exponentiation.concrete_ops",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.pos",
"Prims.op_Division",
"Spec.Exponentiation.mul_acc_pow_a_bits_l",
"Spec.Exponentiation.exp_fw_f"
] | [] | false | false | false | false | false | let exp_four_fw_f
(#t: Type)
(k: concrete_ops t)
(a1: t)
(bBits: nat)
(b1: nat{b1 < pow2 bBits})
(a2: t)
(b2: nat{b2 < pow2 bBits})
(a3: t)
(b3: nat{b3 < pow2 bBits})
(a4: t)
(b4: nat{b4 < pow2 bBits})
(l: pos)
(i: nat{i < bBits / l})
(acc: t)
: t =
| let acc = exp_fw_f k a4 bBits b4 l i acc in
let acc = mul_acc_pow_a_bits_l k a3 bBits b3 l i acc in
let acc = mul_acc_pow_a_bits_l k a2 bBits b2 l i acc in
let acc = mul_acc_pow_a_bits_l k a1 bBits b1 l i acc in
acc | false |
LowParse.Low.Writers.Instances.fst | LowParse.Low.Writers.Instances.swrite_bitsum | val swrite_bitsum
(h0: HS.mem)
(space_beyond: nat)
(sout:
slice (srel_of_buffer_srel (B.trivial_preorder _))
(srel_of_buffer_srel (B.trivial_preorder _)))
(pout_from0: U32.t)
(#kt: parser_kind)
(#tot: pos)
(#t: eqtype)
(#cl: uint_t tot t)
(b: bitsum' cl tot)
(#data: Type)
(tag_of_data: (data -> Tot (bitsum'_type b)))
(type_of_tag: (bitsum'_key_type b -> Tot Type))
(synth_case: synth_case_t b data tag_of_data type_of_tag)
(#p: parser kt t)
(#s: serializer p {kt.parser_kind_subkind == Some ParserStrong})
(w_tg: leaf_writer_strong s)
(mk: synth_bitsum'_recip_t b)
(#f: (x: bitsum'_key_type b -> Tot (k: parser_kind & parser k (type_of_tag x))))
(g: (x: bitsum'_key_type b -> Tot (serializer (dsnd (f x)))))
(k:
bitsum'_type b
{ (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\
(dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong })
(w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0)
: Tot
(w':
swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g)
h0
space_beyond
sout
pout_from0 {swvalue w' == synth_case.f k (swvalue w_pl)}) | val swrite_bitsum
(h0: HS.mem)
(space_beyond: nat)
(sout:
slice (srel_of_buffer_srel (B.trivial_preorder _))
(srel_of_buffer_srel (B.trivial_preorder _)))
(pout_from0: U32.t)
(#kt: parser_kind)
(#tot: pos)
(#t: eqtype)
(#cl: uint_t tot t)
(b: bitsum' cl tot)
(#data: Type)
(tag_of_data: (data -> Tot (bitsum'_type b)))
(type_of_tag: (bitsum'_key_type b -> Tot Type))
(synth_case: synth_case_t b data tag_of_data type_of_tag)
(#p: parser kt t)
(#s: serializer p {kt.parser_kind_subkind == Some ParserStrong})
(w_tg: leaf_writer_strong s)
(mk: synth_bitsum'_recip_t b)
(#f: (x: bitsum'_key_type b -> Tot (k: parser_kind & parser k (type_of_tag x))))
(g: (x: bitsum'_key_type b -> Tot (serializer (dsnd (f x)))))
(k:
bitsum'_type b
{ (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\
(dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong })
(w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0)
: Tot
(w':
swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g)
h0
space_beyond
sout
pout_from0 {swvalue w' == synth_case.f k (swvalue w_pl)}) | let swrite_bitsum
(h0: HS.mem)
(space_beyond: nat)
(sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(pout_from0: U32.t)
(#kt: parser_kind)
(#tot: pos)
(#t: eqtype)
(#cl: uint_t tot t)
(b: bitsum' cl tot)
(#data: Type)
(tag_of_data: (data -> Tot (bitsum'_type b)))
(type_of_tag: (bitsum'_key_type b -> Tot Type))
(synth_case: synth_case_t b data tag_of_data type_of_tag)
(#p: parser kt t)
(#s: serializer p { kt.parser_kind_subkind == Some ParserStrong } )
(w_tg: leaf_writer_strong s)
(mk: synth_bitsum'_recip_t b)
(#f: (x: bitsum'_key_type b) -> Tot (k: parser_kind & parser k (type_of_tag x)))
(g: (x: bitsum'_key_type b) -> Tot (serializer (dsnd (f x))))
(k: bitsum'_type b {
(parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\
(dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong
})
(w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0)
: Tot (w' : swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 {
swvalue w' == synth_case.f k (swvalue w_pl)
})
= SWriter (Ghost.hide (synth_case.f k (swvalue w_pl))) (fun pout_from ->
serialized_length_eq (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) (synth_case.f k (swvalue w_pl));
serialized_length_eq s (synth_bitsum'_recip b k);
serialized_length_eq (g (bitsum'_key_of_t b k)) (swvalue w_pl);
serialize_bitsum_eq_2 b tag_of_data type_of_tag synth_case s g k (swvalue w_pl);
let pos1 = w_tg (mk k) sout pout_from in
let pos2 = swrite w_pl pos1 in
let h = HST.get () in
valid_filter h p (filter_bitsum' b) sout pout_from;
synth_bitsum'_injective b;
synth_bitsum'_recip_inverse b;
assert (filter_bitsum' b (mk k) == true);
assert (synth_bitsum' b (mk k) == k);
valid_synth h (p `parse_filter` filter_bitsum' b) (synth_bitsum' b) sout pout_from;
valid_bitsum_intro b tag_of_data type_of_tag synth_case p f h sout pout_from;
pos2
) | {
"file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 298,
"start_col": 0,
"start_line": 254
} | module LowParse.Low.Writers.Instances
include LowParse.Low.Writers
include LowParse.Low.Combinators
include LowParse.Low.Bytes
include LowParse.Low.BitSum
module HS = FStar.HyperStack
module B = LowStar.Buffer
module U32 = FStar.UInt32
module HST = FStar.HyperStack.ST
inline_for_extraction
noextract
let swrite_weaken
(#h0: HS.mem)
(#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(#pout_from0: U32.t)
(#k1: parser_kind)
(#t1: Type)
(#p1: parser k1 t1)
(#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong })
(#space_beyond: nat)
(k2: parser_kind)
(w1: swriter s1 h0 space_beyond sout pout_from0 {
(k2 `is_weaker_than` k1) /\
k2.parser_kind_subkind == Some ParserStrong
})
: Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 {
swvalue w2 == swvalue w1
})
= SWriter (Ghost.hide (swvalue w1)) (fun pout_from ->
serialized_length_eq s1 (swvalue w1);
serialized_length_eq (serialize_weaken k2 s1) (swvalue w1);
let res = swrite w1 pout_from in
let h = HST.get () in
valid_weaken k2 p1 h sout pout_from;
res
)
inline_for_extraction
noextract
let swrite_nondep_then'
(#h0: HS.mem)
(#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(#pout_from0: U32.t)
(#k1: parser_kind)
(#t1: Type)
(#p1: parser k1 t1)
(#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong })
(#space_beyond: nat)
(w1: swriter s1 h0 space_beyond sout pout_from0)
(#k2: parser_kind)
(#t2: Type)
(#p2: parser k2 t2)
(#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong })
(w2: swriter s2 h0 space_beyond sout pout_from0)
: Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 {
swvalue w == (swvalue w1, swvalue w2)
})
= SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from ->
serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2);
serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2);
serialized_length_eq s1 (swvalue w1);
serialized_length_eq s2 (swvalue w2);
let pos1 = swrite w1 pout_from in
let pos2 = swrite w2 pos1 in
let h' = HST.get () in
valid_nondep_then h' p1 p2 sout pout_from;
pos2
)
let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2
inline_for_extraction
noextract
let swrite_nondep_then
(#h0: HS.mem)
(#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(#pout_from0: U32.t)
(#k1: parser_kind)
(#t1: Type)
(#p1: parser k1 t1)
(#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong })
(#space_beyond1: nat)
(w1: swriter s1 h0 space_beyond1 sout pout_from0)
(#k2: parser_kind)
(#t2: Type)
(#p2: parser k2 t2)
(#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong })
(#space_beyond2: nat)
(w2: swriter s2 h0 space_beyond2 sout pout_from0)
: Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 {
swvalue w == (swvalue w1, swvalue w2)
})
= [@inline_let]
let sbmax = space_beyond1 `max` space_beyond2 in
weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0
inline_for_extraction
noextract
let swrite_filter
(#h0: HS.mem)
(#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(#pout_from0: U32.t)
(#k1: parser_kind)
(#t1: Type)
(#p1: parser k1 t1)
(#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong })
(#space_beyond: nat)
(cond: (t1 -> GTot bool))
(w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } )
: Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 {
swvalue w2 == swvalue w1
})
= SWriter (Ghost.hide (swvalue w1)) (fun pout_from ->
serialized_length_eq (serialize_filter s1 cond) (swvalue w1);
serialized_length_eq s1 (swvalue w1);
let res = swrite w1 pout_from in
let h = HST.get () in
valid_filter h p1 cond sout pout_from;
res
)
inline_for_extraction
noextract
let swrite_synth
(#h0: HS.mem)
(#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(#pout_from0: U32.t)
(#k1: parser_kind)
(#t1: Type)
(#p1: parser k1 t1)
(#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong })
(#space_beyond: nat)
(w1: swriter s1 h0 space_beyond sout pout_from0)
(#t2: Type)
(f12: (t1 -> GTot t2))
(f21: (t2 -> GTot t1))
(prf: squash (
synth_injective f12 /\
synth_inverse f12 f21
))
: Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 {
swvalue w2 == f12 (swvalue w1) /\
swvalue w1 == f21 (swvalue w2)
})
= [@inline_let] let _ =
serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1));
synth_injective_synth_inverse_synth_inverse_recip f12 f21 ()
in
SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from ->
serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1));
serialized_length_eq s1 (swvalue w1);
let res = swrite w1 pout_from in
let h = HST.get () in
valid_synth h p1 f12 sout pout_from;
res
)
module U8 = FStar.UInt8
module FB = FStar.Bytes
#push-options "--z3rlimit 16"
inline_for_extraction
noextract
let swrite_flbytes
(h0: HS.mem)
(sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(pout_from0: U32.t)
(len: U32.t)
(b: B.buffer U8.t {
B.live h0 b /\
B.length b == U32.v len /\
B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0)
})
: Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 {
swvalue w == FB.hide (B.as_seq h0 b)
})
= SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from ->
serialized_length_eq (serialize_flbytes (U32.v len)) (FB.hide (B.as_seq h0 b));
let payload = B.sub sout.base pout_from len in
B.blit b 0ul payload 0ul len;
let h = HST.get () in
valid_flbytes_intro h (U32.v len) sout pout_from;
pout_from `U32.add` len
)
inline_for_extraction
noextract
let swrite_bounded_vlbytes
(h0: HS.mem)
(sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(pout_from0: U32.t)
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(len: U32.t { min <= U32.v len /\ U32.v len <= max })
(b: B.buffer U8.t {
B.length b == U32.v len /\
B.live h0 b /\
B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0)
})
: Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 {
swvalue w == FB.hide (B.as_seq h0 b)
})
= SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from ->
serialized_length_eq (serialize_bounded_vlbytes min max) (FB.hide (B.as_seq h0 b));
length_serialize_bounded_vlbytes min max (FB.hide (B.as_seq h0 b));
let pout_payload = pout_from `U32.add` U32.uint_to_t (log256' max) in
let payload = B.sub sout.base pout_payload len in
B.blit b 0ul payload 0ul len;
finalize_bounded_vlbytes min max sout pout_from len
)
inline_for_extraction
noextract
let swrite_bounded_vlgenbytes
(h0: HS.mem)
(sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _)))
(pout_from0: U32.t)
(min: nat)
(max: nat { min <= max /\ max > 0 /\ max < 4294967296 })
(#kk: parser_kind)
(#pk: parser kk (bounded_int32 min max))
(#sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong })
(wk: leaf_writer_strong sk)
(len: U32.t { min <= U32.v len /\ U32.v len <= max })
(b: B.buffer U8.t {
B.live h0 b /\
B.length b == U32.v len /\
B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0)
})
: Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 {
swvalue w == FB.hide (B.as_seq h0 b)
})
= SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from ->
serialized_length_eq (serialize_bounded_vlgenbytes min max sk) (FB.hide (B.as_seq h0 b));
length_serialize_bounded_vlgenbytes min max sk (FB.hide (B.as_seq h0 b));
serialized_length_eq sk len;
let pout_payload = swrite (swrite_leaf wk h0 sout pout_from0 len) pout_from in
let payload = B.sub sout.base pout_payload len in
B.blit b 0ul payload 0ul len;
let h = HST.get () in
valid_bounded_vlgenbytes min max pk sout pout_from h;
pout_payload `U32.add` len
)
#pop-options
#push-options "--z3rlimit 32"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Endianness.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Writers.fst.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.Bytes.fst.checked",
"LowParse.Low.BitSum.fst.checked",
"LowParse.Endianness.BitFields.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.Writers.Instances.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "FB"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BitSum",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Writers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Writers",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Writers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h0: FStar.Monotonic.HyperStack.mem ->
space_beyond: Prims.nat ->
sout:
LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte
))
(LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) ->
pout_from0: FStar.UInt32.t ->
b: LowParse.Spec.BitSum.bitsum' cl tot ->
tag_of_data: (_: data -> LowParse.Spec.BitSum.bitsum'_type b) ->
type_of_tag: (_: LowParse.Spec.BitSum.bitsum'_key_type b -> Type) ->
synth_case: LowParse.Spec.BitSum.synth_case_t b data tag_of_data type_of_tag ->
w_tg: LowParse.Low.Base.leaf_writer_strong s ->
mk: LowParse.Spec.BitSum.synth_bitsum'_recip_t b ->
g:
(x: LowParse.Spec.BitSum.bitsum'_key_type b
-> LowParse.Spec.Base.serializer (FStar.Pervasives.dsnd (f x))) ->
k:
LowParse.Spec.BitSum.bitsum'_type b
{ Mkparser_kind'?.parser_kind_subkind (LowParse.Spec.BitSum.parse_bitsum_kind kt
b
type_of_tag
f) ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\
Mkparser_kind'?.parser_kind_subkind (FStar.Pervasives.dfst (f (LowParse.Spec.BitSum.bitsum'_key_of_t
b
k))) ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
w_pl:
LowParse.Low.Writers.swriter (g (LowParse.Spec.BitSum.bitsum'_key_of_t b k))
h0
space_beyond
sout
pout_from0
-> w':
LowParse.Low.Writers.swriter (LowParse.Spec.BitSum.serialize_bitsum b
tag_of_data
type_of_tag
synth_case
s
g)
h0
space_beyond
sout
pout_from0
{ LowParse.Low.Writers.swvalue w' ==
SynthCase?.f synth_case k (LowParse.Low.Writers.swvalue w_pl) } | Prims.Tot | [
"total"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"LowParse.Slice.slice",
"LowParse.Slice.srel_of_buffer_srel",
"LowParse.Bytes.byte",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.t",
"LowParse.Spec.Base.parser_kind",
"Prims.pos",
"Prims.eqtype",
"LowParse.BitFields.uint_t",
"LowParse.Spec.BitSum.bitsum'",
"LowParse.Spec.BitSum.bitsum'_type",
"LowParse.Spec.BitSum.bitsum'_key_type",
"LowParse.Spec.BitSum.synth_case_t",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.Low.Base.leaf_writer_strong",
"LowParse.Spec.BitSum.synth_bitsum'_recip_t",
"Prims.dtuple2",
"Prims.__proj__Mkdtuple2__item___1",
"FStar.Pervasives.dsnd",
"Prims.l_and",
"LowParse.Spec.BitSum.parse_bitsum_kind",
"FStar.Pervasives.dfst",
"LowParse.Spec.BitSum.bitsum'_key_of_t",
"LowParse.Low.Writers.swriter",
"LowParse.Low.Writers.SWriter",
"LowParse.Spec.BitSum.parse_bitsum",
"LowParse.Spec.BitSum.serialize_bitsum",
"FStar.Ghost.hide",
"LowParse.Spec.BitSum.__proj__SynthCase__item__f",
"LowParse.Low.Writers.swvalue",
"Prims.unit",
"LowParse.Low.BitSum.valid_bitsum_intro",
"LowParse.Low.Combinators.valid_synth",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"LowParse.Spec.BitSum.filter_bitsum'",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.BitSum.synth_bitsum'",
"Prims._assert",
"Prims.bool",
"LowParse.Spec.BitSum.synth_bitsum'_recip_inverse",
"LowParse.Spec.BitSum.synth_bitsum'_injective",
"LowParse.Low.Combinators.valid_filter",
"FStar.HyperStack.ST.get",
"LowParse.Low.Writers.swrite",
"LowParse.Spec.BitSum.serialize_bitsum_eq_2",
"LowParse.Low.Base.Spec.serialized_length_eq",
"LowParse.Spec.BitSum.synth_bitsum'_recip"
] | [] | false | false | false | false | false | let swrite_bitsum
(h0: HS.mem)
(space_beyond: nat)
(sout:
slice (srel_of_buffer_srel (B.trivial_preorder _))
(srel_of_buffer_srel (B.trivial_preorder _)))
(pout_from0: U32.t)
(#kt: parser_kind)
(#tot: pos)
(#t: eqtype)
(#cl: uint_t tot t)
(b: bitsum' cl tot)
(#data: Type)
(tag_of_data: (data -> Tot (bitsum'_type b)))
(type_of_tag: (bitsum'_key_type b -> Tot Type))
(synth_case: synth_case_t b data tag_of_data type_of_tag)
(#p: parser kt t)
(#s: serializer p {kt.parser_kind_subkind == Some ParserStrong})
(w_tg: leaf_writer_strong s)
(mk: synth_bitsum'_recip_t b)
(#f: (x: bitsum'_key_type b -> Tot (k: parser_kind & parser k (type_of_tag x))))
(g: (x: bitsum'_key_type b -> Tot (serializer (dsnd (f x)))))
(k:
bitsum'_type b
{ (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\
(dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong })
(w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0)
: Tot
(w':
swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g)
h0
space_beyond
sout
pout_from0 {swvalue w' == synth_case.f k (swvalue w_pl)}) =
| SWriter (Ghost.hide (synth_case.f k (swvalue w_pl)))
(fun pout_from ->
serialized_length_eq (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g)
(synth_case.f k (swvalue w_pl));
serialized_length_eq s (synth_bitsum'_recip b k);
serialized_length_eq (g (bitsum'_key_of_t b k)) (swvalue w_pl);
serialize_bitsum_eq_2 b tag_of_data type_of_tag synth_case s g k (swvalue w_pl);
let pos1 = w_tg (mk k) sout pout_from in
let pos2 = swrite w_pl pos1 in
let h = HST.get () in
valid_filter h p (filter_bitsum' b) sout pout_from;
synth_bitsum'_injective b;
synth_bitsum'_recip_inverse b;
assert (filter_bitsum' b (mk k) == true);
assert (synth_bitsum' b (mk k) == k);
valid_synth h (p `parse_filter` (filter_bitsum' b)) (synth_bitsum' b) sout pout_from;
valid_bitsum_intro b tag_of_data type_of_tag synth_case p f h sout pout_from;
pos2) | false |
Steel.ST.Array.fsti | Steel.ST.Array.alloc | val alloc : x: elt -> n: FStar.SizeT.t -> Steel.ST.Effect.ST (Steel.ST.Array.array elt) | let alloc #elt = malloc #elt | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 28,
"end_line": 207,
"start_col": 0,
"start_line": 207
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: elt -> n: FStar.SizeT.t -> Steel.ST.Effect.ST (Steel.ST.Array.array elt) | Steel.ST.Effect.ST | [] | [] | [
"Steel.ST.Array.malloc",
"FStar.SizeT.t",
"Steel.ST.Array.array",
"Steel.Effect.Common.emp",
"Steel.ST.Array.pts_to",
"Steel.FractionalPermission.full_perm",
"FStar.Seq.Base.create",
"FStar.SizeT.v",
"Steel.Effect.Common.vprop",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"Steel.ST.Array.length",
"Steel.ST.Array.is_full_array"
] | [] | false | true | false | false | false | let alloc #elt =
| malloc #elt | false |
|
Steel.ST.Array.fsti | Steel.ST.Array.write | val write : a: Steel.ST.Array.array t ->
i: FStar.SizeT.t{FStar.SizeT.v i < FStar.Seq.Base.length (FStar.Ghost.reveal s)} ->
v: t
-> Steel.ST.Effect.STT Prims.unit | let write #t = upd #t | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 21,
"end_line": 286,
"start_col": 0,
"start_line": 286
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction
[@@noextract_to "krml"]
let read #t #p = index #t #p
/// Writing the value v at the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val upd
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t {US.v i < Seq.length s})
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Steel.ST.Array.array t ->
i: FStar.SizeT.t{FStar.SizeT.v i < FStar.Seq.Base.length (FStar.Ghost.reveal s)} ->
v: t
-> Steel.ST.Effect.STT Prims.unit | Steel.ST.Effect.STT | [] | [] | [
"Steel.ST.Array.upd",
"Steel.ST.Array.array",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"FStar.SizeT.t",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.SizeT.v",
"FStar.Seq.Base.length",
"FStar.Ghost.reveal",
"Prims.unit",
"Steel.ST.Array.pts_to",
"Steel.FractionalPermission.full_perm",
"FStar.Seq.Base.upd",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let write #t =
| upd #t | false |
|
Steel.ST.Array.fsti | Steel.ST.Array.adjacent | val adjacent (#elt: Type) (a1 a2: array elt) : Tot prop | val adjacent (#elt: Type) (a1 a2: array elt) : Tot prop | let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
base (ptr_of a1) == base (ptr_of a2) /\
offset (ptr_of a1) + (length a1) == offset (ptr_of a2) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 56,
"end_line": 293,
"start_col": 0,
"start_line": 291
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction
[@@noextract_to "krml"]
let read #t #p = index #t #p
/// Writing the value v at the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val upd
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t {US.v i < Seq.length s})
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
inline_for_extraction
[@@noextract_to "krml"]
let write #t = upd #t
/// An array a1 is adjacent to an array a2 if and only if they have
/// the same base array and the end of a1 coincides with the beginning | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a1: Steel.ST.Array.array elt -> a2: Steel.ST.Array.array elt -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Steel.ST.Array.array",
"Prims.l_and",
"Prims.eq2",
"Steel.ST.Array.base_t",
"Steel.ST.Array.base",
"Steel.ST.Array.ptr_of",
"Prims.int",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"Steel.ST.Array.length",
"Prims.prop"
] | [] | false | false | false | true | true | let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
| base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2) | false |
FStar.Printf.fst | FStar.Printf.no_extensions | val no_extensions:extension_parser | val no_extensions:extension_parser | let no_extensions : extension_parser = fun s -> None | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 52,
"end_line": 185,
"start_col": 0,
"start_line": 185
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension
/// `arg_type`: Interpreting a `arg` tag as a type
let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t
let string_of_arg (#a:arg) (x:arg_type a) : string =
match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x
/// `dir`: Internal to this module
/// A 'directive"; used when parsing a format specifier
noeq
type dir =
| Lit of char
| Arg of arg
/// `dir_type ds`: Interpreting a list directives as a pure function type
let rec dir_type (ds:list dir) : Tot Type0 =
match ds with
| [] -> string
| Lit c :: ds' -> dir_type ds'
| Arg a :: ds' -> arg_type a -> dir_type ds'
/// `string_of_dirs ds`:
/// Interpreting a list of directives as its function,
/// in a continuation-passing style
let rec string_of_dirs
(ds:list dir)
(k:string -> string)
: dir_type ds
= match ds with
| [] -> k ""
| Lit c :: ds' ->
coerce_eq () (
string_of_dirs ds' (fun res -> k (string_of_char c ^ res))
)
| Arg a :: ds' ->
fun (x : arg_type a) ->
string_of_dirs ds' (fun res -> ((k "")
^ string_of_arg x
^ res))
type extension_parser = i:list char -> option (extension * o:list char{o << i})
/// `parse_format s`:
/// Parses a list of characters into a list of directives
/// Or None, in case the format string is invalid
let rec parse_format
(s:list char)
(parse_ext: extension_parser)
: option (list dir)
= let add_dir (d:dir) (ods : option (list dir))
: option (list dir)
= match ods with
| None -> None
| Some ds -> Some (d::ds)
in
match s with
| [] -> Some []
| ['%'] -> None
//Unsigned integers beging with '%u'
| '%' :: 'u' :: s' -> begin
match s' with
| 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext)
| 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext)
| 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext)
| 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext)
| _ -> None
end
//User extensions begin with '%X'
| '%' :: 'X' :: s' -> begin
match parse_ext s' with
| Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext)
| _ -> None
end
| '%' :: c :: s' -> begin
match c with
| '%' -> add_dir (Lit '%') (parse_format s' parse_ext)
| 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext)
| 'd' -> add_dir (Arg Int) (parse_format s' parse_ext)
| 'c' -> add_dir (Arg Char) (parse_format s' parse_ext)
| 's' -> add_dir (Arg String) (parse_format s' parse_ext)
| 'y' -> add_dir (Arg I8) (parse_format s' parse_ext)
| 'i' -> add_dir (Arg I16) (parse_format s' parse_ext)
| 'l' -> add_dir (Arg I32) (parse_format s' parse_ext)
| 'L' -> add_dir (Arg I64) (parse_format s' parse_ext)
| _ -> None
end
| c :: s' ->
add_dir (Lit c) (parse_format s' parse_ext)
/// `parse_format_string`: parses a format `string` into a list of directives
let parse_format_string
(s:string)
(parse_ext:extension_parser)
: option (list dir)
= parse_format (list_of_string s) parse_ext | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Printf.extension_parser | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"FStar.String.char",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"FStar.Printf.extension",
"Prims.precedes",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let no_extensions:extension_parser =
| fun s -> None | false |
FStar.Printf.fst | FStar.Printf.parse_format_string | val parse_format_string (s: string) (parse_ext: extension_parser) : option (list dir) | val parse_format_string (s: string) (parse_ext: extension_parser) : option (list dir) | let parse_format_string
(s:string)
(parse_ext:extension_parser)
: option (list dir)
= parse_format (list_of_string s) parse_ext | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 45,
"end_line": 183,
"start_col": 0,
"start_line": 179
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension
/// `arg_type`: Interpreting a `arg` tag as a type
let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t
let string_of_arg (#a:arg) (x:arg_type a) : string =
match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x
/// `dir`: Internal to this module
/// A 'directive"; used when parsing a format specifier
noeq
type dir =
| Lit of char
| Arg of arg
/// `dir_type ds`: Interpreting a list directives as a pure function type
let rec dir_type (ds:list dir) : Tot Type0 =
match ds with
| [] -> string
| Lit c :: ds' -> dir_type ds'
| Arg a :: ds' -> arg_type a -> dir_type ds'
/// `string_of_dirs ds`:
/// Interpreting a list of directives as its function,
/// in a continuation-passing style
let rec string_of_dirs
(ds:list dir)
(k:string -> string)
: dir_type ds
= match ds with
| [] -> k ""
| Lit c :: ds' ->
coerce_eq () (
string_of_dirs ds' (fun res -> k (string_of_char c ^ res))
)
| Arg a :: ds' ->
fun (x : arg_type a) ->
string_of_dirs ds' (fun res -> ((k "")
^ string_of_arg x
^ res))
type extension_parser = i:list char -> option (extension * o:list char{o << i})
/// `parse_format s`:
/// Parses a list of characters into a list of directives
/// Or None, in case the format string is invalid
let rec parse_format
(s:list char)
(parse_ext: extension_parser)
: option (list dir)
= let add_dir (d:dir) (ods : option (list dir))
: option (list dir)
= match ods with
| None -> None
| Some ds -> Some (d::ds)
in
match s with
| [] -> Some []
| ['%'] -> None
//Unsigned integers beging with '%u'
| '%' :: 'u' :: s' -> begin
match s' with
| 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext)
| 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext)
| 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext)
| 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext)
| _ -> None
end
//User extensions begin with '%X'
| '%' :: 'X' :: s' -> begin
match parse_ext s' with
| Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext)
| _ -> None
end
| '%' :: c :: s' -> begin
match c with
| '%' -> add_dir (Lit '%') (parse_format s' parse_ext)
| 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext)
| 'd' -> add_dir (Arg Int) (parse_format s' parse_ext)
| 'c' -> add_dir (Arg Char) (parse_format s' parse_ext)
| 's' -> add_dir (Arg String) (parse_format s' parse_ext)
| 'y' -> add_dir (Arg I8) (parse_format s' parse_ext)
| 'i' -> add_dir (Arg I16) (parse_format s' parse_ext)
| 'l' -> add_dir (Arg I32) (parse_format s' parse_ext)
| 'L' -> add_dir (Arg I64) (parse_format s' parse_ext)
| _ -> None
end
| c :: s' ->
add_dir (Lit c) (parse_format s' parse_ext) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Prims.string -> parse_ext: FStar.Printf.extension_parser
-> FStar.Pervasives.Native.option (Prims.list FStar.Printf.dir) | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"FStar.Printf.extension_parser",
"FStar.Printf.parse_format",
"FStar.String.list_of_string",
"FStar.Pervasives.Native.option",
"Prims.list",
"FStar.Printf.dir"
] | [] | false | false | false | true | false | let parse_format_string (s: string) (parse_ext: extension_parser) : option (list dir) =
| parse_format (list_of_string s) parse_ext | false |
HyE.Plain.fst | HyE.Plain.repr | val repr: p:t{not conf} -> Tot r | val repr: p:t{not conf} -> Tot r | let repr t = t | {
"file_name": "examples/crypto/HyE.Plain.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 25,
"start_col": 0,
"start_line": 25
} | (*
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 HyE.Plain
open Platform.Bytes
open CoreCrypto
open HyE.Ideal
type t = bytes | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Platform.Bytes.fst.checked",
"HyE.Ideal.fsti.checked",
"FStar.Pervasives.fsti.checked",
"CoreCrypto.fst.checked"
],
"interface_file": true,
"source_file": "HyE.Plain.fst"
} | [
{
"abbrev": false,
"full_module": "HyE.Ideal",
"short_module": null
},
{
"abbrev": false,
"full_module": "CoreCrypto",
"short_module": null
},
{
"abbrev": false,
"full_module": "Platform.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "HyE",
"short_module": null
},
{
"abbrev": false,
"full_module": "HyE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: HyE.Plain.t{Prims.op_Negation HyE.Ideal.conf} -> HyE.Plain.r | Prims.Tot | [
"total"
] | [] | [
"HyE.Plain.t",
"Prims.b2t",
"Prims.op_Negation",
"HyE.Ideal.conf",
"HyE.Plain.r"
] | [] | false | false | false | false | false | let repr t =
| t | false |
HyE.Plain.fst | HyE.Plain.coerce | val coerce: x:r -> Tot t | val coerce: x:r -> Tot t | let coerce t =t | {
"file_name": "examples/crypto/HyE.Plain.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 15,
"end_line": 27,
"start_col": 0,
"start_line": 27
} | (*
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 HyE.Plain
open Platform.Bytes
open CoreCrypto
open HyE.Ideal
type t = bytes
(* two pure functions, never called when ideal *)
let repr t = t (* a pure function from t to RSA.plain *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Platform.Bytes.fst.checked",
"HyE.Ideal.fsti.checked",
"FStar.Pervasives.fsti.checked",
"CoreCrypto.fst.checked"
],
"interface_file": true,
"source_file": "HyE.Plain.fst"
} | [
{
"abbrev": false,
"full_module": "HyE.Ideal",
"short_module": null
},
{
"abbrev": false,
"full_module": "CoreCrypto",
"short_module": null
},
{
"abbrev": false,
"full_module": "Platform.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "HyE",
"short_module": null
},
{
"abbrev": false,
"full_module": "HyE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: HyE.Plain.r -> HyE.Plain.t | Prims.Tot | [
"total"
] | [] | [
"HyE.Plain.r",
"HyE.Plain.t"
] | [] | false | false | false | true | false | let coerce t =
| t | false |
HyE.Plain.fst | HyE.Plain.length | val length: p:t -> Tot nat | val length: p:t -> Tot nat | let length p = length p | {
"file_name": "examples/crypto/HyE.Plain.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 29,
"start_col": 0,
"start_line": 29
} | (*
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 HyE.Plain
open Platform.Bytes
open CoreCrypto
open HyE.Ideal
type t = bytes
(* two pure functions, never called when ideal *)
let repr t = t (* a pure function from t to RSA.plain *)
let coerce t =t (* a function from r to t *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Platform.Bytes.fst.checked",
"HyE.Ideal.fsti.checked",
"FStar.Pervasives.fsti.checked",
"CoreCrypto.fst.checked"
],
"interface_file": true,
"source_file": "HyE.Plain.fst"
} | [
{
"abbrev": false,
"full_module": "HyE.Ideal",
"short_module": null
},
{
"abbrev": false,
"full_module": "CoreCrypto",
"short_module": null
},
{
"abbrev": false,
"full_module": "Platform.Bytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "HyE",
"short_module": null
},
{
"abbrev": false,
"full_module": "HyE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: HyE.Plain.t -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"HyE.Plain.t",
"Platform.Bytes.length",
"Prims.nat"
] | [] | false | false | false | true | false | let length p =
| length p | false |
Steel.ST.Array.fsti | Steel.ST.Array.merge_into | val merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop | val merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop | let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop =
adjacent a1 a2 /\
merge a1 a2 == a | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 18,
"end_line": 322,
"start_col": 0,
"start_line": 320
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction
[@@noextract_to "krml"]
let read #t #p = index #t #p
/// Writing the value v at the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val upd
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t {US.v i < Seq.length s})
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
inline_for_extraction
[@@noextract_to "krml"]
let write #t = upd #t
/// An array a1 is adjacent to an array a2 if and only if they have
/// the same base array and the end of a1 coincides with the beginning
/// of a2
let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
base (ptr_of a1) == base (ptr_of a2) /\
offset (ptr_of a1) + (length a1) == offset (ptr_of a2)
/// If two arrays are adjacent, then we can compute their merge, with
/// their combined lengths. By virtue of the length being ghost,
/// Karamel will extract it as "let y = a1"
inline_for_extraction
[@@noextract_to "krml"]
let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2))
= (| ptr_of a1, Ghost.hide (length a1 + length a2) |)
/// Adjacency and merging are associative.
let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma
(requires (
(adjacent a1 a2 /\ adjacent a2 a3) \/
(adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/
(adjacent a2 a3 /\ adjacent a1 (merge a2 a3))
))
(ensures (
adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\
merge (merge a1 a2) a3 == merge a1 (merge a2 a3)
))
= () | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a1: Steel.ST.Array.array elt -> a2: Steel.ST.Array.array elt -> a: Steel.ST.Array.array elt
-> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Steel.ST.Array.array",
"Prims.l_and",
"Steel.ST.Array.adjacent",
"Prims.eq2",
"Steel.ST.Array.merge",
"FStar.Ghost.hide",
"Prims.prop"
] | [] | false | false | false | true | true | let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop =
| adjacent a1 a2 /\ merge a1 a2 == a | false |
Vale.Curve25519.FastUtil_helpers.fsti | Vale.Curve25519.FastUtil_helpers.sub_carry | val sub_carry (x y: nat64) (c: bit) : nat64 & bit | val sub_carry (x y: nat64) (c: bit) : nat64 & bit | let sub_carry (x y:nat64) (c:bit) : nat64 & bit
=
if x - (y + c) < 0 then
(x - (y + c) + pow2_64, 1)
else
(x - (y + c)), 0 | {
"file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastUtil_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 17,
"start_col": 0,
"start_line": 12
} | module Vale.Curve25519.FastUtil_helpers
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Mul
open FStar.Tactics
open FStar.Tactics.CanonCommSemiring
open Vale.Curve25519.Fast_defs
let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring () //; dump "Final" | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.Fast_defs.fst.checked",
"prims.fst.checked",
"FStar.Tactics.CanonCommSemiring.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Curve25519.FastUtil_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonCommSemiring",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Vale.Def.Types_s.nat64 -> y: Vale.Def.Types_s.nat64 -> c: Vale.Curve25519.Fast_defs.bit
-> Vale.Def.Types_s.nat64 * Vale.Curve25519.Fast_defs.bit | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat64",
"Vale.Curve25519.Fast_defs.bit",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Prims.op_Addition",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Def.Words_s.pow2_64",
"Prims.bool",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | true | false | let sub_carry (x y: nat64) (c: bit) : nat64 & bit =
| if x - (y + c) < 0 then (x - (y + c) + pow2_64, 1) else (x - (y + c)), 0 | false |
FStar.Printf.fst | FStar.Printf.arg_type | val arg_type (a: arg) : Tot Type0 | val arg_type (a: arg) : Tot Type0 | let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 75,
"start_col": 0,
"start_line": 61
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.Printf.arg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Printf.arg",
"Prims.bool",
"Prims.int",
"FStar.String.char",
"Prims.string",
"FStar.UInt8.t",
"FStar.UInt16.t",
"FStar.UInt32.t",
"FStar.UInt64.t",
"FStar.Int8.t",
"FStar.Int16.t",
"FStar.Int32.t",
"FStar.Int64.t"
] | [] | false | false | false | true | true | let arg_type (a: arg) : Tot Type0 =
| match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t | false |
FStar.Printf.fst | FStar.Printf.string_of_dirs | val string_of_dirs (ds: list dir) (k: (string -> string)) : dir_type ds | val string_of_dirs (ds: list dir) (k: (string -> string)) : dir_type ds | let rec string_of_dirs
(ds:list dir)
(k:string -> string)
: dir_type ds
= match ds with
| [] -> k ""
| Lit c :: ds' ->
coerce_eq () (
string_of_dirs ds' (fun res -> k (string_of_char c ^ res))
)
| Arg a :: ds' ->
fun (x : arg_type a) ->
string_of_dirs ds' (fun res -> ((k "")
^ string_of_arg x
^ res)) | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 124,
"start_col": 0,
"start_line": 110
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension
/// `arg_type`: Interpreting a `arg` tag as a type
let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t
let string_of_arg (#a:arg) (x:arg_type a) : string =
match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x
/// `dir`: Internal to this module
/// A 'directive"; used when parsing a format specifier
noeq
type dir =
| Lit of char
| Arg of arg
/// `dir_type ds`: Interpreting a list directives as a pure function type
let rec dir_type (ds:list dir) : Tot Type0 =
match ds with
| [] -> string
| Lit c :: ds' -> dir_type ds'
| Arg a :: ds' -> arg_type a -> dir_type ds'
/// `string_of_dirs ds`:
/// Interpreting a list of directives as its function, | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ds: Prims.list FStar.Printf.dir -> k: (_: Prims.string -> Prims.string) -> FStar.Printf.dir_type ds | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"FStar.Printf.dir",
"Prims.string",
"FStar.String.char",
"FStar.Pervasives.coerce_eq",
"FStar.Printf.dir_type",
"FStar.Printf.string_of_dirs",
"Prims.op_Hat",
"FStar.String.string_of_char",
"FStar.Printf.arg",
"FStar.Printf.arg_type",
"FStar.Printf.string_of_arg"
] | [
"recursion"
] | false | false | false | false | false | let rec string_of_dirs (ds: list dir) (k: (string -> string)) : dir_type ds =
| match ds with
| [] -> k ""
| Lit c :: ds' -> coerce_eq () (string_of_dirs ds' (fun res -> k (string_of_char c ^ res)))
| Arg a :: ds' ->
fun (x: arg_type a) -> string_of_dirs ds' (fun res -> ((k "") ^ string_of_arg x ^ res)) | false |
FStar.Printf.fst | FStar.Printf.string_of_arg | val string_of_arg (#a: arg) (x: arg_type a) : string | val string_of_arg (#a: arg) (x: arg_type a) : string | let string_of_arg (#a:arg) (x:arg_type a) : string =
match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 91,
"start_col": 0,
"start_line": 77
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension
/// `arg_type`: Interpreting a `arg` tag as a type
let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.Printf.arg_type a -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"FStar.Printf.arg",
"FStar.Printf.arg_type",
"Prims.string_of_bool",
"Prims.string_of_int",
"FStar.String.string_of_char",
"FStar.UInt8.to_string",
"FStar.UInt16.to_string",
"FStar.UInt32.to_string",
"FStar.UInt64.to_string",
"FStar.Int8.to_string",
"FStar.Int16.to_string",
"FStar.Int32.to_string",
"FStar.Int64.to_string",
"Prims.string"
] | [] | false | false | false | false | false | let string_of_arg (#a: arg) (x: arg_type a) : string =
| match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x | false |
Hacl.Impl.Load56.fst | Hacl.Impl.Load56.lemma_load_64_bytes | val lemma_load_64_bytes (k: lbytes 64) (b0 b1 b2 b3 b4 b5 b6 b7 b8 b9: uint64)
: Lemma
(requires
v b0 == nat_from_bytes_le (Seq.slice k 0 7) /\ v b1 == nat_from_bytes_le (Seq.slice k 7 14) /\
v b2 == nat_from_bytes_le (Seq.slice k 14 21) /\
v b3 == nat_from_bytes_le (Seq.slice k 21 28) /\
v b4 == nat_from_bytes_le (Seq.slice k 28 35) /\
v b5 == nat_from_bytes_le (Seq.slice k 35 42) /\
v b6 == nat_from_bytes_le (Seq.slice k 42 49) /\
v b7 == nat_from_bytes_le (Seq.slice k 49 56) /\
v b8 == nat_from_bytes_le (Seq.slice k 56 63) /\ v b9 == v (Seq.index k 63))
(ensures S56.wide_as_nat5 (b0, b1, b2, b3, b4, b5, b6, b7, b8, b9) == nat_from_bytes_le k) | val lemma_load_64_bytes (k: lbytes 64) (b0 b1 b2 b3 b4 b5 b6 b7 b8 b9: uint64)
: Lemma
(requires
v b0 == nat_from_bytes_le (Seq.slice k 0 7) /\ v b1 == nat_from_bytes_le (Seq.slice k 7 14) /\
v b2 == nat_from_bytes_le (Seq.slice k 14 21) /\
v b3 == nat_from_bytes_le (Seq.slice k 21 28) /\
v b4 == nat_from_bytes_le (Seq.slice k 28 35) /\
v b5 == nat_from_bytes_le (Seq.slice k 35 42) /\
v b6 == nat_from_bytes_le (Seq.slice k 42 49) /\
v b7 == nat_from_bytes_le (Seq.slice k 49 56) /\
v b8 == nat_from_bytes_le (Seq.slice k 56 63) /\ v b9 == v (Seq.index k 63))
(ensures S56.wide_as_nat5 (b0, b1, b2, b3, b4, b5, b6, b7, b8, b9) == nat_from_bytes_le k) | let lemma_load_64_bytes (k:lbytes 64) (b0 b1 b2 b3 b4 b5 b6 b7 b8 b9:uint64) : Lemma
(requires
v b0 == nat_from_bytes_le (Seq.slice k 0 7) /\
v b1 == nat_from_bytes_le (Seq.slice k 7 14) /\
v b2 == nat_from_bytes_le (Seq.slice k 14 21) /\
v b3 == nat_from_bytes_le (Seq.slice k 21 28) /\
v b4 == nat_from_bytes_le (Seq.slice k 28 35) /\
v b5 == nat_from_bytes_le (Seq.slice k 35 42) /\
v b6 == nat_from_bytes_le (Seq.slice k 42 49) /\
v b7 == nat_from_bytes_le (Seq.slice k 49 56) /\
v b8 == nat_from_bytes_le (Seq.slice k 56 63) /\
v b9 == v (Seq.index k 63)
)
(ensures S56.wide_as_nat5 (b0, b1, b2, b3, b4, b5, b6, b7, b8, b9) == nat_from_bytes_le k)
=
lemma_nat_from_bytes_le_append (Seq.slice k 0 7) (Seq.slice k 7 14);
lemma_nat_from_bytes_le_append (Seq.slice k 0 14) (Seq.slice k 14 21);
lemma_nat_from_bytes_le_append (Seq.slice k 0 21) (Seq.slice k 21 28);
lemma_nat_from_bytes_le_append (Seq.slice k 0 28) (Seq.slice k 28 35);
lemma_nat_from_bytes_le_append (Seq.slice k 0 35) (Seq.slice k 35 42);
lemma_nat_from_bytes_le_append (Seq.slice k 0 42) (Seq.slice k 42 49);
lemma_nat_from_bytes_le_append (Seq.slice k 0 49) (Seq.slice k 49 56);
lemma_nat_from_bytes_le_append (Seq.slice k 0 56) (Seq.slice k 56 63);
lemma_nat_from_bytes_le_append (Seq.slice k 0 63) (Seq.create 1 (Seq.index k 63));
assert (Seq.append (Seq.slice k 0 7) (Seq.slice k 7 14) `Seq.equal` Seq.slice k 0 14);
assert (Seq.append (Seq.slice k 0 14) (Seq.slice k 14 21) `Seq.equal` Seq.slice k 0 21);
assert (Seq.append (Seq.slice k 0 21) (Seq.slice k 21 28) `Seq.equal` Seq.slice k 0 28);
assert (Seq.append (Seq.slice k 0 28) (Seq.slice k 28 35) `Seq.equal` Seq.slice k 0 35);
assert (Seq.append (Seq.slice k 0 35) (Seq.slice k 35 42) `Seq.equal` Seq.slice k 0 42);
assert (Seq.append (Seq.slice k 0 42) (Seq.slice k 42 49) `Seq.equal` Seq.slice k 0 49);
assert (Seq.append (Seq.slice k 0 49) (Seq.slice k 49 56) `Seq.equal` Seq.slice k 0 56);
assert (Seq.append (Seq.slice k 0 56) (Seq.slice k 56 63) `Seq.equal` Seq.slice k 0 63);
assert (Seq.append (Seq.slice k 0 63) (Seq.create 1 (Seq.index k 63)) `Seq.equal` k);
nat_from_intseq_le_lemma0 (Seq.create 1 (Seq.index k 63));
assert_norm (pow2 56 == 0x100000000000000);
assert_norm (pow2 112 == 0x10000000000000000000000000000);
assert_norm (pow2 168 == 0x1000000000000000000000000000000000000000000);
assert_norm (pow2 224 == 0x100000000000000000000000000000000000000000000000000000000);
assert_norm (pow2 280 == 0x10000000000000000000000000000000000000000000000000000000000000000000000);
assert_norm (pow2 336 == 0x1000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
assert_norm (pow2 392 == 0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
assert_norm (pow2 448 == 0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
assert_norm (pow2 504 == 0x1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) | {
"file_name": "code/ed25519/Hacl.Impl.Load56.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 157,
"end_line": 116,
"start_col": 0,
"start_line": 74
} | module Hacl.Impl.Load56
module ST = FStar.HyperStack.ST
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.ByteSequence
open Lib.Buffer
open Lib.ByteBuffer
module F56 = Hacl.Impl.BignumQ.Mul
module S56 = Hacl.Spec.BignumQ.Definitions
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
inline_for_extraction noextract
val hload56_le:
b:lbuffer uint8 64ul
-> off:size_t{v off <= 56} ->
Stack uint64
(requires fun h -> live h b)
(ensures fun h0 z h1 -> h0 == h1 /\
v z < 0x100000000000000 /\
v z == nat_from_bytes_le (Seq.slice (as_seq h0 b) (v off) (v off + 7))
)
let hload56_le b off =
let h0 = ST.get() in
let b8 = sub b off 8ul in
let z = uint_from_bytes_le b8 in
let z' = z &. u64 0xffffffffffffff in
assert_norm (0xffffffffffffff == pow2 56 - 1);
assert_norm (0x100000000000000 == pow2 56 );
calc (==) {
v z' <: nat;
(==) { }
v (z &. u64 0xffffffffffffff);
(==) { logand_spec z (u64 0xffffffffffffff) }
v z `logand_v` 0xffffffffffffff;
(==) { assert_norm(pow2 56 - 1 == 0xffffffffffffff); UInt.logand_mask (UInt.to_uint_t 64 (v z)) 56 }
(v z % pow2 56);
(==) { lemma_reveal_uint_to_bytes_le #U64 #SEC (as_seq h0 b8) }
nat_from_bytes_le (as_seq h0 b8) % pow2 56;
(==) { nat_from_intseq_le_slice_lemma (as_seq h0 b8) 7 }
(nat_from_bytes_le (Seq.slice (as_seq h0 b8) 0 7) +
pow2 (7 * 8) * nat_from_bytes_le (Seq.slice (as_seq h0 b8) 7 8)) % pow2 56;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(nat_from_bytes_le (Seq.slice (as_seq h0 b8) 0 7))
(pow2 (7 * 8) * nat_from_bytes_le (Seq.slice (as_seq h0 b8) 7 8))
(pow2 56);
FStar.Math.Lemmas.swap_mul (pow2 (7 * 8)) (nat_from_bytes_le (Seq.slice (as_seq h0 b8) 7 8));
FStar.Math.Lemmas.cancel_mul_mod (nat_from_bytes_le (Seq.slice (as_seq h0 b8) 7 8)) (pow2 56) }
nat_from_bytes_le (Seq.slice (as_seq h0 b8) 0 7) <: nat;
};
assert (Seq.equal
(Seq.slice (as_seq h0 b) (v off) (v off + 7))
(Seq.slice (as_seq h0 b8) 0 7));
z'
let lemma_nat_from_bytes_le_append (k1 k2:bytes) : Lemma
(requires Seq.length k1 + Seq.length k2 <= max_size_t)
(ensures nat_from_bytes_le (Seq.append k1 k2) ==
nat_from_bytes_le k1 + pow2 (Seq.length k1 * 8) * nat_from_bytes_le k2) =
let k = Seq.append k1 k2 in
let n = Seq.length k1 + Seq.length k2 in
nat_from_intseq_le_slice_lemma #U8 #SEC #n k (Seq.length k1);
assert (k1 `Seq.equal` Seq.slice k 0 (Seq.length k1));
assert (k2 `Seq.equal` Seq.slice k (Seq.length k1) n)
#push-options "--z3rlimit 100" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.BignumQ.Definitions.fst.checked",
"Hacl.Impl.BignumQ.Mul.fsti.checked",
"Hacl.Bignum25519.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Load56.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.BignumQ.Definitions",
"short_module": "S56"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.BignumQ.Mul",
"short_module": "F56"
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Lib.ByteSequence.lbytes 64 ->
b0: Lib.IntTypes.uint64 ->
b1: Lib.IntTypes.uint64 ->
b2: Lib.IntTypes.uint64 ->
b3: Lib.IntTypes.uint64 ->
b4: Lib.IntTypes.uint64 ->
b5: Lib.IntTypes.uint64 ->
b6: Lib.IntTypes.uint64 ->
b7: Lib.IntTypes.uint64 ->
b8: Lib.IntTypes.uint64 ->
b9: Lib.IntTypes.uint64
-> FStar.Pervasives.Lemma
(requires
Lib.IntTypes.v b0 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 0 7) /\
Lib.IntTypes.v b1 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 7 14) /\
Lib.IntTypes.v b2 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 14 21) /\
Lib.IntTypes.v b3 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 21 28) /\
Lib.IntTypes.v b4 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 28 35) /\
Lib.IntTypes.v b5 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 35 42) /\
Lib.IntTypes.v b6 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 42 49) /\
Lib.IntTypes.v b7 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 49 56) /\
Lib.IntTypes.v b8 == Lib.ByteSequence.nat_from_bytes_le (FStar.Seq.Base.slice k 56 63) /\
Lib.IntTypes.v b9 == Lib.IntTypes.v (FStar.Seq.Base.index k 63))
(ensures
Hacl.Spec.BignumQ.Definitions.wide_as_nat5 (b0, b1, b2, b3, b4, b5, b6, b7, b8, b9) ==
Lib.ByteSequence.nat_from_bytes_le k) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Lib.ByteSequence.lbytes",
"Lib.IntTypes.uint64",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.pow2",
"Prims.unit",
"Lib.ByteSequence.nat_from_intseq_le_lemma0",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.Seq.Base.create",
"Lib.IntTypes.uint_t",
"FStar.Seq.Base.index",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.append",
"FStar.Seq.Base.slice",
"Hacl.Impl.Load56.lemma_nat_from_bytes_le_append",
"Prims.l_and",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U64",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Lib.Sequence.length",
"Lib.IntTypes.v",
"Lib.ByteSequence.nat_from_bytes_le",
"Prims.squash",
"Prims.nat",
"Hacl.Spec.BignumQ.Definitions.wide_as_nat5",
"FStar.Pervasives.Native.Mktuple10",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_load_64_bytes (k: lbytes 64) (b0 b1 b2 b3 b4 b5 b6 b7 b8 b9: uint64)
: Lemma
(requires
v b0 == nat_from_bytes_le (Seq.slice k 0 7) /\ v b1 == nat_from_bytes_le (Seq.slice k 7 14) /\
v b2 == nat_from_bytes_le (Seq.slice k 14 21) /\
v b3 == nat_from_bytes_le (Seq.slice k 21 28) /\
v b4 == nat_from_bytes_le (Seq.slice k 28 35) /\
v b5 == nat_from_bytes_le (Seq.slice k 35 42) /\
v b6 == nat_from_bytes_le (Seq.slice k 42 49) /\
v b7 == nat_from_bytes_le (Seq.slice k 49 56) /\
v b8 == nat_from_bytes_le (Seq.slice k 56 63) /\ v b9 == v (Seq.index k 63))
(ensures S56.wide_as_nat5 (b0, b1, b2, b3, b4, b5, b6, b7, b8, b9) == nat_from_bytes_le k) =
| lemma_nat_from_bytes_le_append (Seq.slice k 0 7) (Seq.slice k 7 14);
lemma_nat_from_bytes_le_append (Seq.slice k 0 14) (Seq.slice k 14 21);
lemma_nat_from_bytes_le_append (Seq.slice k 0 21) (Seq.slice k 21 28);
lemma_nat_from_bytes_le_append (Seq.slice k 0 28) (Seq.slice k 28 35);
lemma_nat_from_bytes_le_append (Seq.slice k 0 35) (Seq.slice k 35 42);
lemma_nat_from_bytes_le_append (Seq.slice k 0 42) (Seq.slice k 42 49);
lemma_nat_from_bytes_le_append (Seq.slice k 0 49) (Seq.slice k 49 56);
lemma_nat_from_bytes_le_append (Seq.slice k 0 56) (Seq.slice k 56 63);
lemma_nat_from_bytes_le_append (Seq.slice k 0 63) (Seq.create 1 (Seq.index k 63));
assert ((Seq.append (Seq.slice k 0 7) (Seq.slice k 7 14)) `Seq.equal` (Seq.slice k 0 14));
assert ((Seq.append (Seq.slice k 0 14) (Seq.slice k 14 21)) `Seq.equal` (Seq.slice k 0 21));
assert ((Seq.append (Seq.slice k 0 21) (Seq.slice k 21 28)) `Seq.equal` (Seq.slice k 0 28));
assert ((Seq.append (Seq.slice k 0 28) (Seq.slice k 28 35)) `Seq.equal` (Seq.slice k 0 35));
assert ((Seq.append (Seq.slice k 0 35) (Seq.slice k 35 42)) `Seq.equal` (Seq.slice k 0 42));
assert ((Seq.append (Seq.slice k 0 42) (Seq.slice k 42 49)) `Seq.equal` (Seq.slice k 0 49));
assert ((Seq.append (Seq.slice k 0 49) (Seq.slice k 49 56)) `Seq.equal` (Seq.slice k 0 56));
assert ((Seq.append (Seq.slice k 0 56) (Seq.slice k 56 63)) `Seq.equal` (Seq.slice k 0 63));
assert ((Seq.append (Seq.slice k 0 63) (Seq.create 1 (Seq.index k 63))) `Seq.equal` k);
nat_from_intseq_le_lemma0 (Seq.create 1 (Seq.index k 63));
assert_norm (pow2 56 == 0x100000000000000);
assert_norm (pow2 112 == 0x10000000000000000000000000000);
assert_norm (pow2 168 == 0x1000000000000000000000000000000000000000000);
assert_norm (pow2 224 == 0x100000000000000000000000000000000000000000000000000000000);
assert_norm (pow2 280 == 0x10000000000000000000000000000000000000000000000000000000000000000000000);
assert_norm (pow2 336 ==
0x1000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
assert_norm (pow2 392 ==
0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
);
assert_norm (pow2 448 ==
0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
);
assert_norm (pow2 504 ==
0x1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
) | false |
FStar.Printf.fst | FStar.Printf.parse_format | val parse_format (s: list char) (parse_ext: extension_parser) : option (list dir) | val parse_format (s: list char) (parse_ext: extension_parser) : option (list dir) | let rec parse_format
(s:list char)
(parse_ext: extension_parser)
: option (list dir)
= let add_dir (d:dir) (ods : option (list dir))
: option (list dir)
= match ods with
| None -> None
| Some ds -> Some (d::ds)
in
match s with
| [] -> Some []
| ['%'] -> None
//Unsigned integers beging with '%u'
| '%' :: 'u' :: s' -> begin
match s' with
| 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext)
| 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext)
| 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext)
| 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext)
| _ -> None
end
//User extensions begin with '%X'
| '%' :: 'X' :: s' -> begin
match parse_ext s' with
| Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext)
| _ -> None
end
| '%' :: c :: s' -> begin
match c with
| '%' -> add_dir (Lit '%') (parse_format s' parse_ext)
| 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext)
| 'd' -> add_dir (Arg Int) (parse_format s' parse_ext)
| 'c' -> add_dir (Arg Char) (parse_format s' parse_ext)
| 's' -> add_dir (Arg String) (parse_format s' parse_ext)
| 'y' -> add_dir (Arg I8) (parse_format s' parse_ext)
| 'i' -> add_dir (Arg I16) (parse_format s' parse_ext)
| 'l' -> add_dir (Arg I32) (parse_format s' parse_ext)
| 'L' -> add_dir (Arg I64) (parse_format s' parse_ext)
| _ -> None
end
| c :: s' ->
add_dir (Lit c) (parse_format s' parse_ext) | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 176,
"start_col": 0,
"start_line": 131
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension
/// `arg_type`: Interpreting a `arg` tag as a type
let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t
let string_of_arg (#a:arg) (x:arg_type a) : string =
match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x
/// `dir`: Internal to this module
/// A 'directive"; used when parsing a format specifier
noeq
type dir =
| Lit of char
| Arg of arg
/// `dir_type ds`: Interpreting a list directives as a pure function type
let rec dir_type (ds:list dir) : Tot Type0 =
match ds with
| [] -> string
| Lit c :: ds' -> dir_type ds'
| Arg a :: ds' -> arg_type a -> dir_type ds'
/// `string_of_dirs ds`:
/// Interpreting a list of directives as its function,
/// in a continuation-passing style
let rec string_of_dirs
(ds:list dir)
(k:string -> string)
: dir_type ds
= match ds with
| [] -> k ""
| Lit c :: ds' ->
coerce_eq () (
string_of_dirs ds' (fun res -> k (string_of_char c ^ res))
)
| Arg a :: ds' ->
fun (x : arg_type a) ->
string_of_dirs ds' (fun res -> ((k "")
^ string_of_arg x
^ res))
type extension_parser = i:list char -> option (extension * o:list char{o << i})
/// `parse_format s`:
/// Parses a list of characters into a list of directives | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Prims.list FStar.String.char -> parse_ext: FStar.Printf.extension_parser
-> FStar.Pervasives.Native.option (Prims.list FStar.Printf.dir) | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"FStar.String.char",
"FStar.Printf.extension_parser",
"FStar.Pervasives.Native.Some",
"FStar.Printf.dir",
"Prims.Nil",
"FStar.Pervasives.Native.None",
"FStar.Printf.Arg",
"FStar.Printf.U8",
"FStar.Printf.parse_format",
"FStar.Printf.U16",
"FStar.Printf.U32",
"FStar.Printf.U64",
"FStar.Pervasives.Native.option",
"FStar.Printf.extension",
"Prims.precedes",
"FStar.Printf.Extension",
"FStar.Pervasives.Native.tuple2",
"FStar.Printf.Lit",
"FStar.Printf.Bool",
"FStar.Printf.Int",
"FStar.Printf.Char",
"FStar.Printf.String",
"FStar.Printf.I8",
"FStar.Printf.I16",
"FStar.Printf.I32",
"FStar.Printf.I64",
"FStar.Char.char",
"Prims.Cons"
] | [
"recursion"
] | false | false | false | true | false | let rec parse_format (s: list char) (parse_ext: extension_parser) : option (list dir) =
| let add_dir (d: dir) (ods: option (list dir)) : option (list dir) =
match ods with
| None -> None
| Some ds -> Some (d :: ds)
in
match s with
| [] -> Some []
| ['%'] -> None
| '%' :: 'u' :: s' ->
(match s' with
| 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext)
| 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext)
| 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext)
| 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext)
| _ -> None)
| '%' :: 'X' :: s' ->
(match parse_ext s' with
| Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext)
| _ -> None)
| '%' :: c :: s' ->
(match c with
| '%' -> add_dir (Lit '%') (parse_format s' parse_ext)
| 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext)
| 'd' -> add_dir (Arg Int) (parse_format s' parse_ext)
| 'c' -> add_dir (Arg Char) (parse_format s' parse_ext)
| 's' -> add_dir (Arg String) (parse_format s' parse_ext)
| 'y' -> add_dir (Arg I8) (parse_format s' parse_ext)
| 'i' -> add_dir (Arg I16) (parse_format s' parse_ext)
| 'l' -> add_dir (Arg I32) (parse_format s' parse_ext)
| 'L' -> add_dir (Arg I64) (parse_format s' parse_ext)
| _ -> None)
| c :: s' -> add_dir (Lit c) (parse_format s' parse_ext) | false |
FStar.Printf.fst | FStar.Printf.dir_type | val dir_type (ds: list dir) : Tot Type0 | val dir_type (ds: list dir) : Tot Type0 | let rec dir_type (ds:list dir) : Tot Type0 =
match ds with
| [] -> string
| Lit c :: ds' -> dir_type ds'
| Arg a :: ds' -> arg_type a -> dir_type ds' | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 46,
"end_line": 105,
"start_col": 0,
"start_line": 101
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension
/// `arg_type`: Interpreting a `arg` tag as a type
let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t
let string_of_arg (#a:arg) (x:arg_type a) : string =
match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x
/// `dir`: Internal to this module
/// A 'directive"; used when parsing a format specifier
noeq
type dir =
| Lit of char
| Arg of arg | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ds: Prims.list FStar.Printf.dir -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"FStar.Printf.dir",
"Prims.string",
"FStar.String.char",
"FStar.Printf.dir_type",
"FStar.Printf.arg",
"FStar.Printf.arg_type"
] | [
"recursion"
] | false | false | false | true | true | let rec dir_type (ds: list dir) : Tot Type0 =
| match ds with
| [] -> string
| Lit c :: ds' -> dir_type ds'
| Arg a :: ds' -> arg_type a -> dir_type ds' | false |
Steel.ST.Array.fsti | Steel.ST.Array.null | val null (#a: Type0) : array a | val null (#a: Type0) : array a | let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 32,
"end_line": 81,
"start_col": 0,
"start_line": 80
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Steel.ST.Array.array a | Prims.Tot | [
"total"
] | [] | [
"Prims.Mkdtuple2",
"Steel.ST.Array.ptr",
"FStar.Ghost.erased",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"FStar.Ghost.reveal",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base",
"Steel.ST.Array.null_ptr",
"FStar.Ghost.hide",
"Steel.ST.Array.array"
] | [] | false | false | false | true | false | let null (#a: Type0) : array a =
| (| null_ptr a, Ghost.hide 0 |) | false |
Steel.ST.Array.fsti | Steel.ST.Array.larray | val larray : t: Type0 -> n: Prims.nat -> Type0 | let larray (t:Type) (n:nat) = a:array t{ length a = n } | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 55,
"end_line": 110,
"start_col": 0,
"start_line": 110
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Type0 -> n: Prims.nat -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Steel.ST.Array.array",
"Prims.b2t",
"Prims.op_Equality",
"Steel.ST.Array.length"
] | [] | false | false | false | true | true | let larray (t: Type) (n: nat) =
| a: array t {length a = n} | false |
|
Steel.ST.Array.fsti | Steel.ST.Array.is_null | val is_null (#a: Type0) (p: array a)
: Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) | val is_null (#a: Type0) (p: array a)
: Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) | let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 24,
"end_line": 98,
"start_col": 0,
"start_line": 95
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Steel.ST.Array.array a -> Prims.Pure Prims.bool | Prims.Pure | [] | [] | [
"Steel.ST.Array.array",
"Steel.ST.Array.is_null_ptr",
"Steel.ST.Array.ptr_of",
"Prims.bool",
"Prims.l_True",
"Prims.l_iff",
"Prims.eq2",
"Steel.ST.Array.null"
] | [] | false | false | false | false | false | let is_null (#a: Type0) (p: array a)
: Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) =
| is_null_ptr (ptr_of p) | false |
Steel.ST.Array.fsti | Steel.ST.Array.split_l | val split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t)
: Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True)) | val split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t)
: Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True)) | let split_l (#elt: Type) (a: array elt)
(i: Ghost.erased US.t)
: Pure (array elt)
(requires (US.v i <= length a))
(ensures (fun y -> True))
= (| ptr_of a, Ghost.hide (US.v i) |) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 37,
"end_line": 374,
"start_col": 0,
"start_line": 369
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction
[@@noextract_to "krml"]
let read #t #p = index #t #p
/// Writing the value v at the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val upd
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t {US.v i < Seq.length s})
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
inline_for_extraction
[@@noextract_to "krml"]
let write #t = upd #t
/// An array a1 is adjacent to an array a2 if and only if they have
/// the same base array and the end of a1 coincides with the beginning
/// of a2
let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
base (ptr_of a1) == base (ptr_of a2) /\
offset (ptr_of a1) + (length a1) == offset (ptr_of a2)
/// If two arrays are adjacent, then we can compute their merge, with
/// their combined lengths. By virtue of the length being ghost,
/// Karamel will extract it as "let y = a1"
inline_for_extraction
[@@noextract_to "krml"]
let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2))
= (| ptr_of a1, Ghost.hide (length a1 + length a2) |)
/// Adjacency and merging are associative.
let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma
(requires (
(adjacent a1 a2 /\ adjacent a2 a3) \/
(adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/
(adjacent a2 a3 /\ adjacent a1 (merge a2 a3))
))
(ensures (
adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\
merge (merge a1 a2) a3 == merge a1 (merge a2 a3)
))
= ()
/// A shortcut to combine adjacency and merging
let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop =
adjacent a1 a2 /\
merge a1 a2 == a
/// Spatial merging of two arrays, expressed in terms of `merge`.
val ghost_join
(#opened: _)
(#elt: Type)
(#x1 #x2: Seq.seq elt)
(#p: P.perm)
(a1 a2: array elt)
(h: squash (adjacent a1 a2))
: STGhostT unit opened
(pts_to a1 p x1 `star` pts_to a2 p x2)
(fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2))
/// Spatial merging, combining the use of `merge` and the call to the
/// stateful lemma. Since the only operations are calls to stateful
/// lemmas and pure computations, the overall computation is atomic
/// and unobservable, so can be used anywhere in atomic contexts. By
/// virtue of the length being ghost, Karamel will extract this to
/// "let res = a1"
inline_for_extraction // this will extract to "let res = a1"
[@@noextract_to "krml"]
let join
(#opened: _)
(#elt: Type)
(#x1 #x2: Ghost.erased (Seq.seq elt))
(#p: P.perm)
(a1: array elt)
(a2: Ghost.erased (array elt))
: STAtomicBase (array elt) false opened Unobservable
(pts_to a1 p x1 `star` pts_to a2 p x2)
(fun res -> pts_to res p (x1 `Seq.append` x2))
(adjacent a1 a2)
(fun res -> merge_into a1 a2 res)
= let _ : squash (adjacent a1 a2) = () in
ghost_join a1 a2 ();
let res = merge a1 a2 in
rewrite
(pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2))
(pts_to res p (x1 `Seq.append` x2));
return res
/// Computing the left-hand-side part of splitting an array a at
/// offset i. By virtue of the length being ghost, Karamel will
/// extract this to "let y = a"
inline_for_extraction // this will extract to "let y = a" | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Steel.ST.Array.array elt -> i: FStar.Ghost.erased FStar.SizeT.t
-> Prims.Pure (Steel.ST.Array.array elt) | Prims.Pure | [] | [] | [
"Steel.ST.Array.array",
"FStar.Ghost.erased",
"FStar.SizeT.t",
"Prims.Mkdtuple2",
"Steel.ST.Array.ptr",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"FStar.Ghost.reveal",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base",
"Steel.ST.Array.ptr_of",
"FStar.Ghost.hide",
"FStar.SizeT.v",
"Steel.ST.Array.length",
"Prims.l_True"
] | [] | false | false | false | false | false | let split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t)
: Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True)) =
| (| ptr_of a, Ghost.hide (US.v i) |) | false |
Steel.ST.Array.fsti | Steel.ST.Array.merge | val merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2)) | val merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2)) | let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2))
= (| ptr_of a1, Ghost.hide (length a1 + length a2) |) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 53,
"end_line": 304,
"start_col": 0,
"start_line": 300
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction
[@@noextract_to "krml"]
let read #t #p = index #t #p
/// Writing the value v at the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val upd
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t {US.v i < Seq.length s})
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
inline_for_extraction
[@@noextract_to "krml"]
let write #t = upd #t
/// An array a1 is adjacent to an array a2 if and only if they have
/// the same base array and the end of a1 coincides with the beginning
/// of a2
let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
base (ptr_of a1) == base (ptr_of a2) /\
offset (ptr_of a1) + (length a1) == offset (ptr_of a2)
/// If two arrays are adjacent, then we can compute their merge, with
/// their combined lengths. By virtue of the length being ghost,
/// Karamel will extract it as "let y = a1"
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a1: Steel.ST.Array.array elt -> a2: FStar.Ghost.erased (Steel.ST.Array.array elt)
-> Prims.Pure (Steel.ST.Array.array elt) | Prims.Pure | [] | [] | [
"Steel.ST.Array.array",
"FStar.Ghost.erased",
"Prims.Mkdtuple2",
"Steel.ST.Array.ptr",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"FStar.Ghost.reveal",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base",
"Steel.ST.Array.ptr_of",
"FStar.Ghost.hide",
"Steel.ST.Array.length",
"Steel.ST.Array.adjacent",
"Prims.eq2",
"Prims.int"
] | [] | false | false | false | false | false | let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2)) =
| (| ptr_of a1, Ghost.hide (length a1 + length a2) |) | false |
FStar.Printf.fst | FStar.Printf.sprintf | val sprintf (s: string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))})
: norm [unascribe; delta; iota; zeta; primops]
(dir_type (Some?.v (parse_format_string s no_extensions))) | val sprintf (s: string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))})
: norm [unascribe; delta; iota; zeta; primops]
(dir_type (Some?.v (parse_format_string s no_extensions))) | let sprintf
(s:string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))})
: norm [unascribe; delta; iota; zeta; primops] (dir_type (Some?.v (parse_format_string s no_extensions)))
= norm [unascribe; delta; iota; zeta; primops] (string_of_dirs (Some?.v (parse_format_string s no_extensions)) (fun s -> s)) | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 128,
"end_line": 200,
"start_col": 0,
"start_line": 197
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension
/// `arg_type`: Interpreting a `arg` tag as a type
let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t
let string_of_arg (#a:arg) (x:arg_type a) : string =
match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x
/// `dir`: Internal to this module
/// A 'directive"; used when parsing a format specifier
noeq
type dir =
| Lit of char
| Arg of arg
/// `dir_type ds`: Interpreting a list directives as a pure function type
let rec dir_type (ds:list dir) : Tot Type0 =
match ds with
| [] -> string
| Lit c :: ds' -> dir_type ds'
| Arg a :: ds' -> arg_type a -> dir_type ds'
/// `string_of_dirs ds`:
/// Interpreting a list of directives as its function,
/// in a continuation-passing style
let rec string_of_dirs
(ds:list dir)
(k:string -> string)
: dir_type ds
= match ds with
| [] -> k ""
| Lit c :: ds' ->
coerce_eq () (
string_of_dirs ds' (fun res -> k (string_of_char c ^ res))
)
| Arg a :: ds' ->
fun (x : arg_type a) ->
string_of_dirs ds' (fun res -> ((k "")
^ string_of_arg x
^ res))
type extension_parser = i:list char -> option (extension * o:list char{o << i})
/// `parse_format s`:
/// Parses a list of characters into a list of directives
/// Or None, in case the format string is invalid
let rec parse_format
(s:list char)
(parse_ext: extension_parser)
: option (list dir)
= let add_dir (d:dir) (ods : option (list dir))
: option (list dir)
= match ods with
| None -> None
| Some ds -> Some (d::ds)
in
match s with
| [] -> Some []
| ['%'] -> None
//Unsigned integers beging with '%u'
| '%' :: 'u' :: s' -> begin
match s' with
| 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext)
| 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext)
| 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext)
| 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext)
| _ -> None
end
//User extensions begin with '%X'
| '%' :: 'X' :: s' -> begin
match parse_ext s' with
| Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext)
| _ -> None
end
| '%' :: c :: s' -> begin
match c with
| '%' -> add_dir (Lit '%') (parse_format s' parse_ext)
| 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext)
| 'd' -> add_dir (Arg Int) (parse_format s' parse_ext)
| 'c' -> add_dir (Arg Char) (parse_format s' parse_ext)
| 's' -> add_dir (Arg String) (parse_format s' parse_ext)
| 'y' -> add_dir (Arg I8) (parse_format s' parse_ext)
| 'i' -> add_dir (Arg I16) (parse_format s' parse_ext)
| 'l' -> add_dir (Arg I32) (parse_format s' parse_ext)
| 'L' -> add_dir (Arg I64) (parse_format s' parse_ext)
| _ -> None
end
| c :: s' ->
add_dir (Lit c) (parse_format s' parse_ext)
/// `parse_format_string`: parses a format `string` into a list of directives
let parse_format_string
(s:string)
(parse_ext:extension_parser)
: option (list dir)
= parse_format (list_of_string s) parse_ext
let no_extensions : extension_parser = fun s -> None
/// `sprintf`: The main function of this module
/// A variable arity string formatter
/// Used as: `sprintf "format string" v1 ... vn`
///
/// It's marked `inline_for_extraction`, meaning that we don't need
/// any special support in our compilation targets to support sprintf
///
/// `sprintf "Hello %s" "world"`
/// will just extract to `"Hello " ^ "world"` | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s:
Prims.string
{ FStar.Pervasives.normalize_term (Some? (FStar.Printf.parse_format_string s
FStar.Printf.no_extensions)) }
-> FStar.Pervasives.norm [
FStar.Pervasives.unascribe;
FStar.Pervasives.delta;
FStar.Pervasives.iota;
FStar.Pervasives.zeta;
FStar.Pervasives.primops
]
(FStar.Printf.dir_type (Some?.v (FStar.Printf.parse_format_string s FStar.Printf.no_extensions
))) | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"FStar.Pervasives.normalize_term",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.list",
"FStar.Printf.dir",
"FStar.Printf.parse_format_string",
"FStar.Printf.no_extensions",
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.unascribe",
"FStar.Pervasives.delta",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"Prims.Nil",
"FStar.String.list_of_string",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.None",
"FStar.String.char",
"FStar.Printf.parse_format",
"FStar.Printf.Arg",
"FStar.Printf.U8",
"FStar.Pervasives.Native.option",
"FStar.Printf.U16",
"FStar.Printf.U32",
"FStar.Printf.U64",
"FStar.Printf.extension",
"Prims.precedes",
"FStar.Printf.Extension",
"FStar.Pervasives.Native.tuple2",
"FStar.Printf.Lit",
"FStar.Printf.Bool",
"FStar.Printf.Int",
"FStar.Printf.Char",
"FStar.Printf.String",
"FStar.Printf.I8",
"FStar.Printf.I16",
"FStar.Printf.I32",
"FStar.Printf.I64",
"FStar.Char.char",
"FStar.Printf.dir_type",
"FStar.Printf.arg",
"FStar.Printf.arg_type",
"FStar.Printf.string_of_dirs",
"FStar.Pervasives.Native.__proj__Some__item__v"
] | [] | false | false | false | false | false | let sprintf (s: string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))})
: norm [unascribe; delta; iota; zeta; primops]
(dir_type (Some?.v (parse_format_string s no_extensions))) =
| norm [unascribe; delta; iota; zeta; primops]
(string_of_dirs (Some?.v (parse_format_string s no_extensions)) (fun s -> s)) | false |
Steel.ST.Array.fsti | Steel.ST.Array.ptr_shift_add | val ptr_shift_add (#elt: Type) (p: ptr elt) (off1 off2: US.t)
: Lemma
(requires
(offset p + US.v off1 + US.v off2 <= base_len (base p) /\ US.fits (US.v off1 + US.v off2)))
(ensures (ptr_shift (ptr_shift p off1) off2 == ptr_shift p (off1 `US.add` off2))) | val ptr_shift_add (#elt: Type) (p: ptr elt) (off1 off2: US.t)
: Lemma
(requires
(offset p + US.v off1 + US.v off2 <= base_len (base p) /\ US.fits (US.v off1 + US.v off2)))
(ensures (ptr_shift (ptr_shift p off1) off2 == ptr_shift p (off1 `US.add` off2))) | let ptr_shift_add
(#elt: Type)
(p: ptr elt)
(off1 off2: US.t)
: Lemma
(requires (
offset p + US.v off1 + US.v off2 <= base_len (base p) /\
US.fits (US.v off1 + US.v off2) // cannot be deduced from base_len, because length_fits only works for arrays, not array pointers
))
(ensures (
ptr_shift (ptr_shift p off1) off2 == ptr_shift p (off1 `US.add` off2)
))
= ptr_base_offset_inj (ptr_shift (ptr_shift p off1) off2) (ptr_shift p (off1 `US.add` off2)) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 92,
"end_line": 412,
"start_col": 0,
"start_line": 400
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction
[@@noextract_to "krml"]
let read #t #p = index #t #p
/// Writing the value v at the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val upd
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t {US.v i < Seq.length s})
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
inline_for_extraction
[@@noextract_to "krml"]
let write #t = upd #t
/// An array a1 is adjacent to an array a2 if and only if they have
/// the same base array and the end of a1 coincides with the beginning
/// of a2
let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
base (ptr_of a1) == base (ptr_of a2) /\
offset (ptr_of a1) + (length a1) == offset (ptr_of a2)
/// If two arrays are adjacent, then we can compute their merge, with
/// their combined lengths. By virtue of the length being ghost,
/// Karamel will extract it as "let y = a1"
inline_for_extraction
[@@noextract_to "krml"]
let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2))
= (| ptr_of a1, Ghost.hide (length a1 + length a2) |)
/// Adjacency and merging are associative.
let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma
(requires (
(adjacent a1 a2 /\ adjacent a2 a3) \/
(adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/
(adjacent a2 a3 /\ adjacent a1 (merge a2 a3))
))
(ensures (
adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\
merge (merge a1 a2) a3 == merge a1 (merge a2 a3)
))
= ()
/// A shortcut to combine adjacency and merging
let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop =
adjacent a1 a2 /\
merge a1 a2 == a
/// Spatial merging of two arrays, expressed in terms of `merge`.
val ghost_join
(#opened: _)
(#elt: Type)
(#x1 #x2: Seq.seq elt)
(#p: P.perm)
(a1 a2: array elt)
(h: squash (adjacent a1 a2))
: STGhostT unit opened
(pts_to a1 p x1 `star` pts_to a2 p x2)
(fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2))
/// Spatial merging, combining the use of `merge` and the call to the
/// stateful lemma. Since the only operations are calls to stateful
/// lemmas and pure computations, the overall computation is atomic
/// and unobservable, so can be used anywhere in atomic contexts. By
/// virtue of the length being ghost, Karamel will extract this to
/// "let res = a1"
inline_for_extraction // this will extract to "let res = a1"
[@@noextract_to "krml"]
let join
(#opened: _)
(#elt: Type)
(#x1 #x2: Ghost.erased (Seq.seq elt))
(#p: P.perm)
(a1: array elt)
(a2: Ghost.erased (array elt))
: STAtomicBase (array elt) false opened Unobservable
(pts_to a1 p x1 `star` pts_to a2 p x2)
(fun res -> pts_to res p (x1 `Seq.append` x2))
(adjacent a1 a2)
(fun res -> merge_into a1 a2 res)
= let _ : squash (adjacent a1 a2) = () in
ghost_join a1 a2 ();
let res = merge a1 a2 in
rewrite
(pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2))
(pts_to res p (x1 `Seq.append` x2));
return res
/// Computing the left-hand-side part of splitting an array a at
/// offset i. By virtue of the length being ghost, Karamel will
/// extract this to "let y = a"
inline_for_extraction // this will extract to "let y = a"
[@@noextract_to "krml"]
let split_l (#elt: Type) (a: array elt)
(i: Ghost.erased US.t)
: Pure (array elt)
(requires (US.v i <= length a))
(ensures (fun y -> True))
= (| ptr_of a, Ghost.hide (US.v i) |)
/// C pointer arithmetic to compute (p+off), shifting a pointer p by
/// offset off. TODO: replace this with a Ghost definition and a
/// SteelAtomicBase Unobservable operation with the corresponding
/// permission.
inline_for_extraction
[@@noextract_to "krml"]
val ptr_shift
(#elt: Type)
(p: ptr elt)
(off: US.t)
: Pure (ptr elt)
(requires (offset p + US.v off <= base_len (base p)))
(ensures (fun p' ->
base p' == base p /\
offset p' == offset p + US.v off
))
let ptr_shift_zero
(#elt: Type)
(p: ptr elt)
: Lemma
(ptr_shift p 0sz == p)
= ptr_base_offset_inj (ptr_shift p 0sz) p | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Steel.ST.Array.ptr elt -> off1: FStar.SizeT.t -> off2: FStar.SizeT.t
-> FStar.Pervasives.Lemma
(requires
Steel.ST.Array.offset p + FStar.SizeT.v off1 + FStar.SizeT.v off2 <=
Steel.ST.Array.base_len (Steel.ST.Array.base p) /\
FStar.SizeT.fits (FStar.SizeT.v off1 + FStar.SizeT.v off2))
(ensures
Steel.ST.Array.ptr_shift (Steel.ST.Array.ptr_shift p off1) off2 ==
Steel.ST.Array.ptr_shift p (FStar.SizeT.add off1 off2)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Steel.ST.Array.ptr",
"FStar.SizeT.t",
"Steel.ST.Array.ptr_base_offset_inj",
"Steel.ST.Array.ptr_shift",
"FStar.SizeT.add",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"FStar.SizeT.v",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base",
"FStar.SizeT.fits",
"Prims.squash",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let ptr_shift_add (#elt: Type) (p: ptr elt) (off1 off2: US.t)
: Lemma
(requires
(offset p + US.v off1 + US.v off2 <= base_len (base p) /\ US.fits (US.v off1 + US.v off2)))
(ensures (ptr_shift (ptr_shift p off1) off2 == ptr_shift p (off1 `US.add` off2))) =
| ptr_base_offset_inj (ptr_shift (ptr_shift p off1) off2) (ptr_shift p (off1 `US.add` off2)) | false |
Steel.ST.Array.fsti | Steel.ST.Array.ptr_shift_zero | val ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p) | val ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p) | let ptr_shift_zero
(#elt: Type)
(p: ptr elt)
: Lemma
(ptr_shift p 0sz == p)
= ptr_base_offset_inj (ptr_shift p 0sz) p | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 41,
"end_line": 398,
"start_col": 0,
"start_line": 393
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction
[@@noextract_to "krml"]
let read #t #p = index #t #p
/// Writing the value v at the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val upd
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t {US.v i < Seq.length s})
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
inline_for_extraction
[@@noextract_to "krml"]
let write #t = upd #t
/// An array a1 is adjacent to an array a2 if and only if they have
/// the same base array and the end of a1 coincides with the beginning
/// of a2
let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
base (ptr_of a1) == base (ptr_of a2) /\
offset (ptr_of a1) + (length a1) == offset (ptr_of a2)
/// If two arrays are adjacent, then we can compute their merge, with
/// their combined lengths. By virtue of the length being ghost,
/// Karamel will extract it as "let y = a1"
inline_for_extraction
[@@noextract_to "krml"]
let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2))
= (| ptr_of a1, Ghost.hide (length a1 + length a2) |)
/// Adjacency and merging are associative.
let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma
(requires (
(adjacent a1 a2 /\ adjacent a2 a3) \/
(adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/
(adjacent a2 a3 /\ adjacent a1 (merge a2 a3))
))
(ensures (
adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\
merge (merge a1 a2) a3 == merge a1 (merge a2 a3)
))
= ()
/// A shortcut to combine adjacency and merging
let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop =
adjacent a1 a2 /\
merge a1 a2 == a
/// Spatial merging of two arrays, expressed in terms of `merge`.
val ghost_join
(#opened: _)
(#elt: Type)
(#x1 #x2: Seq.seq elt)
(#p: P.perm)
(a1 a2: array elt)
(h: squash (adjacent a1 a2))
: STGhostT unit opened
(pts_to a1 p x1 `star` pts_to a2 p x2)
(fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2))
/// Spatial merging, combining the use of `merge` and the call to the
/// stateful lemma. Since the only operations are calls to stateful
/// lemmas and pure computations, the overall computation is atomic
/// and unobservable, so can be used anywhere in atomic contexts. By
/// virtue of the length being ghost, Karamel will extract this to
/// "let res = a1"
inline_for_extraction // this will extract to "let res = a1"
[@@noextract_to "krml"]
let join
(#opened: _)
(#elt: Type)
(#x1 #x2: Ghost.erased (Seq.seq elt))
(#p: P.perm)
(a1: array elt)
(a2: Ghost.erased (array elt))
: STAtomicBase (array elt) false opened Unobservable
(pts_to a1 p x1 `star` pts_to a2 p x2)
(fun res -> pts_to res p (x1 `Seq.append` x2))
(adjacent a1 a2)
(fun res -> merge_into a1 a2 res)
= let _ : squash (adjacent a1 a2) = () in
ghost_join a1 a2 ();
let res = merge a1 a2 in
rewrite
(pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2))
(pts_to res p (x1 `Seq.append` x2));
return res
/// Computing the left-hand-side part of splitting an array a at
/// offset i. By virtue of the length being ghost, Karamel will
/// extract this to "let y = a"
inline_for_extraction // this will extract to "let y = a"
[@@noextract_to "krml"]
let split_l (#elt: Type) (a: array elt)
(i: Ghost.erased US.t)
: Pure (array elt)
(requires (US.v i <= length a))
(ensures (fun y -> True))
= (| ptr_of a, Ghost.hide (US.v i) |)
/// C pointer arithmetic to compute (p+off), shifting a pointer p by
/// offset off. TODO: replace this with a Ghost definition and a
/// SteelAtomicBase Unobservable operation with the corresponding
/// permission.
inline_for_extraction
[@@noextract_to "krml"]
val ptr_shift
(#elt: Type)
(p: ptr elt)
(off: US.t)
: Pure (ptr elt)
(requires (offset p + US.v off <= base_len (base p)))
(ensures (fun p' ->
base p' == base p /\
offset p' == offset p + US.v off
)) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Steel.ST.Array.ptr elt -> FStar.Pervasives.Lemma (ensures Steel.ST.Array.ptr_shift p 0sz == p) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Steel.ST.Array.ptr",
"Steel.ST.Array.ptr_base_offset_inj",
"Steel.ST.Array.ptr_shift",
"FStar.SizeT.__uint_to_t",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p) =
| ptr_base_offset_inj (ptr_shift p 0sz) p | false |
Steel.ST.Array.fsti | Steel.ST.Array.split_r | val split_r (#elt: Type) (a: array elt) (i: US.t)
: Pure (array elt)
(requires (US.v i <= length a))
(ensures (fun y -> merge_into (split_l a i) y a)) | val split_r (#elt: Type) (a: array elt) (i: US.t)
: Pure (array elt)
(requires (US.v i <= length a))
(ensures (fun y -> merge_into (split_l a i) y a)) | let split_r (#elt: Type) (a: array elt)
(i: US.t)
: Pure (array elt)
(requires (US.v i <= length a))
(ensures (fun y -> merge_into (split_l a i) y a))
= (| ptr_shift (ptr_of a) i, Ghost.hide (length a - US.v i) |) | {
"file_name": "lib/steel/Steel.ST.Array.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 62,
"end_line": 423,
"start_col": 0,
"start_line": 418
} | (*
Copyright 2020, 2021, 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Array
/// C arrays of universe 0 elements, with selectors.
module P = Steel.FractionalPermission
module US = FStar.SizeT
module UP = FStar.PtrdiffT
open Steel.ST.Util
/// NOTE: This module is defined on top of Steel.HigherArray, so its
/// definitions are all meant to be inlined and benefit from the
/// latter module's primitive extraction. We seal it under an
/// interface to avoid unpleasantly leaking the lifting of values
/// of lower universes into the SMT context. Due to this interface,
/// cross-module inlining must be enabled using F*'s --cmi option.
/// An abstract type to represent a base array (whole allocation
/// unit), exposed for proof purposes only
[@@erasable]
val base_t (elt: Type0) : Tot Type0
val base_len (#elt: Type) (b: base_t elt) : GTot nat
/// An abstract type to represent a C pointer, as a base and an offset
/// into its base
inline_for_extraction
[@@noextract_to "krml"]
val ptr ([@@@unused] elt: Type0) : Type0
inline_for_extraction
[@@noextract_to "krml"]
val null_ptr (elt: Type0) : ptr elt
// TODO: turn into a stateful operation to avoid comparing dangling pointers
inline_for_extraction
[@@noextract_to "krml"]
val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null_ptr elt))
val base (#elt: Type) (p: ptr elt) : Tot (base_t elt)
val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p)))
val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
val base_len_null_ptr (elt: Type0) : Lemma
(base_len (base (null_ptr elt)) == 0)
[SMTPat (base_len (base (null_ptr elt)))]
/// A concrete type to represent a C array, as a C pointer and a ghost
/// array length. By virtue of the length being ghost, Karamel will
/// extract this type as just ptr, but to inline the definition of
/// this type, we use standard dependent pairs instead of a custom
/// record type.
inline_for_extraction
[@@noextract_to "krml"]
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 =
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
inline_for_extraction
[@@noextract_to "krml"]
let null (#a: Type0) : array a
= (| null_ptr a, Ghost.hide 0 |)
/// This will extract to "let p = a"
inline_for_extraction
[@@noextract_to "krml"]
let ptr_of
(#elt: Type)
(a: array elt)
: Tot (ptr elt)
= match a with // dfst is not marked inline_for_extraction, so we need to reimplement it
| (| p, _ |) -> p
inline_for_extraction
[@@noextract_to "krml"]
let is_null (#a: Type0) (p: array a) : Pure bool
(requires True)
(ensures (fun res -> res == true <==> p == null))
= is_null_ptr (ptr_of p)
/// Returns the length of the array. Usable for specification and proof purposes,
/// as modeled by the GTot effect
let length (#elt: Type) (a: array elt) : GTot nat =
dsnd a
val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a))
/// An abbreviation refining an array by its length
inline_for_extraction
[@@noextract_to "krml"]
let larray (t:Type) (n:nat) = a:array t{ length a = n }
/// The main representation predicate:
/// A Steel separation logic heap predicate to describe that an array
/// a points to some element sequence s with some permission p.
///
/// A big design decision in this library was whether the second index
/// of this predicate should be a [lseq t (length a)] or just a [seq t].
///
/// Making it an [lseq] forces every specification to be strongly
/// typed, in the sense that the logical representation of an array
/// has to be a sequence of the right length. This can be a little
/// cumbersome in specifications, particularly as the refinement appears
/// in some cases beneath the [erased] constructor.
///
/// So, we opted instead to let the index be just a [seq t], and
/// requiring length refinements on it in certain functions, only when
/// necessary.
val pts_to
(#elt: Type0) (a: array elt)
(p: P.perm)
([@@@ smt_fallback ] s: Seq.seq elt)
: Tot vprop
/// A stateful lemma to relate the size of an array with the size
/// of the element sequence it points to
/// This ghost function proves that an array always points to a
/// sequence of the appropriate length
val pts_to_length
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> Seq.length s == length a)
val pts_to_not_null
(#opened: _)
(#elt: Type0)
(#p: P.perm)
(a: array elt)
(s: Seq.seq elt)
: STGhost unit opened
(pts_to a p s)
(fun _ -> pts_to a p s)
(True)
(fun _ -> a =!= null)
/// An injectivity property, needed only to define a selector. Such a
/// selector can be only defined in universe 0, and universes are not
/// cumulative, so we need to define a separate module for arrays of
/// universe 0 elements with selectors, reusing definitions from this
/// interface, but we do not want to use `friend`.
val pts_to_inj
(#elt: Type0) (a: array elt)
(p1: P.perm)
(s1: Seq.seq elt)
(p2: P.perm)
(s2: Seq.seq elt)
(m: mem)
: Lemma
(requires (
interp (hp_of (pts_to a p1 s1)) m /\
interp (hp_of (pts_to a p2 s2)) m
))
(ensures (
s1 == s2
))
/// Allocating a new array of size n, where each cell is initialized
/// with value x. We define the non-selector version of this operation
/// (and others) with a _pt suffix in the name.
let is_full_array (#elt: Type) (a: array elt) : Tot prop =
length a == base_len (base (ptr_of a))
inline_for_extraction
[@@noextract_to "krml"]
val malloc
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
is_full_array a
)
inline_for_extraction
[@@noextract_to "krml"]
let alloc #elt = malloc #elt
/// Freeing a full array.
inline_for_extraction
[@@ noextract_to "krml";
warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"]
val free
(#elt: Type)
(a: array elt)
: ST unit
(exists_ (pts_to a P.full_perm))
(fun _ -> emp)
(
is_full_array a
)
(fun _ -> True)
/// Sharing and gathering permissions on an array. Those only
/// manipulate permissions, so they are nothing more than stateful
/// lemmas.
val share
(#opened: _)
(#elt: Type)
(#x: Seq.seq elt)
(a: array elt)
(p p1 p2: P.perm)
: STGhost unit opened
(pts_to a p x)
(fun _ -> pts_to a p1 x `star` pts_to a p2 x)
(p == p1 `P.sum_perm` p2)
(fun _ -> True)
val gather
(#opened: _)
(#elt: Type)
(a: array elt)
(#x1: Seq.seq elt) (p1: P.perm)
(#x2: Seq.seq elt) (p2: P.perm)
: STGhost unit opened
(pts_to a p1 x1 `star` pts_to a p2 x2)
(fun _ -> pts_to a (p1 `P.sum_perm` p2) x1)
(True)
(fun _ -> x1 == x2)
/// Reading the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val index
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
inline_for_extraction
[@@noextract_to "krml"]
let read #t #p = index #t #p
/// Writing the value v at the i-th element of an array a.
/// TODO: we should also provide an atomic version for small types.
inline_for_extraction
[@@noextract_to "krml"]
val upd
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t {US.v i < Seq.length s})
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
inline_for_extraction
[@@noextract_to "krml"]
let write #t = upd #t
/// An array a1 is adjacent to an array a2 if and only if they have
/// the same base array and the end of a1 coincides with the beginning
/// of a2
let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
base (ptr_of a1) == base (ptr_of a2) /\
offset (ptr_of a1) + (length a1) == offset (ptr_of a2)
/// If two arrays are adjacent, then we can compute their merge, with
/// their combined lengths. By virtue of the length being ghost,
/// Karamel will extract it as "let y = a1"
inline_for_extraction
[@@noextract_to "krml"]
let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt))
: Pure (array elt)
(requires (adjacent a1 a2))
(ensures (fun y -> length y == length a1 + length a2))
= (| ptr_of a1, Ghost.hide (length a1 + length a2) |)
/// Adjacency and merging are associative.
let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma
(requires (
(adjacent a1 a2 /\ adjacent a2 a3) \/
(adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/
(adjacent a2 a3 /\ adjacent a1 (merge a2 a3))
))
(ensures (
adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\
merge (merge a1 a2) a3 == merge a1 (merge a2 a3)
))
= ()
/// A shortcut to combine adjacency and merging
let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop =
adjacent a1 a2 /\
merge a1 a2 == a
/// Spatial merging of two arrays, expressed in terms of `merge`.
val ghost_join
(#opened: _)
(#elt: Type)
(#x1 #x2: Seq.seq elt)
(#p: P.perm)
(a1 a2: array elt)
(h: squash (adjacent a1 a2))
: STGhostT unit opened
(pts_to a1 p x1 `star` pts_to a2 p x2)
(fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2))
/// Spatial merging, combining the use of `merge` and the call to the
/// stateful lemma. Since the only operations are calls to stateful
/// lemmas and pure computations, the overall computation is atomic
/// and unobservable, so can be used anywhere in atomic contexts. By
/// virtue of the length being ghost, Karamel will extract this to
/// "let res = a1"
inline_for_extraction // this will extract to "let res = a1"
[@@noextract_to "krml"]
let join
(#opened: _)
(#elt: Type)
(#x1 #x2: Ghost.erased (Seq.seq elt))
(#p: P.perm)
(a1: array elt)
(a2: Ghost.erased (array elt))
: STAtomicBase (array elt) false opened Unobservable
(pts_to a1 p x1 `star` pts_to a2 p x2)
(fun res -> pts_to res p (x1 `Seq.append` x2))
(adjacent a1 a2)
(fun res -> merge_into a1 a2 res)
= let _ : squash (adjacent a1 a2) = () in
ghost_join a1 a2 ();
let res = merge a1 a2 in
rewrite
(pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2))
(pts_to res p (x1 `Seq.append` x2));
return res
/// Computing the left-hand-side part of splitting an array a at
/// offset i. By virtue of the length being ghost, Karamel will
/// extract this to "let y = a"
inline_for_extraction // this will extract to "let y = a"
[@@noextract_to "krml"]
let split_l (#elt: Type) (a: array elt)
(i: Ghost.erased US.t)
: Pure (array elt)
(requires (US.v i <= length a))
(ensures (fun y -> True))
= (| ptr_of a, Ghost.hide (US.v i) |)
/// C pointer arithmetic to compute (p+off), shifting a pointer p by
/// offset off. TODO: replace this with a Ghost definition and a
/// SteelAtomicBase Unobservable operation with the corresponding
/// permission.
inline_for_extraction
[@@noextract_to "krml"]
val ptr_shift
(#elt: Type)
(p: ptr elt)
(off: US.t)
: Pure (ptr elt)
(requires (offset p + US.v off <= base_len (base p)))
(ensures (fun p' ->
base p' == base p /\
offset p' == offset p + US.v off
))
let ptr_shift_zero
(#elt: Type)
(p: ptr elt)
: Lemma
(ptr_shift p 0sz == p)
= ptr_base_offset_inj (ptr_shift p 0sz) p
let ptr_shift_add
(#elt: Type)
(p: ptr elt)
(off1 off2: US.t)
: Lemma
(requires (
offset p + US.v off1 + US.v off2 <= base_len (base p) /\
US.fits (US.v off1 + US.v off2) // cannot be deduced from base_len, because length_fits only works for arrays, not array pointers
))
(ensures (
ptr_shift (ptr_shift p off1) off2 == ptr_shift p (off1 `US.add` off2)
))
= ptr_base_offset_inj (ptr_shift (ptr_shift p off1) off2) (ptr_shift p (off1 `US.add` off2))
/// Computing the right-hand-side part of splitting an array a at
/// offset i.
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.PtrdiffT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Array.fsti"
} | [
{
"abbrev": true,
"full_module": "Steel.ST.HigherArray",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Steel.ST.Array.array elt -> i: FStar.SizeT.t -> Prims.Pure (Steel.ST.Array.array elt) | Prims.Pure | [] | [] | [
"Steel.ST.Array.array",
"FStar.SizeT.t",
"Prims.Mkdtuple2",
"Steel.ST.Array.ptr",
"FStar.Ghost.erased",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Steel.ST.Array.offset",
"FStar.Ghost.reveal",
"Steel.ST.Array.base_len",
"Steel.ST.Array.base",
"Steel.ST.Array.ptr_shift",
"Steel.ST.Array.ptr_of",
"FStar.Ghost.hide",
"Prims.op_Subtraction",
"Steel.ST.Array.length",
"FStar.SizeT.v",
"Steel.ST.Array.merge_into",
"Steel.ST.Array.split_l"
] | [] | false | false | false | false | false | let split_r (#elt: Type) (a: array elt) (i: US.t)
: Pure (array elt)
(requires (US.v i <= length a))
(ensures (fun y -> merge_into (split_l a i) y a)) =
| (| ptr_shift (ptr_of a) i, Ghost.hide (length a - US.v i) |) | false |
FStar.Printf.fst | FStar.Printf.ext_sprintf | val ext_sprintf
(parse_ext: extension_parser)
(s: string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))})
: norm [unascribe; delta; iota; zeta; primops]
(dir_type (Some?.v (parse_format_string s parse_ext))) | val ext_sprintf
(parse_ext: extension_parser)
(s: string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))})
: norm [unascribe; delta; iota; zeta; primops]
(dir_type (Some?.v (parse_format_string s parse_ext))) | let ext_sprintf
(parse_ext: extension_parser)
(s:string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))})
: norm [unascribe; delta; iota; zeta; primops] (dir_type (Some?.v (parse_format_string s parse_ext)))
= norm [unascribe; delta; iota; zeta; primops] (string_of_dirs (Some?.v (parse_format_string s parse_ext)) (fun s -> s)) | {
"file_name": "ulib/FStar.Printf.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 124,
"end_line": 209,
"start_col": 0,
"start_line": 205
} | (*
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.Printf
(*
* A variable arity C-style printf
* See tests/micro-benchmarks/Test.Printf.fst for example usage
*)
open FStar.Char
open FStar.String
module I = FStar.Integers
noeq
type extension =
| MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension
/// `arg`: The format specifiers supported
/// %b : bool
/// %d : int
/// %c : char
/// %s : string
/// %uy : U8.t
/// %us : U16.t
/// %ul : U32.t
/// %uL : U64.t
/// %y : Int8.t
/// %i : Int16.t
/// %l : Int32.t
/// %L : Int64.t
noeq
type arg =
| Bool
| Int
| Char
| String
| U8
| U16
| U32
| U64
| I8
| I16
| I32
| I64
| Extension of extension
/// `arg_type`: Interpreting a `arg` tag as a type
let arg_type (a:arg) : Tot Type0 =
match a with
| Bool -> bool
| Int -> int
| Char -> char
| String -> string
| U8 -> FStar.UInt8.t
| U16 -> FStar.UInt16.t
| U32 -> FStar.UInt32.t
| U64 -> FStar.UInt64.t
| I8 -> FStar.Int8.t
| I16 -> FStar.Int16.t
| I32 -> FStar.Int32.t
| I64 -> FStar.Int64.t
| Extension (MkExtension #t _) -> t
let string_of_arg (#a:arg) (x:arg_type a) : string =
match a with
| Bool -> string_of_bool x
| Int -> string_of_int x
| Char -> string_of_char x
| String -> x
| U8 -> FStar.UInt8.to_string x
| U16 -> FStar.UInt16.to_string x
| U32 -> FStar.UInt32.to_string x
| U64 -> FStar.UInt64.to_string x
| I8 -> FStar.Int8.to_string x
| I16 -> FStar.Int16.to_string x
| I32 -> FStar.Int32.to_string x
| I64 -> FStar.Int64.to_string x
| Extension (MkExtension f) -> f x
/// `dir`: Internal to this module
/// A 'directive"; used when parsing a format specifier
noeq
type dir =
| Lit of char
| Arg of arg
/// `dir_type ds`: Interpreting a list directives as a pure function type
let rec dir_type (ds:list dir) : Tot Type0 =
match ds with
| [] -> string
| Lit c :: ds' -> dir_type ds'
| Arg a :: ds' -> arg_type a -> dir_type ds'
/// `string_of_dirs ds`:
/// Interpreting a list of directives as its function,
/// in a continuation-passing style
let rec string_of_dirs
(ds:list dir)
(k:string -> string)
: dir_type ds
= match ds with
| [] -> k ""
| Lit c :: ds' ->
coerce_eq () (
string_of_dirs ds' (fun res -> k (string_of_char c ^ res))
)
| Arg a :: ds' ->
fun (x : arg_type a) ->
string_of_dirs ds' (fun res -> ((k "")
^ string_of_arg x
^ res))
type extension_parser = i:list char -> option (extension * o:list char{o << i})
/// `parse_format s`:
/// Parses a list of characters into a list of directives
/// Or None, in case the format string is invalid
let rec parse_format
(s:list char)
(parse_ext: extension_parser)
: option (list dir)
= let add_dir (d:dir) (ods : option (list dir))
: option (list dir)
= match ods with
| None -> None
| Some ds -> Some (d::ds)
in
match s with
| [] -> Some []
| ['%'] -> None
//Unsigned integers beging with '%u'
| '%' :: 'u' :: s' -> begin
match s' with
| 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext)
| 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext)
| 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext)
| 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext)
| _ -> None
end
//User extensions begin with '%X'
| '%' :: 'X' :: s' -> begin
match parse_ext s' with
| Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext)
| _ -> None
end
| '%' :: c :: s' -> begin
match c with
| '%' -> add_dir (Lit '%') (parse_format s' parse_ext)
| 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext)
| 'd' -> add_dir (Arg Int) (parse_format s' parse_ext)
| 'c' -> add_dir (Arg Char) (parse_format s' parse_ext)
| 's' -> add_dir (Arg String) (parse_format s' parse_ext)
| 'y' -> add_dir (Arg I8) (parse_format s' parse_ext)
| 'i' -> add_dir (Arg I16) (parse_format s' parse_ext)
| 'l' -> add_dir (Arg I32) (parse_format s' parse_ext)
| 'L' -> add_dir (Arg I64) (parse_format s' parse_ext)
| _ -> None
end
| c :: s' ->
add_dir (Lit c) (parse_format s' parse_ext)
/// `parse_format_string`: parses a format `string` into a list of directives
let parse_format_string
(s:string)
(parse_ext:extension_parser)
: option (list dir)
= parse_format (list_of_string s) parse_ext
let no_extensions : extension_parser = fun s -> None
/// `sprintf`: The main function of this module
/// A variable arity string formatter
/// Used as: `sprintf "format string" v1 ... vn`
///
/// It's marked `inline_for_extraction`, meaning that we don't need
/// any special support in our compilation targets to support sprintf
///
/// `sprintf "Hello %s" "world"`
/// will just extract to `"Hello " ^ "world"`
inline_for_extraction
let sprintf
(s:string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))})
: norm [unascribe; delta; iota; zeta; primops] (dir_type (Some?.v (parse_format_string s no_extensions)))
= norm [unascribe; delta; iota; zeta; primops] (string_of_dirs (Some?.v (parse_format_string s no_extensions)) (fun s -> s))
/// `ext_sprintf`: An extensible version of sprintf | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.Int8.fsti.checked",
"FStar.Int64.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.Int16.fsti.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Printf.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Integers",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "FStar.String",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"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
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
parse_ext: FStar.Printf.extension_parser ->
s:
Prims.string
{FStar.Pervasives.normalize_term (Some? (FStar.Printf.parse_format_string s parse_ext))}
-> FStar.Pervasives.norm [
FStar.Pervasives.unascribe;
FStar.Pervasives.delta;
FStar.Pervasives.iota;
FStar.Pervasives.zeta;
FStar.Pervasives.primops
]
(FStar.Printf.dir_type (Some?.v (FStar.Printf.parse_format_string s parse_ext))) | Prims.Tot | [
"total"
] | [] | [
"FStar.Printf.extension_parser",
"Prims.string",
"FStar.Pervasives.normalize_term",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.list",
"FStar.Printf.dir",
"FStar.Printf.parse_format_string",
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.unascribe",
"FStar.Pervasives.delta",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"Prims.Nil",
"FStar.String.list_of_string",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.None",
"FStar.String.char",
"FStar.Printf.parse_format",
"FStar.Printf.Arg",
"FStar.Printf.U8",
"FStar.Pervasives.Native.option",
"FStar.Printf.U16",
"FStar.Printf.U32",
"FStar.Printf.U64",
"FStar.Printf.extension",
"Prims.precedes",
"FStar.Printf.Extension",
"FStar.Pervasives.Native.tuple2",
"FStar.Printf.Lit",
"FStar.Printf.Bool",
"FStar.Printf.Int",
"FStar.Printf.Char",
"FStar.Printf.String",
"FStar.Printf.I8",
"FStar.Printf.I16",
"FStar.Printf.I32",
"FStar.Printf.I64",
"FStar.Char.char",
"FStar.Printf.dir_type",
"FStar.Printf.arg",
"FStar.Printf.arg_type",
"FStar.Printf.string_of_dirs",
"FStar.Pervasives.Native.__proj__Some__item__v"
] | [] | false | false | false | false | false | let ext_sprintf
(parse_ext: extension_parser)
(s: string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))})
: norm [unascribe; delta; iota; zeta; primops]
(dir_type (Some?.v (parse_format_string s parse_ext))) =
| norm [unascribe; delta; iota; zeta; primops]
(string_of_dirs (Some?.v (parse_format_string s parse_ext)) (fun s -> s)) | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.key0 | val key0:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) | val key0:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) | let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 10,
"start_col": 0,
"start_line": 7
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 32 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let key0:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) =
| [@@ inline_let ]let l =
[
0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy;
0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy;
0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy
]
in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.key0_len | val key0_len:(x: UInt32.t{UInt32.v x = B.length key0}) | val key0_len:(x: UInt32.t{UInt32.v x = B.length key0}) | let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 13,
"start_col": 22,
"start_line": 12
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.key0} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let key0_len:(x: UInt32.t{UInt32.v x = B.length key0}) =
| 32ul | false |
Hacl.Impl.Frodo.KEM.Decaps.fst | Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss2 | val crypto_kem_dec_ss2:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | val crypto_kem_dec_ss2:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss =
push_frame ();
let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in
crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k;
crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss;
clear_words_u8 seed_se_k;
pop_frame () | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 307,
"start_col": 0,
"start_line": 301
} | module Hacl.Impl.Frodo.KEM.Decaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.KEM.Encaps
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module FP = Spec.Frodo.Params
module KG = Hacl.Impl.Frodo.KEM.KeyGen
module S = Spec.Frodo.KEM.Decaps
module M = Spec.Matrix
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val get_bp_c_matrices:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ct /\ live h bp_matrix /\ live h c_matrix /\
disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\
(as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct))
let get_bp_c_matrices a ct bp_matrix c_matrix =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix;
frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix
inline_for_extraction noextract
val frodo_mu_decode:
a:FP.frodo_alg
-> s_bytes:lbytes (secretmatrixbytes_len a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h s_bytes /\ live h bp_matrix /\
live h c_matrix /\ live h mu_decode /\
disjoint mu_decode s_bytes /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0))
(ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\
as_seq h1 mu_decode ==
S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode =
push_frame();
let s_matrix = matrix_create (params_n a) params_nbar in
let m_matrix = matrix_create params_nbar params_nbar in
matrix_from_lbytes s_bytes s_matrix;
matrix_mul_s bp_matrix s_matrix m_matrix;
matrix_sub c_matrix m_matrix;
frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode;
clear_matrix s_matrix;
clear_matrix m_matrix;
pop_frame()
inline_for_extraction noextract
val get_bpp_cp_matrices_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix;
loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk)
(as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix))
let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix =
FP.expand_crypto_secretkeybytes a;
FP.expand_crypto_publickeybytes a;
let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix;
frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix;
mod_pow2 (params_logq a) bpp_matrix;
mod_pow2 (params_logq a) cp_matrix
#push-options "--z3rlimit 150"
inline_for_extraction noextract
val get_bpp_cp_matrices:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk))
let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix =
push_frame ();
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_dec_kp_s_cond:
a:FP.frodo_alg
-> bp_matrix:matrix_t params_nbar (params_n a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h bp_matrix /\ live h bpp_matrix /\
live h c_matrix /\ live h cp_matrix)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix)
(as_matrix h0 c_matrix) (as_matrix h0 cp_matrix))
let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix =
let b1 = matrix_eq bp_matrix bpp_matrix in
let b2 = matrix_eq c_matrix cp_matrix in
b1 &. b2
inline_for_extraction noextract
val crypto_kem_dec_kp_s:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se /\
live h c_matrix /\ live h sk /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk])
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix =
push_frame ();
let bpp_matrix = matrix_create params_nbar (params_n a) in
let cp_matrix = matrix_create params_nbar params_nbar in
get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix;
let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in
pop_frame ();
mask
inline_for_extraction noextract
val crypto_kem_dec_ss0:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)}
-> kp:lbytes (crypto_bytes a)
-> s:lbytes (crypto_bytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h kp /\ live h s /\ live h ss /\
disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\
disjoint kp s)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s))
let crypto_kem_dec_ss0 a ct mask kp s ss =
push_frame ();
let kp_s = create (crypto_bytes a) (u8 0) in
Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s;
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let ss_init = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init;
frodo_shake a ss_init_len ss_init (crypto_bytes a) ss;
clear_words_u8 ss_init;
clear_words_u8 kp_s;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_seed_se_k:
a:FP.frodo_alg
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\ live h seed_se_k /\
disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk))
let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k =
push_frame ();
let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in
let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in
let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in
concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode;
frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_ss1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
let s = sub sk 0ul (crypto_bytes a) in
let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in
crypto_kem_dec_ss0 a ct mask kp s ss
inline_for_extraction noextract
val crypto_kem_dec_ss2:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Decaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Decaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM.Encaps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) ->
mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
bp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
c_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.clear_words_u8",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss1",
"Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_seed_se_k",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.uint8",
"Lib.IntTypes.u8",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss =
| push_frame ();
let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in
crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k;
crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss;
clear_words_u8 seed_se_k;
pop_frame () | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.nonce0 | val nonce0:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) | val nonce0:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) | let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 18,
"start_col": 0,
"start_line": 15
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 12 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let nonce0:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) =
| [@@ inline_let ]let l =
[0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy]
in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | false |
Hacl.Impl.Frodo.KEM.Decaps.fst | Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec | val crypto_kem_dec:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk)) | val crypto_kem_dec:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk)) | let crypto_kem_dec a gen_a ss ct sk =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
let c_matrix = matrix_create params_nbar params_nbar in
get_bp_c_matrices a ct bp_matrix c_matrix;
crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix;
pop_frame ();
u32 0 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 7,
"end_line": 407,
"start_col": 0,
"start_line": 399
} | module Hacl.Impl.Frodo.KEM.Decaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.KEM.Encaps
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module FP = Spec.Frodo.Params
module KG = Hacl.Impl.Frodo.KEM.KeyGen
module S = Spec.Frodo.KEM.Decaps
module M = Spec.Matrix
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val get_bp_c_matrices:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ct /\ live h bp_matrix /\ live h c_matrix /\
disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\
(as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct))
let get_bp_c_matrices a ct bp_matrix c_matrix =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix;
frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix
inline_for_extraction noextract
val frodo_mu_decode:
a:FP.frodo_alg
-> s_bytes:lbytes (secretmatrixbytes_len a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h s_bytes /\ live h bp_matrix /\
live h c_matrix /\ live h mu_decode /\
disjoint mu_decode s_bytes /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0))
(ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\
as_seq h1 mu_decode ==
S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode =
push_frame();
let s_matrix = matrix_create (params_n a) params_nbar in
let m_matrix = matrix_create params_nbar params_nbar in
matrix_from_lbytes s_bytes s_matrix;
matrix_mul_s bp_matrix s_matrix m_matrix;
matrix_sub c_matrix m_matrix;
frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode;
clear_matrix s_matrix;
clear_matrix m_matrix;
pop_frame()
inline_for_extraction noextract
val get_bpp_cp_matrices_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix;
loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk)
(as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix))
let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix =
FP.expand_crypto_secretkeybytes a;
FP.expand_crypto_publickeybytes a;
let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix;
frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix;
mod_pow2 (params_logq a) bpp_matrix;
mod_pow2 (params_logq a) cp_matrix
#push-options "--z3rlimit 150"
inline_for_extraction noextract
val get_bpp_cp_matrices:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk))
let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix =
push_frame ();
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_dec_kp_s_cond:
a:FP.frodo_alg
-> bp_matrix:matrix_t params_nbar (params_n a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h bp_matrix /\ live h bpp_matrix /\
live h c_matrix /\ live h cp_matrix)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix)
(as_matrix h0 c_matrix) (as_matrix h0 cp_matrix))
let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix =
let b1 = matrix_eq bp_matrix bpp_matrix in
let b2 = matrix_eq c_matrix cp_matrix in
b1 &. b2
inline_for_extraction noextract
val crypto_kem_dec_kp_s:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se /\
live h c_matrix /\ live h sk /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk])
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix =
push_frame ();
let bpp_matrix = matrix_create params_nbar (params_n a) in
let cp_matrix = matrix_create params_nbar params_nbar in
get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix;
let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in
pop_frame ();
mask
inline_for_extraction noextract
val crypto_kem_dec_ss0:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)}
-> kp:lbytes (crypto_bytes a)
-> s:lbytes (crypto_bytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h kp /\ live h s /\ live h ss /\
disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\
disjoint kp s)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s))
let crypto_kem_dec_ss0 a ct mask kp s ss =
push_frame ();
let kp_s = create (crypto_bytes a) (u8 0) in
Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s;
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let ss_init = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init;
frodo_shake a ss_init_len ss_init (crypto_bytes a) ss;
clear_words_u8 ss_init;
clear_words_u8 kp_s;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_seed_se_k:
a:FP.frodo_alg
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\ live h seed_se_k /\
disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk))
let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k =
push_frame ();
let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in
let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in
let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in
concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode;
frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_ss1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
let s = sub sk 0ul (crypto_bytes a) in
let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in
crypto_kem_dec_ss0 a ct mask kp s ss
inline_for_extraction noextract
val crypto_kem_dec_ss2:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> mu_decode:lbytes (bytes_mu a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\
live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\
loc_pairwise_disjoint [loc ct; loc sk;
loc mu_decode; loc bp_matrix; loc c_matrix; loc ss])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk)
(as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss =
push_frame ();
let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in
crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k;
crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss;
clear_words_u8 seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec_mu:
a:FP.frodo_alg
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h sk /\ live h mu_decode /\
live h bp_matrix /\ live h c_matrix /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\
loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix])
(ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\
as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk)
(as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode =
FP.expand_crypto_secretkeybytes a;
let s_bytes = sub sk (crypto_bytes a +! crypto_publickeybytes a) (secretmatrixbytes_len a) in
frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode
inline_for_extraction noextract
val crypto_kem_dec0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\ live h mu_decode /\
live h bp_matrix /\ live h c_matrix /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\
loc_pairwise_disjoint [loc ss; loc ct; loc sk;
loc mu_decode; loc bp_matrix; loc c_matrix])
(ensures fun h0 _ h1 -> modifies (loc ss |+| loc mu_decode) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode =
crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode;
crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss
inline_for_extraction noextract
val crypto_kem_dec1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
live h bp_matrix /\ live h c_matrix /\
loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix])
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix =
push_frame ();
let mu_decode = create (bytes_mu a) (u8 0) in
crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode;
clear_words_u8 mu_decode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_dec:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk)) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Decaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Decaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM.Encaps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a)
-> FStar.HyperStack.ST.Stack Lib.IntTypes.uint32 | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Lib.IntTypes.u32",
"Lib.IntTypes.uint32",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec1",
"Hacl.Impl.Frodo.KEM.Decaps.get_bp_c_matrices",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Matrix.matrix_create",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_n",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let crypto_kem_dec a gen_a ss ct sk =
| push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
let c_matrix = matrix_create params_nbar params_nbar in
get_bp_c_matrices a ct bp_matrix c_matrix;
crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix;
pop_frame ();
u32 0 | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.aad0 | val aad0:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) | val aad0:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) | let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 26,
"start_col": 0,
"start_line": 23
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 12 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let aad0:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) =
| [@@ inline_let ]let l =
[0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy]
in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.nonce0_len | val nonce0_len:(x: UInt32.t{UInt32.v x = B.length nonce0}) | val nonce0_len:(x: UInt32.t{UInt32.v x = B.length nonce0}) | let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 21,
"start_col": 22,
"start_line": 20
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.nonce0} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let nonce0_len:(x: UInt32.t{UInt32.v x = B.length nonce0}) =
| 12ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.aad0_len | val aad0_len:(x: UInt32.t{UInt32.v x = B.length aad0}) | val aad0_len:(x: UInt32.t{UInt32.v x = B.length aad0}) | let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 29,
"start_col": 22,
"start_line": 28
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.aad0} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let aad0_len:(x: UInt32.t{UInt32.v x = B.length aad0}) =
| 12ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.input0_len | val input0_len:(x: UInt32.t{UInt32.v x = B.length input0}) | val input0_len:(x: UInt32.t{UInt32.v x = B.length input0}) | let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 7,
"end_line": 37,
"start_col": 22,
"start_line": 36
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.input0} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let input0_len:(x: UInt32.t{UInt32.v x = B.length input0}) =
| 265ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.output0_len | val output0_len:(x: UInt32.t{UInt32.v x = B.length output0}) | val output0_len:(x: UInt32.t{UInt32.v x = B.length output0}) | let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 7,
"end_line": 45,
"start_col": 22,
"start_line": 44
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.output0} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let output0_len:(x: UInt32.t{UInt32.v x = B.length output0}) =
| 281ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.key1_len | val key1_len:(x: UInt32.t{UInt32.v x = B.length key1}) | val key1_len:(x: UInt32.t{UInt32.v x = B.length key1}) | let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 53,
"start_col": 22,
"start_line": 52
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.key1} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let key1_len:(x: UInt32.t{UInt32.v x = B.length key1}) =
| 32ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.nonce1 | val nonce1:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) | val nonce1:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) | let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 58,
"start_col": 0,
"start_line": 55
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 12 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let nonce1:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) =
| [@@ inline_let ]let l =
[0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy]
in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | false |
Hacl.Impl.Frodo.KEM.Decaps.fst | Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_kp_s | val crypto_kem_dec_kp_s:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se /\
live h c_matrix /\ live h sk /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk])
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | val crypto_kem_dec_kp_s:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se /\
live h c_matrix /\ live h sk /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk])
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix =
push_frame ();
let bpp_matrix = matrix_create params_nbar (params_n a) in
let cp_matrix = matrix_create params_nbar params_nbar in
get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix;
let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in
pop_frame ();
mask | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 194,
"start_col": 0,
"start_line": 187
} | module Hacl.Impl.Frodo.KEM.Decaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.KEM.Encaps
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module FP = Spec.Frodo.Params
module KG = Hacl.Impl.Frodo.KEM.KeyGen
module S = Spec.Frodo.KEM.Decaps
module M = Spec.Matrix
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val get_bp_c_matrices:
a:FP.frodo_alg
-> ct:lbytes (crypto_ciphertextbytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h ct /\ live h bp_matrix /\ live h c_matrix /\
disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\
(as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct))
let get_bp_c_matrices a ct bp_matrix c_matrix =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix;
frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix
inline_for_extraction noextract
val frodo_mu_decode:
a:FP.frodo_alg
-> s_bytes:lbytes (secretmatrixbytes_len a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> mu_decode:lbytes (bytes_mu a)
-> Stack unit
(requires fun h ->
live h s_bytes /\ live h bp_matrix /\
live h c_matrix /\ live h mu_decode /\
disjoint mu_decode s_bytes /\
as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0))
(ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\
as_seq h1 mu_decode ==
S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode =
push_frame();
let s_matrix = matrix_create (params_n a) params_nbar in
let m_matrix = matrix_create params_nbar params_nbar in
matrix_from_lbytes s_bytes s_matrix;
matrix_mul_s bp_matrix s_matrix m_matrix;
matrix_sub c_matrix m_matrix;
frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode;
clear_matrix s_matrix;
clear_matrix m_matrix;
pop_frame()
inline_for_extraction noextract
val get_bpp_cp_matrices_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix;
loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk)
(as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix))
let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix =
FP.expand_crypto_secretkeybytes a;
FP.expand_crypto_publickeybytes a;
let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix;
frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix;
mod_pow2 (params_logq a) bpp_matrix;
mod_pow2 (params_logq a) cp_matrix
#push-options "--z3rlimit 150"
inline_for_extraction noextract
val get_bpp_cp_matrices:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h mu_decode /\ live h sk /\
live h bpp_matrix /\ live h cp_matrix /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix])
(ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\
(as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) ==
S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk))
let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix =
push_frame ();
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_dec_kp_s_cond:
a:FP.frodo_alg
-> bp_matrix:matrix_t params_nbar (params_n a)
-> bpp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> cp_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h bp_matrix /\ live h bpp_matrix /\
live h c_matrix /\ live h cp_matrix)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix)
(as_matrix h0 c_matrix) (as_matrix h0 cp_matrix))
let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix =
let b1 = matrix_eq bp_matrix bpp_matrix in
let b2 = matrix_eq c_matrix cp_matrix in
b1 &. b2
inline_for_extraction noextract
val crypto_kem_dec_kp_s:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu_decode:lbytes (bytes_mu a)
-> seed_se:lbytes (crypto_bytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> c_matrix:matrix_t params_nbar params_nbar
-> Stack uint16
(requires fun h ->
live h mu_decode /\ live h bp_matrix /\ live h seed_se /\
live h c_matrix /\ live h sk /\
loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk])
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se)
(as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Decaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Decaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM.Encaps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
seed_se: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) ->
bp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
c_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar
-> FStar.HyperStack.ST.Stack Lib.IntTypes.uint16 | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"Lib.IntTypes.uint16",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_kp_s_cond",
"Hacl.Impl.Frodo.KEM.Decaps.get_bpp_cp_matrices",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Matrix.matrix_create",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix =
| push_frame ();
let bpp_matrix = matrix_create params_nbar (params_n a) in
let cp_matrix = matrix_create params_nbar params_nbar in
get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix;
let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in
pop_frame ();
mask | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.aad1_len | val aad1_len:(x: UInt32.t{UInt32.v x = B.length aad1}) | val aad1_len:(x: UInt32.t{UInt32.v x = B.length aad1}) | let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 69,
"start_col": 22,
"start_line": 68
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.aad1} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let aad1_len:(x: UInt32.t{UInt32.v x = B.length aad1}) =
| 0ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.aad1 | val aad1:(b: B.buffer UInt8.t {B.length b = 0 /\ B.recallable b}) | val aad1:(b: B.buffer UInt8.t {B.length b = 0 /\ B.recallable b}) | let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 66,
"start_col": 0,
"start_line": 63
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 0 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Nil"
] | [] | false | false | false | false | false | let aad1:(b: B.buffer UInt8.t {B.length b = 0 /\ B.recallable b}) =
| [@@ inline_let ]let l = [] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.nonce1_len | val nonce1_len:(x: UInt32.t{UInt32.v x = B.length nonce1}) | val nonce1_len:(x: UInt32.t{UInt32.v x = B.length nonce1}) | let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 61,
"start_col": 22,
"start_line": 60
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.nonce1} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let nonce1_len:(x: UInt32.t{UInt32.v x = B.length nonce1}) =
| 12ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.output1 | val output1:(b: B.buffer UInt8.t {B.length b = 16 /\ B.recallable b}) | val output1:(b: B.buffer UInt8.t {B.length b = 16 /\ B.recallable b}) | let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 82,
"start_col": 0,
"start_line": 79
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul
let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) =
0ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 16 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let output1:(b: B.buffer UInt8.t {B.length b = 16 /\ B.recallable b}) =
| [@@ inline_let ]let l =
[
0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy;
0x8auy; 0xf7uy; 0x69uy; 0x92uy
]
in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.output1_len | val output1_len:(x: UInt32.t{UInt32.v x = B.length output1}) | val output1_len:(x: UInt32.t{UInt32.v x = B.length output1}) | let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) =
16ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 85,
"start_col": 22,
"start_line": 84
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul
let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) =
0ul
let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.output1} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let output1_len:(x: UInt32.t{UInt32.v x = B.length output1}) =
| 16ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.key1 | val key1:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) | val key1:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) | let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 50,
"start_col": 0,
"start_line": 47
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 32 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let key1:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) =
| [@@ inline_let ]let l =
[
0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy;
0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy;
0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy
]
in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.key2 | val key2:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) | val key2:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) | let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 90,
"start_col": 0,
"start_line": 87
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul
let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) =
0ul
let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) =
16ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 32 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let key2:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) =
| [@@ inline_let ]let l =
[
0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy;
0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy;
0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy
]
in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.input1_len | val input1_len:(x: UInt32.t{UInt32.v x = B.length input1}) | val input1_len:(x: UInt32.t{UInt32.v x = B.length input1}) | let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) =
0ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 77,
"start_col": 22,
"start_line": 76
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul
let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.input1} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let input1_len:(x: UInt32.t{UInt32.v x = B.length input1}) =
| 0ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.nonce2 | val nonce2:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) | val nonce2:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) | let nonce2: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x3duy; 0x86uy; 0xb5uy; 0x6buy; 0xc8uy; 0xa3uy; 0x1fuy; 0x1duy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 98,
"start_col": 0,
"start_line": 95
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul
let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) =
0ul
let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) =
16ul
let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key2_len: (x:UInt32.t { UInt32.v x = B.length key2 }) =
32ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{LowStar.Monotonic.Buffer.length b = 12 /\ LowStar.Monotonic.Buffer.recallable b} | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | false | false | let nonce2:(b: B.buffer UInt8.t {B.length b = 12 /\ B.recallable b}) =
| [@@ inline_let ]let l =
[0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x3duy; 0x86uy; 0xb5uy; 0x6buy; 0xc8uy; 0xa3uy; 0x1fuy; 0x1duy]
in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.input1 | val input1:(b: B.buffer UInt8.t {B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1}) | val input1:(b: B.buffer UInt8.t {B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1}) | let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 74,
"start_col": 0,
"start_line": 71
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{ LowStar.Monotonic.Buffer.length b = 0 /\ LowStar.Monotonic.Buffer.recallable b /\
LowStar.Monotonic.Buffer.disjoint b Test.Vectors.Chacha20Poly1305.aad1 } | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"LowStar.Monotonic.Buffer.disjoint",
"Test.Vectors.Chacha20Poly1305.aad1",
"Prims.list",
"Prims.Nil",
"LowStar.Monotonic.Buffer.recall"
] | [] | false | false | false | false | false | let input1:(b: B.buffer UInt8.t {B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1}) =
| B.recall aad1;
[@@ inline_let ]let l = [] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.key2_len | val key2_len:(x: UInt32.t{UInt32.v x = B.length key2}) | val key2_len:(x: UInt32.t{UInt32.v x = B.length key2}) | let key2_len: (x:UInt32.t { UInt32.v x = B.length key2 }) =
32ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 93,
"start_col": 22,
"start_line": 92
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul
let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) =
0ul
let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) =
16ul
let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.key2} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let key2_len:(x: UInt32.t{UInt32.v x = B.length key2}) =
| 32ul | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.aad2_len | val aad2_len:(x: UInt32.t{UInt32.v x = B.length aad2}) | val aad2_len:(x: UInt32.t{UInt32.v x = B.length aad2}) | let aad2_len: (x:UInt32.t { UInt32.v x = B.length aad2 }) =
8ul | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 109,
"start_col": 22,
"start_line": 108
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul
let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) =
0ul
let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) =
16ul
let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key2_len: (x:UInt32.t { UInt32.v x = B.length key2 }) =
32ul
let nonce2: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x3duy; 0x86uy; 0xb5uy; 0x6buy; 0xc8uy; 0xa3uy; 0x1fuy; 0x1duy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce2_len: (x:UInt32.t { UInt32.v x = B.length nonce2 }) =
12ul
let aad2: (b: B.buffer UInt8.t { B.length b = 8 /\ B.recallable b }) =
[@inline_let] let l = [ 0x33uy; 0x10uy; 0x41uy; 0x12uy; 0x1fuy; 0xf3uy; 0xd2uy; 0x6buy; ] in
assert_norm (List.Tot.length l = 8);
B.gcmalloc_of_list HyperStack.root l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
FStar.UInt32.t
{FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.aad2} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let aad2_len:(x: UInt32.t{UInt32.v x = B.length aad2}) =
| 8ul | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.