effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.HyperStack.ST.Stack | val make_u64_4 (out:qelem) (f:qelem4) : Stack unit
(requires fun h -> live h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat4 f /\
(let (f0,f1,f2,f3) = f in as_seq h1 out == LSeq.create4 f0 f1 f2 f3)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) | val make_u64_4 (out:qelem) (f:qelem4) : Stack unit
(requires fun h -> live h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat4 f /\
(let (f0,f1,f2,f3) = f in as_seq h1 out == LSeq.create4 f0 f1 f2 f3))
let make_u64_4 out (f0, f1, f2, f3) = | true | null | false | out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.Spec.K256.Scalar.qelem4",
"Lib.IntTypes.uint64",
"Prims._assert",
"FStar.Seq.Base.equal",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.K256.Scalar.qnlimb",
"Lib.Sequence.create4",
"Prims.unit",
"Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.op_Array_Assignment",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
} | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_u64_4 (out:qelem) (f:qelem4) : Stack unit
(requires fun h -> live h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat4 f /\
(let (f0,f1,f2,f3) = f in as_seq h1 out == LSeq.create4 f0 f1 f2 f3)) | [] | Hacl.K256.Scalar.make_u64_4 | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | out: Hacl.K256.Scalar.qelem -> f: Hacl.Spec.K256.Scalar.qelem4
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 62,
"end_line": 73,
"start_col": 2,
"start_line": 67
} |
FStar.HyperStack.ST.Stack | val qsqr (out f: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ eq_or_disjoint out f /\
qe_lt_q h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qmul (qas_nat h0 f) (qas_nat h0 f) /\
qe_lt_q h1 out) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qsqr out f =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.sqr f tmp;
SN.bn_sqr_lemma (as_seq h0 f);
modq out tmp;
pop_frame () | val qsqr (out f: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ eq_or_disjoint out f /\
qe_lt_q h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qmul (qas_nat h0 f) (qas_nat h0 f) /\
qe_lt_q h1 out)
let qsqr out f = | true | null | false | push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.sqr f tmp;
SN.bn_sqr_lemma (as_seq h0 f);
modq out tmp;
pop_frame () | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.K256.Scalar.modq",
"Hacl.Spec.Bignum.bn_sqr_lemma",
"Lib.IntTypes.U64",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.K256.Scalar.qnlimb",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Hacl.Bignum.__proj__Mkbn__item__sqr",
"Hacl.K256.Scalar.kn",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Lib.Buffer.lbuffer",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline]
let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame ()
val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
[@CInline]
let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c
inline_for_extraction noextract
val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
let modq_before_final t01 a out =
push_frame ();
let m = create 7ul (u64 0) in
let p = create 5ul (u64 0) in
let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in
let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in
let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in
pop_frame ();
c2
val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q)
[@CInline]
let modq out a =
push_frame ();
let r = create_qelem () in
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let t01 = sub tmp 0ul 2ul in
let h0 = ST.get () in
assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1));
let c0 = modq_before_final t01 a r in
let c1 = kn.BN.add r tmp out in
let mask = u64 0 -. (c0 +. c1) in
map2T qnlimb out (BB.mask_select mask) out r;
let h1 = ST.get () in
KL.mod_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let qmul out f1 f2 =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.mul f1 f2 tmp;
SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2);
modq out tmp;
pop_frame ()
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qsqr (out f: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ eq_or_disjoint out f /\
qe_lt_q h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qmul (qas_nat h0 f) (qas_nat h0 f) /\
qe_lt_q h1 out) | [] | Hacl.K256.Scalar.qsqr | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | out: Hacl.K256.Scalar.qelem -> f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 339,
"start_col": 2,
"start_line": 332
} |
FStar.HyperStack.ST.Stack | val load_qelem_modq: f:qelem -> b:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h f /\ live h b /\ disjoint f b)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == BSeq.nat_from_bytes_be (as_seq h0 b) % S.q /\
qe_lt_q h1 f) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame () | val load_qelem_modq: f:qelem -> b:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h f /\ live h b /\ disjoint f b)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == BSeq.nat_from_bytes_be (as_seq h0 b) % S.q /\
qe_lt_q h1 f)
let load_qelem_modq f b = | true | null | false | push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame () | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.K256.Scalar.modq_short",
"Lib.Buffer.copy",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Hacl.K256.Scalar.qnlimb",
"Hacl.K256.Scalar.load_qelem",
"Hacl.K256.Scalar.create_qelem",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_qelem_modq: f:qelem -> b:lbuffer uint8 32ul -> Stack unit
(requires fun h ->
live h f /\ live h b /\ disjoint f b)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == BSeq.nat_from_bytes_be (as_seq h0 b) % S.q /\
qe_lt_q h1 f) | [] | Hacl.K256.Scalar.load_qelem_modq | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Scalar.qelem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 212,
"start_col": 2,
"start_line": 207
} |
FStar.HyperStack.ST.Stack | val qmul (out f1 f2: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f1 /\ live h f2 /\
eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\
qe_lt_q h f1 /\ qe_lt_q h f2)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qmul (qas_nat h0 f1) (qas_nat h0 f2) /\
qe_lt_q h1 out) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qmul out f1 f2 =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.mul f1 f2 tmp;
SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2);
modq out tmp;
pop_frame () | val qmul (out f1 f2: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f1 /\ live h f2 /\
eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\
qe_lt_q h f1 /\ qe_lt_q h f2)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qmul (qas_nat h0 f1) (qas_nat h0 f2) /\
qe_lt_q h1 out)
let qmul out f1 f2 = | true | null | false | push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.mul f1 f2 tmp;
SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2);
modq out tmp;
pop_frame () | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.K256.Scalar.modq",
"Hacl.Spec.Bignum.bn_mul_lemma",
"Lib.IntTypes.U64",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.K256.Scalar.qnlimb",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Hacl.Bignum.__proj__Mkbn__item__mul",
"Hacl.K256.Scalar.kn",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Lib.Buffer.lbuffer",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline]
let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame ()
val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
[@CInline]
let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c
inline_for_extraction noextract
val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
let modq_before_final t01 a out =
push_frame ();
let m = create 7ul (u64 0) in
let p = create 5ul (u64 0) in
let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in
let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in
let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in
pop_frame ();
c2
val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q)
[@CInline]
let modq out a =
push_frame ();
let r = create_qelem () in
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let t01 = sub tmp 0ul 2ul in
let h0 = ST.get () in
assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1));
let c0 = modq_before_final t01 a r in
let c1 = kn.BN.add r tmp out in
let mask = u64 0 -. (c0 +. c1) in
map2T qnlimb out (BB.mask_select mask) out r;
let h1 = ST.get () in
KL.mod_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qmul (out f1 f2: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f1 /\ live h f2 /\
eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\
qe_lt_q h f1 /\ qe_lt_q h f2)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qmul (qas_nat h0 f1) (qas_nat h0 f2) /\
qe_lt_q h1 out) | [] | Hacl.K256.Scalar.qmul | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | out: Hacl.K256.Scalar.qelem -> f1: Hacl.K256.Scalar.qelem -> f2: Hacl.K256.Scalar.qelem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 327,
"start_col": 2,
"start_line": 320
} |
FStar.HyperStack.ST.Stack | val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit
(requires fun h -> live h res /\ live h l /\ disjoint res l /\
as_seq h res == LSeq.create 4 (u64 0))
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
(let res_b = SN.bn_rshift (as_seq h0 l) 6 in
let res_b_padded = LSeq.create 4 (u64 0) in
let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in
as_seq h1 res == res_b_padded)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rshift_update_sub res l =
let h1 = ST.get () in
update_sub_f h1 res 0ul 2ul
(fun h -> SN.bn_rshift (as_seq h1 l) 6)
(fun _ -> BN.bn_rshift 8ul l 6ul (sub res 0ul 2ul)) | val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit
(requires fun h -> live h res /\ live h l /\ disjoint res l /\
as_seq h res == LSeq.create 4 (u64 0))
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
(let res_b = SN.bn_rshift (as_seq h0 l) 6 in
let res_b_padded = LSeq.create 4 (u64 0) in
let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in
as_seq h1 res == res_b_padded))
let rshift_update_sub res l = | true | null | false | let h1 = ST.get () in
update_sub_f h1
res
0ul
2ul
(fun h -> SN.bn_rshift (as_seq h1 l) 6)
(fun _ -> BN.bn_rshift 8ul l 6ul (sub res 0ul 2ul)) | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.update_sub_f",
"Hacl.K256.Scalar.qnlimb",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Spec.Bignum.bn_rshift",
"Lib.IntTypes.U64",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Sequence.lseq",
"Prims.unit",
"Hacl.Bignum.bn_rshift",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.sub",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Lib.Buffer.lbuffer_t",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline]
let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame ()
val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
[@CInline]
let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c
inline_for_extraction noextract
val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
let modq_before_final t01 a out =
push_frame ();
let m = create 7ul (u64 0) in
let p = create 5ul (u64 0) in
let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in
let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in
let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in
pop_frame ();
c2
val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q)
[@CInline]
let modq out a =
push_frame ();
let r = create_qelem () in
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let t01 = sub tmp 0ul 2ul in
let h0 = ST.get () in
assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1));
let c0 = modq_before_final t01 a r in
let c1 = kn.BN.add r tmp out in
let mask = u64 0 -. (c0 +. c1) in
map2T qnlimb out (BB.mask_select mask) out r;
let h1 = ST.get () in
KL.mod_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let qmul out f1 f2 =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.mul f1 f2 tmp;
SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2);
modq out tmp;
pop_frame ()
[@CInline]
let qsqr out f =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.sqr f tmp;
SN.bn_sqr_lemma (as_seq h0 f);
modq out tmp;
pop_frame ()
[@CInline]
let qnegate_conditional_vartime f is_negate =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let zero = create_qelem () in
if is_negate then begin
let h0 = ST.get () in
kn.BN.sub_mod_n n zero f f;
SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f);
let h1 = ST.get () in
assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q);
Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1;
assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q) end;
pop_frame ()
[@CInline]
let is_qelem_le_q_halved_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_le_q_halved_vartime4_lemma (a0,a1,a2,a3);
is_qelem_le_q_halved_vartime4 (a0,a1,a2,a3)
let is_qelem_lt_pow2_128_vartime f =
let open Lib.RawIntTypes in
let h0 = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h0 f);
let f0 = Ghost.hide (LSeq.index (as_seq h0 f) 0) in
let f1 = Ghost.hide (LSeq.index (as_seq h0 f) 1) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
KL.is_qelem_lt_pow2_128_vartime4_lemma (Ghost.reveal f0, Ghost.reveal f1,f2,f3);
u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit
(requires fun h -> live h res /\ live h l /\ disjoint res l /\
as_seq h res == LSeq.create 4 (u64 0))
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
(let res_b = SN.bn_rshift (as_seq h0 l) 6 in
let res_b_padded = LSeq.create 4 (u64 0) in
let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in
as_seq h1 res == res_b_padded)) | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit
(requires fun h -> live h res /\ live h l /\ disjoint res l /\
as_seq h res == LSeq.create 4 (u64 0))
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
(let res_b = SN.bn_rshift (as_seq h0 l) 6 in
let res_b_padded = LSeq.create 4 (u64 0) in
let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in
as_seq h1 res == res_b_padded)) | [] | Hacl.K256.Scalar.rshift_update_sub | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | res: Hacl.K256.Scalar.qelem -> l: Lib.Buffer.lbuffer Lib.IntTypes.uint64 8ul
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 55,
"end_line": 396,
"start_col": 29,
"start_line": 392
} |
FStar.HyperStack.ST.Stack | val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame () | val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
let modq_short out a = | true | null | false | push_frame ();
let tmp = create_qelem () in
[@@ inline_let ]let t0, t1, t2, t3 = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0, t1, t2, t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame () | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Lib.IntTypes.uint64",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.K256.Scalar.Lemmas.mod_short_lseq_lemma",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.K256.Scalar.qnlimb",
"Lib.Buffer.map2T",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.U64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.__proj__Mkbn__item__add",
"Hacl.K256.Scalar.kn",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Scalar.make_u64_4",
"FStar.Pervasives.Native.Mktuple4",
"Hacl.Spec.K256.Scalar.qelem4",
"Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256",
"Hacl.K256.Scalar.create_qelem",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q) | [] | Hacl.K256.Scalar.modq_short | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | out: Hacl.K256.Scalar.qelem -> a: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 202,
"start_col": 2,
"start_line": 191
} |
FStar.HyperStack.ST.Stack | val load_qelem_conditional: res:qelem -> b:lbuffer uint8 32ul -> Stack uint64
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 m h1 -> modifies (loc res) h0 h1 /\
(let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in
let is_b_valid = 0 < b_nat && b_nat < S.q in
(v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = is_b_valid /\
qas_nat h1 res == (if is_b_valid then b_nat else 1))) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid | val load_qelem_conditional: res:qelem -> b:lbuffer uint8 32ul -> Stack uint64
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 m h1 -> modifies (loc res) h0 h1 /\
(let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in
let is_b_valid = 0 < b_nat && b_nat < S.q in
(v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = is_b_valid /\
qas_nat h1 res == (if is_b_valid then b_nat else 1)))
let load_qelem_conditional res b = | true | null | false | push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.uint64",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.K256.Scalar.qnlimb",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.ByteBuffer.buf_mask_select",
"Hacl.K256.Scalar.create_one",
"Lib.IntTypes.int_t",
"Hacl.K256.Scalar.load_qelem_check",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_qelem_conditional: res:qelem -> b:lbuffer uint8 32ul -> Stack uint64
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 m h1 -> modifies (loc res) h0 h1 /\
(let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in
let is_b_valid = 0 < b_nat && b_nat < S.q in
(v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = is_b_valid /\
qas_nat h1 res == (if is_b_valid then b_nat else 1))) | [] | Hacl.K256.Scalar.load_qelem_conditional | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | res: Hacl.K256.Scalar.qelem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64 | {
"end_col": 12,
"end_line": 167,
"start_col": 2,
"start_line": 159
} |
FStar.HyperStack.ST.Stack | val qadd (out f1 f2: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f1 /\ live h f2 /\
eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\
qe_lt_q h f1 /\ qe_lt_q h f2)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qadd (qas_nat h0 f1) (qas_nat h0 f2) /\
qe_lt_q h1 out) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame () | val qadd (out f1 f2: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f1 /\ live h f2 /\
eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\
qe_lt_q h f1 /\ qe_lt_q h f2)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qadd (qas_nat h0 f1) (qas_nat h0 f2) /\
qe_lt_q h1 out)
let qadd out f1 f2 = | true | null | false | push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame () | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.Bignum.bn_add_mod_n_lemma",
"Lib.IntTypes.U64",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.K256.Scalar.qnlimb",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Hacl.Bignum.__proj__Mkbn__item__add_mod_n",
"Hacl.K256.Scalar.kn",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Scalar.make_u64_4",
"Hacl.K256.Scalar.make_order_k256",
"Hacl.K256.Scalar.create_qelem",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qadd (out f1 f2: qelem) : Stack unit
(requires fun h ->
live h out /\ live h f1 /\ live h f2 /\
eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\
qe_lt_q h f1 /\ qe_lt_q h f2)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == S.qadd (qas_nat h0 f1) (qas_nat h0 f2) /\
qe_lt_q h1 out) | [] | Hacl.K256.Scalar.qadd | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | out: Hacl.K256.Scalar.qelem -> f1: Hacl.K256.Scalar.qelem -> f2: Hacl.K256.Scalar.qelem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 231,
"start_col": 2,
"start_line": 224
} |
FStar.HyperStack.ST.Stack | val load_qelem_check: f:qelem -> b:lbuffer uint8 32ul -> Stack uint64
(requires fun h ->
live h f /\ live h b /\ disjoint f b)
(ensures fun h0 m h1 -> modifies (loc f) h0 h1 /\
(let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in
qas_nat h1 f == b_nat /\ (v m = ones_v U64 \/ v m = 0) /\
(v m = ones_v U64) = (0 < b_nat && b_nat < S.q))) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m | val load_qelem_check: f:qelem -> b:lbuffer uint8 32ul -> Stack uint64
(requires fun h ->
live h f /\ live h b /\ disjoint f b)
(ensures fun h0 m h1 -> modifies (loc f) h0 h1 /\
(let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in
qas_nat h1 f == b_nat /\ (v m = ones_v U64 \/ v m = 0) /\
(v m = ones_v U64) = (0 < b_nat && b_nat < S.q)))
let load_qelem_check f b = | true | null | false | push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.uint64",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.logand_lemma",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.lognot",
"Lib.IntTypes.lognot_lemma",
"Lib.IntTypes.int_t",
"Lib.IntTypes.logand",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.v",
"Prims.op_LessThan",
"Hacl.K256.Scalar.qas_nat",
"Spec.K256.PointOps.q",
"Lib.IntTypes.ones_v",
"Prims.bool",
"Hacl.Spec.Bignum.bn_lt_mask_lemma",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.K256.Scalar.qnlimb",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.bn_lt_mask",
"Prims.op_Equality",
"Hacl.K256.Scalar.is_qelem_zero",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Scalar.load_qelem",
"Hacl.K256.Scalar.make_u64_4",
"Hacl.K256.Scalar.make_order_k256",
"Hacl.K256.Scalar.create_qelem",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_qelem_check: f:qelem -> b:lbuffer uint8 32ul -> Stack uint64
(requires fun h ->
live h f /\ live h b /\ disjoint f b)
(ensures fun h0 m h1 -> modifies (loc f) h0 h1 /\
(let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in
qas_nat h1 f == b_nat /\ (v m = ones_v U64 \/ v m = 0) /\
(v m = ones_v U64) = (0 < b_nat && b_nat < S.q))) | [] | Hacl.K256.Scalar.load_qelem_check | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Scalar.qelem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64 | {
"end_col": 3,
"end_line": 155,
"start_col": 2,
"start_line": 140
} |
FStar.HyperStack.ST.Stack | val qnegate_conditional_vartime (f:qelem) (is_negate:bool) : Stack unit
(requires fun h -> live h f /\ qe_lt_q h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qe_lt_q h1 f /\
qas_nat h1 f == (if is_negate then (S.q - qas_nat h0 f) % S.q else qas_nat h0 f)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qnegate_conditional_vartime f is_negate =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let zero = create_qelem () in
if is_negate then begin
let h0 = ST.get () in
kn.BN.sub_mod_n n zero f f;
SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f);
let h1 = ST.get () in
assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q);
Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1;
assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q) end;
pop_frame () | val qnegate_conditional_vartime (f:qelem) (is_negate:bool) : Stack unit
(requires fun h -> live h f /\ qe_lt_q h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qe_lt_q h1 f /\
qas_nat h1 f == (if is_negate then (S.q - qas_nat h0 f) % S.q else qas_nat h0 f))
let qnegate_conditional_vartime f is_negate = | true | null | false | push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let zero = create_qelem () in
if is_negate
then
(let h0 = ST.get () in
kn.BN.sub_mod_n n zero f f;
SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f);
let h1 = ST.get () in
assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q);
Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1;
assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q));
pop_frame () | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Prims.bool",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Hacl.K256.Scalar.qas_nat",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Spec.K256.PointOps.q",
"FStar.Math.Lemmas.modulo_addition_lemma",
"Prims.op_Minus",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Spec.Bignum.bn_sub_mod_n_lemma",
"Lib.IntTypes.U64",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.K256.Scalar.qnlimb",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Hacl.Bignum.__proj__Mkbn__item__sub_mod_n",
"Hacl.K256.Scalar.kn",
"Hacl.K256.Scalar.create_qelem",
"Hacl.K256.Scalar.make_u64_4",
"Hacl.K256.Scalar.make_order_k256",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline]
let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame ()
val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
[@CInline]
let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c
inline_for_extraction noextract
val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
let modq_before_final t01 a out =
push_frame ();
let m = create 7ul (u64 0) in
let p = create 5ul (u64 0) in
let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in
let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in
let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in
pop_frame ();
c2
val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q)
[@CInline]
let modq out a =
push_frame ();
let r = create_qelem () in
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let t01 = sub tmp 0ul 2ul in
let h0 = ST.get () in
assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1));
let c0 = modq_before_final t01 a r in
let c1 = kn.BN.add r tmp out in
let mask = u64 0 -. (c0 +. c1) in
map2T qnlimb out (BB.mask_select mask) out r;
let h1 = ST.get () in
KL.mod_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let qmul out f1 f2 =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.mul f1 f2 tmp;
SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2);
modq out tmp;
pop_frame ()
[@CInline]
let qsqr out f =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.sqr f tmp;
SN.bn_sqr_lemma (as_seq h0 f);
modq out tmp;
pop_frame ()
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qnegate_conditional_vartime (f:qelem) (is_negate:bool) : Stack unit
(requires fun h -> live h f /\ qe_lt_q h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qe_lt_q h1 f /\
qas_nat h1 f == (if is_negate then (S.q - qas_nat h0 f) % S.q else qas_nat h0 f)) | [] | Hacl.K256.Scalar.qnegate_conditional_vartime | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Scalar.qelem -> is_negate: Prims.bool -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 357,
"start_col": 2,
"start_line": 344
} |
FStar.HyperStack.ST.Stack | val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c | val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
let mul_pow2_256_minus_q_add len resLen t01 a e res = | true | null | false | push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.K256.Scalar.bn_add",
"Lib.IntTypes.op_Plus_Bang",
"Lib.Buffer.update_sub",
"Lib.Buffer.MUT",
"Hacl.Bignum.bn_mul",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.add",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.u64",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline]
let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame ()
val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) | [] | Hacl.K256.Scalar.mul_pow2_256_minus_q_add | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_t ->
resLen:
Lib.IntTypes.size_t
{2 + Lib.IntTypes.v len <= Lib.IntTypes.v resLen /\ 4 <= Lib.IntTypes.v resLen} ->
t01: Lib.Buffer.lbuffer Lib.IntTypes.uint64 2ul ->
a: Lib.Buffer.lbuffer Lib.IntTypes.uint64 len ->
e: Lib.Buffer.lbuffer Lib.IntTypes.uint64 4ul ->
res: Lib.Buffer.lbuffer Lib.IntTypes.uint64 resLen
-> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry Lib.IntTypes.U64) | {
"end_col": 3,
"end_line": 261,
"start_col": 2,
"start_line": 254
} |
FStar.HyperStack.ST.Stack | val qmul_shift_384 (res a b: qelem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res /\
qas_nat h a < S.q /\ qas_nat h b < S.q)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
qas_nat h1 res < S.q /\
qas_nat h1 res == SG.qmul_shift_384 (qas_nat h0 a) (qas_nat h0 b)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qmul_shift_384 res a b =
push_frame ();
let h0 = ST.get () in
let l = create (2ul *! qnlimb) (u64 0) in
kn.BN.mul a b l; // l = a * b
let res_b_padded = create_qelem () in
rshift_update_sub res_b_padded l;
let _ = BN.bn_add1 qnlimb res_b_padded (u64 1) res in
let flag = l.(5ul) >>. 63ul in
let mask = u64 0 -. flag in
map2T qnlimb res (BB.mask_select mask) res res_b_padded;
let h2 = ST.get () in
assert (as_seq h2 res == Hacl.Spec.K256.Scalar.qmul_shift_384 (as_seq h0 a) (as_seq h0 b));
KL.qmul_shift_384_lemma (as_seq h0 a) (as_seq h0 b);
KL.qas_nat4_is_qas_nat (as_seq h0 a);
KL.qas_nat4_is_qas_nat (as_seq h0 b);
KL.qas_nat4_is_qas_nat (as_seq h2 res);
pop_frame () | val qmul_shift_384 (res a b: qelem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res /\
qas_nat h a < S.q /\ qas_nat h b < S.q)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
qas_nat h1 res < S.q /\
qas_nat h1 res == SG.qmul_shift_384 (qas_nat h0 a) (qas_nat h0 b))
let qmul_shift_384 res a b = | true | null | false | push_frame ();
let h0 = ST.get () in
let l = create (2ul *! qnlimb) (u64 0) in
kn.BN.mul a b l;
let res_b_padded = create_qelem () in
rshift_update_sub res_b_padded l;
let _ = BN.bn_add1 qnlimb res_b_padded (u64 1) res in
let flag = l.(5ul) >>. 63ul in
let mask = u64 0 -. flag in
map2T qnlimb res (BB.mask_select mask) res res_b_padded;
let h2 = ST.get () in
assert (as_seq h2 res == Hacl.Spec.K256.Scalar.qmul_shift_384 (as_seq h0 a) (as_seq h0 b));
KL.qmul_shift_384_lemma (as_seq h0 a) (as_seq h0 b);
KL.qas_nat4_is_qas_nat (as_seq h0 a);
KL.qas_nat4_is_qas_nat (as_seq h0 b);
KL.qas_nat4_is_qas_nat (as_seq h2 res);
pop_frame () | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Hacl.K256.Scalar.qnlimb",
"Hacl.Spec.K256.Scalar.Lemmas.qmul_shift_384_lemma",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.K256.Scalar.qmul_shift_384",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.map2T",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.U64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.op_Array_Access",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.op_Star_Bang",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.bn_add1",
"Hacl.K256.Scalar.rshift_update_sub",
"Hacl.K256.Scalar.create_qelem",
"Hacl.Bignum.__proj__Mkbn__item__mul",
"Hacl.K256.Scalar.kn",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline]
let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame ()
val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
[@CInline]
let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c
inline_for_extraction noextract
val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
let modq_before_final t01 a out =
push_frame ();
let m = create 7ul (u64 0) in
let p = create 5ul (u64 0) in
let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in
let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in
let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in
pop_frame ();
c2
val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q)
[@CInline]
let modq out a =
push_frame ();
let r = create_qelem () in
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let t01 = sub tmp 0ul 2ul in
let h0 = ST.get () in
assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1));
let c0 = modq_before_final t01 a r in
let c1 = kn.BN.add r tmp out in
let mask = u64 0 -. (c0 +. c1) in
map2T qnlimb out (BB.mask_select mask) out r;
let h1 = ST.get () in
KL.mod_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let qmul out f1 f2 =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.mul f1 f2 tmp;
SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2);
modq out tmp;
pop_frame ()
[@CInline]
let qsqr out f =
push_frame ();
let h0 = ST.get () in
let tmp = create (2ul *! qnlimb) (u64 0) in
kn.BN.sqr f tmp;
SN.bn_sqr_lemma (as_seq h0 f);
modq out tmp;
pop_frame ()
[@CInline]
let qnegate_conditional_vartime f is_negate =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let zero = create_qelem () in
if is_negate then begin
let h0 = ST.get () in
kn.BN.sub_mod_n n zero f f;
SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f);
let h1 = ST.get () in
assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q);
Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1;
assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q) end;
pop_frame ()
[@CInline]
let is_qelem_le_q_halved_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_le_q_halved_vartime4_lemma (a0,a1,a2,a3);
is_qelem_le_q_halved_vartime4 (a0,a1,a2,a3)
let is_qelem_lt_pow2_128_vartime f =
let open Lib.RawIntTypes in
let h0 = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h0 f);
let f0 = Ghost.hide (LSeq.index (as_seq h0 f) 0) in
let f1 = Ghost.hide (LSeq.index (as_seq h0 f) 1) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
KL.is_qelem_lt_pow2_128_vartime4_lemma (Ghost.reveal f0, Ghost.reveal f1,f2,f3);
u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit
(requires fun h -> live h res /\ live h l /\ disjoint res l /\
as_seq h res == LSeq.create 4 (u64 0))
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
(let res_b = SN.bn_rshift (as_seq h0 l) 6 in
let res_b_padded = LSeq.create 4 (u64 0) in
let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in
as_seq h1 res == res_b_padded))
let rshift_update_sub res l =
let h1 = ST.get () in
update_sub_f h1 res 0ul 2ul
(fun h -> SN.bn_rshift (as_seq h1 l) 6)
(fun _ -> BN.bn_rshift 8ul l 6ul (sub res 0ul 2ul))
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qmul_shift_384 (res a b: qelem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res /\
qas_nat h a < S.q /\ qas_nat h b < S.q)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
qas_nat h1 res < S.q /\
qas_nat h1 res == SG.qmul_shift_384 (qas_nat h0 a) (qas_nat h0 b)) | [] | Hacl.K256.Scalar.qmul_shift_384 | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | res: Hacl.K256.Scalar.qelem -> a: Hacl.K256.Scalar.qelem -> b: Hacl.K256.Scalar.qelem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 417,
"start_col": 2,
"start_line": 401
} |
FStar.HyperStack.ST.Stack | val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modq out a =
push_frame ();
let r = create_qelem () in
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let t01 = sub tmp 0ul 2ul in
let h0 = ST.get () in
assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1));
let c0 = modq_before_final t01 a r in
let c1 = kn.BN.add r tmp out in
let mask = u64 0 -. (c0 +. c1) in
map2T qnlimb out (BB.mask_select mask) out r;
let h1 = ST.get () in
KL.mod_lseq_lemma (as_seq h0 a);
pop_frame () | val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q)
let modq out a = | true | null | false | push_frame ();
let r = create_qelem () in
let tmp = create_qelem () in
[@@ inline_let ]let t0, t1, t2, t3 = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0, t1, t2, t3);
let t01 = sub tmp 0ul 2ul in
let h0 = ST.get () in
assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1));
let c0 = modq_before_final t01 a r in
let c1 = kn.BN.add r tmp out in
let mask = u64 0 -. (c0 +. c1) in
map2T qnlimb out (BB.mask_select mask) out r;
let h1 = ST.get () in
KL.mod_lseq_lemma (as_seq h0 a);
pop_frame () | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.K256.Scalar.qnlimb",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.K256.Scalar.Lemmas.mod_lseq_lemma",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.map2T",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.U64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.__proj__Mkbn__item__add",
"Hacl.K256.Scalar.kn",
"Hacl.K256.Scalar.modq_before_final",
"Prims._assert",
"FStar.Seq.Base.equal",
"Lib.Sequence.create2",
"Lib.Buffer.lbuffer_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Hacl.K256.Scalar.make_u64_4",
"FStar.Pervasives.Native.Mktuple4",
"Hacl.Spec.K256.Scalar.qelem4",
"Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256",
"Hacl.K256.Scalar.create_qelem",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline]
let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame ()
val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
[@CInline]
let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c
inline_for_extraction noextract
val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
let modq_before_final t01 a out =
push_frame ();
let m = create 7ul (u64 0) in
let p = create 5ul (u64 0) in
let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in
let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in
let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in
pop_frame ();
c2
val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q)
[@CInline] | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == BD.bn_v h0 a % S.q) | [] | Hacl.K256.Scalar.modq | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
out: Hacl.K256.Scalar.qelem ->
a: Lib.Buffer.lbuffer Lib.IntTypes.uint64 (2ul *! Hacl.K256.Scalar.qnlimb)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 315,
"start_col": 2,
"start_line": 297
} |
FStar.HyperStack.ST.Stack | val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Scalar",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Scalar.Lemmas",
"short_module": "KL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modq_before_final t01 a out =
push_frame ();
let m = create 7ul (u64 0) in
let p = create 5ul (u64 0) in
let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in
let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in
let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in
pop_frame ();
c2 | val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
let modq_before_final t01 a out = | true | null | false | push_frame ();
let m = create 7ul (u64 0) in
let p = create 5ul (u64 0) in
let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in
let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in
let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in
pop_frame ();
c2 | {
"checked_file": "Hacl.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Scalar.Lemmas.fst.checked",
"Hacl.Spec.K256.Scalar.fst.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Convert.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.Typeclasses.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.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.K256.Scalar.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.K256.Scalar.qnlimb",
"Hacl.K256.Scalar.qelem",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.K256.Scalar.mul_pow2_256_minus_q_add",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Lib.Buffer.create",
"Lib.IntTypes.u64",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.K256.Scalar
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module KL = Hacl.Spec.K256.Scalar.Lemmas
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
module BD = Hacl.Bignum.Definitions
module BN = Hacl.Bignum
module BB = Hacl.Bignum.Base
module SN = Hacl.Spec.Bignum
module SD = Hacl.Spec.Bignum.Definitions
include Hacl.Spec.K256.Scalar
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@CInline]
let bn_add : BN.bn_add_st U64 = BN.bn_add
//inline_for_extraction noextract
//let kn = BN.mk_runtime_bn U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
inline_for_extraction noextract
instance kn: BN.bn U64 = {
BN.len = qnlimb;
BN.add = add4;
BN.sub = sub4;
BN.add_mod_n = add_mod4;
BN.sub_mod_n = sub_mod4;
BN.mul = mul4;
BN.sqr = sqr4
}
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0;
out.(1ul) <- f1;
out.(2ul) <- f2;
out.(3ul) <- f3;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h out);
assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
let make_order_k256 () =
[@inline_let]
let r =
(u64 0xbfd25e8cd0364141,
u64 0xbaaedce6af48a03b,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (qas_nat4 r = S.q);
r
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb);
create qnlimb (u64 0)
let create_one () =
[@inline_let]
let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in
assert_norm (FStar.List.Tot.length l = 4);
Seq.elim_of_list l;
LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l);
KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0));
createL l
[@CInline]
let is_qelem_zero f =
let h0 = ST.get () in
SN.bn_is_zero_mask_lemma (as_seq h0 f);
BN.bn_is_zero_mask qnlimb f
[@CInline]
let is_qelem_zero_vartime f =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3);
is_qelem_zero_vartime4 (f0,f1,f2,f3)
[@CInline]
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f1);
KL.qas_nat4_is_qas_nat (as_seq h f2);
let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in
let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in
KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3);
is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
let load_qelem f b =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b);
Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
[@CInline]
let load_qelem_check f b =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
load_qelem f b;
let h0 = ST.get () in
let is_zero = is_qelem_zero f in
assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0));
let is_lt_q = BN.bn_lt_mask qnlimb f n in
SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n);
assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0));
let m = logand (lognot is_zero) is_lt_q in
lognot_lemma is_zero;
logand_lemma (lognot is_zero) is_lt_q;
pop_frame ();
m
let load_qelem_conditional res b =
push_frame ();
let is_b_valid = load_qelem_check res b in
let oneq = create_one () in
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
[@CInline]
let load_qelem_vartime f b =
load_qelem f b;
let h = ST.get () in
KL.qas_nat4_is_qas_nat (as_seq h f);
let is_zero = is_qelem_zero_vartime f in
let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in
let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in
KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3);
not is_zero && is_lt_q_b
val modq_short: out:qelem -> a:qelem -> Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
qas_nat h1 out == qas_nat h0 a % S.q)
[@CInline]
let modq_short out a =
push_frame ();
let tmp = create_qelem () in
[@inline_let]
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
make_u64_4 tmp (t0,t1,t2,t3);
let h0 = ST.get () in
let c = kn.BN.add a tmp out in
let mask = u64 0 -. c in
map2T qnlimb out (BB.mask_select mask) out a;
KL.mod_short_lseq_lemma (as_seq h0 a);
pop_frame ()
[@CInline]
let load_qelem_modq f b =
push_frame ();
let tmp = create_qelem () in
load_qelem f b;
copy tmp f;
modq_short f tmp;
pop_frame ()
[@CInline]
let store_qelem b f =
let h0 = ST.get () in
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f);
Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
[@CInline]
let qadd out f1 f2 =
push_frame ();
let n = create_qelem () in
make_u64_4 n (make_order_k256 ());
let h0 = ST.get () in
kn.BN.add_mod_n n f1 f2 out;
SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2);
pop_frame ()
val mul_pow2_256_minus_q_add:
len:size_t
-> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen}
-> t01:lbuffer uint64 2ul
-> a:lbuffer uint64 len
-> e:lbuffer uint64 4ul
-> res:lbuffer uint64 resLen ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h res /\ live h t01 /\ live h e /\
disjoint a res /\ disjoint a t01 /\ disjoint a e /\
disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h res == LSeq.create (v resLen) (u64 0))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) ==
mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
[@CInline]
let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame ();
let tmp = create (len +! 2ul) (u64 0) in
BN.bn_mul len 2ul a t01 tmp;
update_sub res 2ul len a;
let _ = bn_add resLen res (len +! 2ul) tmp res in
let c = bn_add resLen res 4ul e res in
pop_frame ();
c
inline_for_extraction noextract
val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) | false | false | Hacl.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modq_before_final:
t01:lbuffer uint64 2ul
-> a:lbuffer uint64 (2ul *! qnlimb)
-> out:qelem ->
Stack (BB.carry U64)
(requires fun h ->
live h a /\ live h out /\ live h t01 /\
disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\
as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\
as_seq h out == LSeq.create 4 (u64 0))
(ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\
(c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) | [] | Hacl.K256.Scalar.modq_before_final | {
"file_name": "code/k256/Hacl.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t01: Lib.Buffer.lbuffer Lib.IntTypes.uint64 2ul ->
a: Lib.Buffer.lbuffer Lib.IntTypes.uint64 (2ul *! Hacl.K256.Scalar.qnlimb) ->
out: Hacl.K256.Scalar.qelem
-> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry Lib.IntTypes.U64) | {
"end_col": 4,
"end_line": 286,
"start_col": 2,
"start_line": 279
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let prev_length_t (a: hash_alg) =
if is_keccak a then
unit
else
n:nat { n % block_length a = 0 } | let prev_length_t (a: hash_alg) = | false | null | false | if is_keccak a then unit else n: nat{n % block_length a = 0} | {
"checked_file": "Spec.Hash.Incremental.Definitions.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Incremental.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.is_keccak",
"Prims.unit",
"Prims.bool",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Spec.Hash.Definitions.block_length"
] | [] | module Spec.Hash.Incremental.Definitions
module S = FStar.Seq
module Blake2 = Spec.Blake2
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.MD
open FStar.Mul
open Lib.Sequence
open Lib.ByteSequence
open Lib.IntTypes
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
#set-options "--fuel 0 --ifuel 0 --z3rlimit 50" | false | true | Spec.Hash.Incremental.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val prev_length_t : a: Spec.Hash.Definitions.hash_alg -> Type0 | [] | Spec.Hash.Incremental.Definitions.prev_length_t | {
"file_name": "specs/lemmas/Spec.Hash.Incremental.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> Type0 | {
"end_col": 36,
"end_line": 24,
"start_col": 2,
"start_line": 21
} |
|
Prims.Pure | val split_blocks (a: hash_alg) (input: bytes)
: Pure (bytes & bytes)
(requires (S.length input) `less_than_max_input_length` a)
(ensures
fun (bs, l) ->
S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input
) | [
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let split_blocks (a:hash_alg) (input:bytes)
: Pure (bytes & bytes)
(requires S.length input `less_than_max_input_length` a)
(ensures fun (bs, l) ->
S.length bs % block_length a = 0 /\
S.length l <= block_length a /\
S.append bs l == input) =
UpdateMulti.split_at_last_lazy (block_length a) input | val split_blocks (a: hash_alg) (input: bytes)
: Pure (bytes & bytes)
(requires (S.length input) `less_than_max_input_length` a)
(ensures
fun (bs, l) ->
S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input
)
let split_blocks (a: hash_alg) (input: bytes)
: Pure (bytes & bytes)
(requires (S.length input) `less_than_max_input_length` a)
(ensures
fun (bs, l) ->
S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input
) = | false | null | false | UpdateMulti.split_at_last_lazy (block_length a) input | {
"checked_file": "Spec.Hash.Incremental.Definitions.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Incremental.Definitions.fst"
} | [] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.ByteSequence.bytes",
"Lib.UpdateMulti.split_at_last_lazy",
"Spec.Hash.Definitions.block_length",
"FStar.Pervasives.Native.tuple2",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_and",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_LessThanOrEqual",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.append"
] | [] | module Spec.Hash.Incremental.Definitions
module S = FStar.Seq
module Blake2 = Spec.Blake2
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.MD
open FStar.Mul
open Lib.Sequence
open Lib.ByteSequence
open Lib.IntTypes
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
#set-options "--fuel 0 --ifuel 0 --z3rlimit 50"
let prev_length_t (a: hash_alg) =
if is_keccak a then
unit
else
n:nat { n % block_length a = 0 }
(* An incremental specification better suited to a stateful API, allowing the
client to perform the padding at the last minute upon hitting the last chunk of
data. *)
let update_last (a:hash_alg)
(hash:words_state a)
(prevlen:prev_length_t a)
(input:bytes{ (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\
S.length input <= block_length a }):
Tot (words_state a)
=
if is_blake a then
Spec.Blake2.blake2_update_last (to_blake_alg a) prevlen (S.length input) input hash
else if is_keccak a then
// VERY UNPLEASANT! Because of the lazy split for Blake2 we need to unroll...
let rateInBytes = rate a / 8 in
let delimitedSuffix = if is_shake a then byte 0x1f else byte 0x06 in
let s = hash in
let l = S.length input in
if l = block_length a then
let s = Spec.SHA3.absorb_inner rateInBytes input s in
Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s
else
Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length input) input s
else
let total_len = prevlen + S.length input in
let padding = pad a total_len in
(**) Math.Lemmas.lemma_mod_add_distr (S.length input + S.length padding) prevlen (block_length a);
(**) assert(S.length S.(input @| padding) % block_length a = 0);
update_multi a hash () S.(input @| padding)
let split_blocks (a:hash_alg) (input:bytes)
: Pure (bytes & bytes)
(requires S.length input `less_than_max_input_length` a)
(ensures fun (bs, l) ->
S.length bs % block_length a = 0 /\
S.length l <= block_length a /\ | false | false | Spec.Hash.Incremental.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val split_blocks (a: hash_alg) (input: bytes)
: Pure (bytes & bytes)
(requires (S.length input) `less_than_max_input_length` a)
(ensures
fun (bs, l) ->
S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input
) | [] | Spec.Hash.Incremental.Definitions.split_blocks | {
"file_name": "specs/lemmas/Spec.Hash.Incremental.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Hash.Definitions.hash_alg -> input: Lib.ByteSequence.bytes
-> Prims.Pure (Lib.ByteSequence.bytes * Lib.ByteSequence.bytes) | {
"end_col": 55,
"end_line": 63,
"start_col": 2,
"start_line": 63
} |
Prims.Tot | val hash_incremental
(a: hash_alg)
(input: bytes{(S.length input) `less_than_max_input_length` a})
(out_length: output_length a)
: Tot (hash: bytes{S.length hash = (hash_length' a out_length)}) | [
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_incremental (a:hash_alg) (input:bytes{S.length input `less_than_max_input_length` a})
(out_length: output_length a):
Tot (hash:bytes{S.length hash = (hash_length' a out_length)})
=
let s = init a in
let bs, l = split_blocks a input in
let s = update_multi a s (init_extra_state a) bs in
let s = update_last a s (if is_keccak a then () else S.length bs) l in
finish a s out_length | val hash_incremental
(a: hash_alg)
(input: bytes{(S.length input) `less_than_max_input_length` a})
(out_length: output_length a)
: Tot (hash: bytes{S.length hash = (hash_length' a out_length)})
let hash_incremental
(a: hash_alg)
(input: bytes{(S.length input) `less_than_max_input_length` a})
(out_length: output_length a)
: Tot (hash: bytes{S.length hash = (hash_length' a out_length)}) = | false | null | false | let s = init a in
let bs, l = split_blocks a input in
let s = update_multi a s (init_extra_state a) bs in
let s = update_last a s (if is_keccak a then () else S.length bs) l in
finish a s out_length | {
"checked_file": "Spec.Hash.Incremental.Definitions.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Incremental.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Hash.Definitions.output_length",
"Spec.Agile.Hash.finish",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Incremental.Definitions.update_last",
"Spec.Hash.Definitions.is_keccak",
"Prims.bool",
"Spec.Hash.Incremental.Definitions.prev_length_t",
"Spec.Agile.Hash.update_multi",
"Spec.Agile.Hash.init_extra_state",
"Prims.op_Equality",
"Prims.nat",
"Spec.Hash.Definitions.hash_length'",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.seq",
"Lib.IntTypes.int_t",
"Spec.Hash.Incremental.Definitions.split_blocks",
"Spec.Hash.Definitions.init_t",
"Spec.Agile.Hash.init"
] | [] | module Spec.Hash.Incremental.Definitions
module S = FStar.Seq
module Blake2 = Spec.Blake2
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.MD
open FStar.Mul
open Lib.Sequence
open Lib.ByteSequence
open Lib.IntTypes
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
#set-options "--fuel 0 --ifuel 0 --z3rlimit 50"
let prev_length_t (a: hash_alg) =
if is_keccak a then
unit
else
n:nat { n % block_length a = 0 }
(* An incremental specification better suited to a stateful API, allowing the
client to perform the padding at the last minute upon hitting the last chunk of
data. *)
let update_last (a:hash_alg)
(hash:words_state a)
(prevlen:prev_length_t a)
(input:bytes{ (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\
S.length input <= block_length a }):
Tot (words_state a)
=
if is_blake a then
Spec.Blake2.blake2_update_last (to_blake_alg a) prevlen (S.length input) input hash
else if is_keccak a then
// VERY UNPLEASANT! Because of the lazy split for Blake2 we need to unroll...
let rateInBytes = rate a / 8 in
let delimitedSuffix = if is_shake a then byte 0x1f else byte 0x06 in
let s = hash in
let l = S.length input in
if l = block_length a then
let s = Spec.SHA3.absorb_inner rateInBytes input s in
Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s
else
Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length input) input s
else
let total_len = prevlen + S.length input in
let padding = pad a total_len in
(**) Math.Lemmas.lemma_mod_add_distr (S.length input + S.length padding) prevlen (block_length a);
(**) assert(S.length S.(input @| padding) % block_length a = 0);
update_multi a hash () S.(input @| padding)
let split_blocks (a:hash_alg) (input:bytes)
: Pure (bytes & bytes)
(requires S.length input `less_than_max_input_length` a)
(ensures fun (bs, l) ->
S.length bs % block_length a = 0 /\
S.length l <= block_length a /\
S.append bs l == input) =
UpdateMulti.split_at_last_lazy (block_length a) input
let hash_incremental (a:hash_alg) (input:bytes{S.length input `less_than_max_input_length` a})
(out_length: output_length a): | false | false | Spec.Hash.Incremental.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_incremental
(a: hash_alg)
(input: bytes{(S.length input) `less_than_max_input_length` a})
(out_length: output_length a)
: Tot (hash: bytes{S.length hash = (hash_length' a out_length)}) | [] | Spec.Hash.Incremental.Definitions.hash_incremental | {
"file_name": "specs/lemmas/Spec.Hash.Incremental.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg ->
input:
Lib.ByteSequence.bytes
{Spec.Hash.Definitions.less_than_max_input_length (FStar.Seq.Base.length input) a} ->
out_length: Spec.Hash.Definitions.output_length a
-> hash:
Lib.ByteSequence.bytes
{FStar.Seq.Base.length hash = Spec.Hash.Definitions.hash_length' a out_length} | {
"end_col": 23,
"end_line": 73,
"start_col": 1,
"start_line": 68
} |
Prims.Tot | val update_last
(a: hash_alg)
(hash: words_state a)
(prevlen: prev_length_t a)
(input:
bytes
{ (if is_keccak a
then True
else (S.length input + prevlen) `less_than_max_input_length` a) /\
S.length input <= block_length a })
: Tot (words_state a) | [
{
"abbrev": true,
"full_module": "Lib.UpdateMulti",
"short_module": "UpdateMulti"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Blake2"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_last (a:hash_alg)
(hash:words_state a)
(prevlen:prev_length_t a)
(input:bytes{ (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\
S.length input <= block_length a }):
Tot (words_state a)
=
if is_blake a then
Spec.Blake2.blake2_update_last (to_blake_alg a) prevlen (S.length input) input hash
else if is_keccak a then
// VERY UNPLEASANT! Because of the lazy split for Blake2 we need to unroll...
let rateInBytes = rate a / 8 in
let delimitedSuffix = if is_shake a then byte 0x1f else byte 0x06 in
let s = hash in
let l = S.length input in
if l = block_length a then
let s = Spec.SHA3.absorb_inner rateInBytes input s in
Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s
else
Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length input) input s
else
let total_len = prevlen + S.length input in
let padding = pad a total_len in
(**) Math.Lemmas.lemma_mod_add_distr (S.length input + S.length padding) prevlen (block_length a);
(**) assert(S.length S.(input @| padding) % block_length a = 0);
update_multi a hash () S.(input @| padding) | val update_last
(a: hash_alg)
(hash: words_state a)
(prevlen: prev_length_t a)
(input:
bytes
{ (if is_keccak a
then True
else (S.length input + prevlen) `less_than_max_input_length` a) /\
S.length input <= block_length a })
: Tot (words_state a)
let update_last
(a: hash_alg)
(hash: words_state a)
(prevlen: prev_length_t a)
(input:
bytes
{ (if is_keccak a
then True
else (S.length input + prevlen) `less_than_max_input_length` a) /\
S.length input <= block_length a })
: Tot (words_state a) = | false | null | false | if is_blake a
then Spec.Blake2.blake2_update_last (to_blake_alg a) prevlen (S.length input) input hash
else
if is_keccak a
then
let rateInBytes = rate a / 8 in
let delimitedSuffix = if is_shake a then byte 0x1f else byte 0x06 in
let s = hash in
let l = S.length input in
if l = block_length a
then
let s = Spec.SHA3.absorb_inner rateInBytes input s in
Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s
else Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length input) input s
else
let total_len = prevlen + S.length input in
let padding = pad a total_len in
Math.Lemmas.lemma_mod_add_distr (S.length input + S.length padding) prevlen (block_length a);
assert (S.length S.(input @| padding) % block_length a = 0);
update_multi a hash () S.(input @| padding) | {
"checked_file": "Spec.Hash.Incremental.Definitions.fst.checked",
"dependencies": [
"Spec.SHA3.fst.checked",
"Spec.Hash.MD.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Blake2.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Hash.Incremental.Definitions.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Incremental.Definitions.prev_length_t",
"Lib.ByteSequence.bytes",
"Prims.l_and",
"Spec.Hash.Definitions.is_keccak",
"Prims.l_True",
"Prims.bool",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.logical",
"Prims.op_LessThanOrEqual",
"Spec.Hash.Definitions.block_length",
"Spec.Hash.Definitions.is_blake",
"Spec.Blake2.blake2_update_last",
"Spec.Hash.Definitions.to_blake_alg",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"Spec.SHA3.absorb_last",
"FStar.Seq.Base.empty",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Spec.SHA3.absorb_inner",
"Prims.nat",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.is_shake",
"Lib.IntTypes.byte",
"Lib.IntTypes.byte_t",
"Prims.op_Division",
"Spec.Hash.Definitions.rate",
"Spec.Agile.Hash.update_multi",
"FStar.Seq.Base.op_At_Bar",
"Prims.unit",
"Prims._assert",
"Prims.op_Modulus",
"FStar.Math.Lemmas.lemma_mod_add_distr",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.bytes",
"Spec.Hash.MD.pad"
] | [] | module Spec.Hash.Incremental.Definitions
module S = FStar.Seq
module Blake2 = Spec.Blake2
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.MD
open FStar.Mul
open Lib.Sequence
open Lib.ByteSequence
open Lib.IntTypes
module Loops = Lib.LoopCombinators
module UpdateMulti = Lib.UpdateMulti
#set-options "--fuel 0 --ifuel 0 --z3rlimit 50"
let prev_length_t (a: hash_alg) =
if is_keccak a then
unit
else
n:nat { n % block_length a = 0 }
(* An incremental specification better suited to a stateful API, allowing the
client to perform the padding at the last minute upon hitting the last chunk of
data. *)
let update_last (a:hash_alg)
(hash:words_state a)
(prevlen:prev_length_t a)
(input:bytes{ (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\
S.length input <= block_length a }):
Tot (words_state a) | false | false | Spec.Hash.Incremental.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_last
(a: hash_alg)
(hash: words_state a)
(prevlen: prev_length_t a)
(input:
bytes
{ (if is_keccak a
then True
else (S.length input + prevlen) `less_than_max_input_length` a) /\
S.length input <= block_length a })
: Tot (words_state a) | [] | Spec.Hash.Incremental.Definitions.update_last | {
"file_name": "specs/lemmas/Spec.Hash.Incremental.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg ->
hash: Spec.Hash.Definitions.words_state a ->
prevlen: Spec.Hash.Incremental.Definitions.prev_length_t a ->
input:
Lib.ByteSequence.bytes
{ (match Spec.Hash.Definitions.is_keccak a with
| true -> Prims.l_True
| _ ->
Spec.Hash.Definitions.less_than_max_input_length (FStar.Seq.Base.length input +
prevlen)
a) /\ FStar.Seq.Base.length input <= Spec.Hash.Definitions.block_length a }
-> Spec.Hash.Definitions.words_state a | {
"end_col": 47,
"end_line": 54,
"start_col": 2,
"start_line": 36
} |
FStar.Pervasives.Lemma | val split_at_last_lazy_spec (l : pos)
(b blocks rest: S.seq uint8) :
Lemma
(requires (
S.length blocks % l = 0 /\
S.length rest <= l /\
(S.length rest = 0 ==> S.length b = 0) /\
b `Seq.equal` Seq.append blocks rest))
(ensures (
(blocks, rest) == split_at_last_lazy l b)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let split_at_last_lazy_spec (l : pos)
(b blocks rest: S.seq uint8):
Lemma
(requires (
S.length blocks % l = 0 /\
S.length rest <= l /\
(S.length rest = 0 ==> S.length b = 0) /\
b `Seq.equal` Seq.append blocks rest))
(ensures (
(blocks, rest) == split_at_last_lazy l b)) =
(* We need to introduce the variables with which to call [split_at_last_lazy_nb_rem_spec] *)
let b_l = Seq.length b in
let blocks_l = Seq.length blocks in
let rest_l = Seq.length rest in
let blocks', rest' = split_at_last_lazy l b in
let n' = Seq.length blocks' / l in
let n = blocks_l / l in
Math.Lemmas.nat_over_pos_is_nat blocks_l l;
assert(n >= 0);
Math.Lemmas.euclidean_division_definition (S.length blocks) l;
split_at_last_lazy_nb_rem_spec l b_l n rest_l;
assert(((n <: nat), rest_l) = split_at_last_lazy_nb_rem l b_l);
assert(n = n'); (* comes from the spec of [split_at_last_lazy] *)
assert(rest_l = Seq.length rest');
(* We have the equalities between the sequence lengths, so the rest follows
* naturally *)
assert(blocks `Seq.equal` blocks');
assert(rest `Seq.equal` rest') | val split_at_last_lazy_spec (l : pos)
(b blocks rest: S.seq uint8) :
Lemma
(requires (
S.length blocks % l = 0 /\
S.length rest <= l /\
(S.length rest = 0 ==> S.length b = 0) /\
b `Seq.equal` Seq.append blocks rest))
(ensures (
(blocks, rest) == split_at_last_lazy l b))
let split_at_last_lazy_spec (l: pos) (b blocks rest: S.seq uint8)
: Lemma
(requires
(S.length blocks % l = 0 /\ S.length rest <= l /\ (S.length rest = 0 ==> S.length b = 0) /\
b `Seq.equal` (Seq.append blocks rest)))
(ensures ((blocks, rest) == split_at_last_lazy l b)) = | false | null | true | let b_l = Seq.length b in
let blocks_l = Seq.length blocks in
let rest_l = Seq.length rest in
let blocks', rest' = split_at_last_lazy l b in
let n' = Seq.length blocks' / l in
let n = blocks_l / l in
Math.Lemmas.nat_over_pos_is_nat blocks_l l;
assert (n >= 0);
Math.Lemmas.euclidean_division_definition (S.length blocks) l;
split_at_last_lazy_nb_rem_spec l b_l n rest_l;
assert (((n <: nat), rest_l) = split_at_last_lazy_nb_rem l b_l);
assert (n = n');
assert (rest_l = Seq.length rest');
assert (blocks `Seq.equal` blocks');
assert (rest `Seq.equal` rest') | {
"checked_file": "Lib.UpdateMulti.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.UpdateMulti.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.pos",
"FStar.Seq.Base.seq",
"Lib.UpdateMulti.Lemmas.uint8",
"Lib.UpdateMulti.uint8",
"Prims._assert",
"FStar.Seq.Base.equal",
"Prims.unit",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"Prims.int",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Lib.UpdateMulti.split_at_last_lazy_nb_rem",
"Lib.UpdateMulti.Lemmas.split_at_last_lazy_nb_rem_spec",
"FStar.Math.Lemmas.euclidean_division_definition",
"Prims.op_GreaterThanOrEqual",
"FStar.Math.Lemmas.nat_over_pos_is_nat",
"Prims.op_Division",
"Lib.UpdateMulti.split_at_last_lazy",
"Prims.l_and",
"Prims.op_Modulus",
"Prims.op_LessThanOrEqual",
"Prims.l_imp",
"FStar.Seq.Base.append",
"Prims.squash",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Lib.UpdateMulti.Lemmas
/// This first auxiliary lemma only manipulates the lengths of the sequences.
#push-options "--z3cliopt smt.arith.nl=false"
let split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) :
Lemma
(requires (
rest <= l /\
(rest = 0 ==> d = 0) /\
d = n * l + rest))
(ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) =
(* We call ``split_at_last_lazy_nb_rem`` at the beginning to have its
* postcondition in the context (the return values are only used in the second
* branch *)
let n', rest' = split_at_last_lazy_nb_rem l d in
if d = 0 then
begin
Math.Lemmas.nat_times_nat_is_nat n l;
Math.Lemmas.int_times_int_equal_zero_lemma n l;
assert(n = 0)
end
else
begin
assert(d > 0);
(* In order to prove the equality between all the lengths, we use the unicity
* of the modulo to prove that the rests are equal, then that the numbers
* of blocks are equal. *)
let blocks = n * l in
let rest = d - blocks in
let blocks' = n' * l in
Math.Lemmas.cancel_mul_mod n l;
assert(blocks % l = 0);
assert(blocks' % l = 0); (* comes from the spec of [split_at_last_lazy_nb_rem] *)
Math.Lemmas.euclidean_division_definition blocks l;
(* First, prove that the lengths of the rests are equal modulo the size of
* a block *)
assert(rest' % l = d % l); (* comes from the spec of [split_at_last] *)
assert(rest + n * l = d);
Math.Lemmas.lemma_mod_plus rest n l; (* doesn't work inside a calc: typing problem with squash *)
assert(d % l = rest % l);
assert(rest % l = rest' % l);
(* If both rests are stricly smaller than a block, we can directly apply
* the modulo injectivity and the rest follows immediately *)
if rest < l && rest' < l then
begin
Math.Lemmas.lemma_mod_injective l rest rest';
assert(rest = rest');
assert(n * l + rest = n' * l + rest');
assert(n * l = n' * l);
Math.Lemmas.lemma_cancel_mul n n' l;
assert(n = n')
end
(* Otherwise, case one: both rests are equal to block length (even easier) *)
else if rest = l && rest' = l then
Math.Lemmas.lemma_cancel_mul n n' l
(* Last two cases: one of the rests is smaller than a block, and the other is
* of the size of a block. Because of modulo properties, the smaller rest
* must be equal to 0, which gives us that the data is actually of length 0:
* contradiction. *)
else
begin
assert((rest = l && rest' < l) \/ (rest < l && rest' = l));
let rest, rest' = if rest = l then rest, rest' else rest', rest in
assert(rest = l && rest' < l);
(* [rest % l = 0] *)
assert(rest = 1 * l);
Math.Lemmas.cancel_mul_mod 1 l;
assert(rest % l = 0);
(* [rest' = 0 ] *)
Math.Lemmas.modulo_lemma rest' l;
assert(rest' = 0);
(* By the current hypotheses, if rest' = 0 then d = 0 (contradiction) *)
assert(False)
end
end
#pop-options
/// This second lemma characterizes the sequences themselves.
/// The proof strategy is to first prove that the blocks and rest sequences have
/// the expected lengths, and the equality between the sequences is then trivial
/// to get.
#push-options "--z3cliopt smt.arith.nl=false"
let split_at_last_lazy_spec (l : pos)
(b blocks rest: S.seq uint8):
Lemma
(requires (
S.length blocks % l = 0 /\
S.length rest <= l /\
(S.length rest = 0 ==> S.length b = 0) /\
b `Seq.equal` Seq.append blocks rest)) | false | false | Lib.UpdateMulti.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val split_at_last_lazy_spec (l : pos)
(b blocks rest: S.seq uint8) :
Lemma
(requires (
S.length blocks % l = 0 /\
S.length rest <= l /\
(S.length rest = 0 ==> S.length b = 0) /\
b `Seq.equal` Seq.append blocks rest))
(ensures (
(blocks, rest) == split_at_last_lazy l b)) | [] | Lib.UpdateMulti.Lemmas.split_at_last_lazy_spec | {
"file_name": "lib/Lib.UpdateMulti.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
l: Prims.pos ->
b: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8 ->
blocks: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8 ->
rest: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length blocks % l = 0 /\ FStar.Seq.Base.length rest <= l /\
(FStar.Seq.Base.length rest = 0 ==> FStar.Seq.Base.length b = 0) /\
FStar.Seq.Base.equal b (FStar.Seq.Base.append blocks rest))
(ensures
FStar.Pervasives.Native.Mktuple2 blocks rest == Lib.UpdateMulti.split_at_last_lazy l b) | {
"end_col": 32,
"end_line": 112,
"start_col": 49,
"start_line": 94
} |
FStar.Pervasives.Lemma | val split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) :
Lemma
(requires (
rest <= l /\
(rest = 0 ==> d = 0) /\
d = n * l + rest))
(ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) :
Lemma
(requires (
rest <= l /\
(rest = 0 ==> d = 0) /\
d = n * l + rest))
(ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) =
(* We call ``split_at_last_lazy_nb_rem`` at the beginning to have its
* postcondition in the context (the return values are only used in the second
* branch *)
let n', rest' = split_at_last_lazy_nb_rem l d in
if d = 0 then
begin
Math.Lemmas.nat_times_nat_is_nat n l;
Math.Lemmas.int_times_int_equal_zero_lemma n l;
assert(n = 0)
end
else
begin
assert(d > 0);
(* In order to prove the equality between all the lengths, we use the unicity
* of the modulo to prove that the rests are equal, then that the numbers
* of blocks are equal. *)
let blocks = n * l in
let rest = d - blocks in
let blocks' = n' * l in
Math.Lemmas.cancel_mul_mod n l;
assert(blocks % l = 0);
assert(blocks' % l = 0); (* comes from the spec of [split_at_last_lazy_nb_rem] *)
Math.Lemmas.euclidean_division_definition blocks l;
(* First, prove that the lengths of the rests are equal modulo the size of
* a block *)
assert(rest' % l = d % l); (* comes from the spec of [split_at_last] *)
assert(rest + n * l = d);
Math.Lemmas.lemma_mod_plus rest n l; (* doesn't work inside a calc: typing problem with squash *)
assert(d % l = rest % l);
assert(rest % l = rest' % l);
(* If both rests are stricly smaller than a block, we can directly apply
* the modulo injectivity and the rest follows immediately *)
if rest < l && rest' < l then
begin
Math.Lemmas.lemma_mod_injective l rest rest';
assert(rest = rest');
assert(n * l + rest = n' * l + rest');
assert(n * l = n' * l);
Math.Lemmas.lemma_cancel_mul n n' l;
assert(n = n')
end
(* Otherwise, case one: both rests are equal to block length (even easier) *)
else if rest = l && rest' = l then
Math.Lemmas.lemma_cancel_mul n n' l
(* Last two cases: one of the rests is smaller than a block, and the other is
* of the size of a block. Because of modulo properties, the smaller rest
* must be equal to 0, which gives us that the data is actually of length 0:
* contradiction. *)
else
begin
assert((rest = l && rest' < l) \/ (rest < l && rest' = l));
let rest, rest' = if rest = l then rest, rest' else rest', rest in
assert(rest = l && rest' < l);
(* [rest % l = 0] *)
assert(rest = 1 * l);
Math.Lemmas.cancel_mul_mod 1 l;
assert(rest % l = 0);
(* [rest' = 0 ] *)
Math.Lemmas.modulo_lemma rest' l;
assert(rest' = 0);
(* By the current hypotheses, if rest' = 0 then d = 0 (contradiction) *)
assert(False)
end
end | val split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) :
Lemma
(requires (
rest <= l /\
(rest = 0 ==> d = 0) /\
d = n * l + rest))
(ensures ((n, rest) = split_at_last_lazy_nb_rem l d))
let split_at_last_lazy_nb_rem_spec (l: pos) (d n rest: nat)
: Lemma (requires (rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest))
(ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) = | false | null | true | let n', rest' = split_at_last_lazy_nb_rem l d in
if d = 0
then
(Math.Lemmas.nat_times_nat_is_nat n l;
Math.Lemmas.int_times_int_equal_zero_lemma n l;
assert (n = 0))
else
(assert (d > 0);
let blocks = n * l in
let rest = d - blocks in
let blocks' = n' * l in
Math.Lemmas.cancel_mul_mod n l;
assert (blocks % l = 0);
assert (blocks' % l = 0);
Math.Lemmas.euclidean_division_definition blocks l;
assert (rest' % l = d % l);
assert (rest + n * l = d);
Math.Lemmas.lemma_mod_plus rest n l;
assert (d % l = rest % l);
assert (rest % l = rest' % l);
if rest < l && rest' < l
then
(Math.Lemmas.lemma_mod_injective l rest rest';
assert (rest = rest');
assert (n * l + rest = n' * l + rest');
assert (n * l = n' * l);
Math.Lemmas.lemma_cancel_mul n n' l;
assert (n = n'))
else
if rest = l && rest' = l
then Math.Lemmas.lemma_cancel_mul n n' l
else
(assert ((rest = l && rest' < l) \/ (rest < l && rest' = l));
let rest, rest' = if rest = l then rest, rest' else rest', rest in
assert (rest = l && rest' < l);
assert (rest = 1 * l);
Math.Lemmas.cancel_mul_mod 1 l;
assert (rest % l = 0);
Math.Lemmas.modulo_lemma rest' l;
assert (rest' = 0);
assert (False))) | {
"checked_file": "Lib.UpdateMulti.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.UpdateMulti.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.pos",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims._assert",
"Prims.b2t",
"Prims.unit",
"FStar.Math.Lemmas.int_times_int_equal_zero_lemma",
"FStar.Math.Lemmas.nat_times_nat_is_nat",
"Prims.bool",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"FStar.Math.Lemmas.lemma_cancel_mul",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"FStar.Math.Lemmas.lemma_mod_injective",
"Prims.l_or",
"Prims.op_GreaterThan",
"Prims.op_GreaterThanOrEqual",
"Prims.l_False",
"FStar.Math.Lemmas.modulo_lemma",
"Prims.op_Modulus",
"FStar.Math.Lemmas.cancel_mul_mod",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Math.Lemmas.lemma_mod_plus",
"FStar.Math.Lemmas.euclidean_division_definition",
"Prims.op_Subtraction",
"Lib.UpdateMulti.split_at_last_lazy_nb_rem",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.l_imp",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Lib.UpdateMulti.Lemmas
/// This first auxiliary lemma only manipulates the lengths of the sequences.
#push-options "--z3cliopt smt.arith.nl=false"
let split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) :
Lemma
(requires (
rest <= l /\
(rest = 0 ==> d = 0) /\ | false | false | Lib.UpdateMulti.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) :
Lemma
(requires (
rest <= l /\
(rest = 0 ==> d = 0) /\
d = n * l + rest))
(ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) | [] | Lib.UpdateMulti.Lemmas.split_at_last_lazy_nb_rem_spec | {
"file_name": "lib/Lib.UpdateMulti.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Prims.pos -> d: Prims.nat -> n: Prims.nat -> rest: Prims.nat
-> FStar.Pervasives.Lemma (requires rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest)
(ensures
FStar.Pervasives.Native.Mktuple2 n rest = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d) | {
"end_col": 8,
"end_line": 77,
"start_col": 57,
"start_line": 11
} |
FStar.Pervasives.Lemma | val update_multi_is_repeat_blocks_multi:
#a:Type0 ->
block_length:pos{ block_length < pow2 32 } ->
update: (a -> s:S.seq uint8 { S.length s = block_length } -> a) ->
acc:a ->
input:S.seq uint8 ->
Lemma
(requires (S.length input % block_length == 0))
(ensures (
let repeat_f = repeat_f block_length update in
Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc ==
Lib.UpdateMulti.mk_update_multi block_length update acc input))
(decreases (S.length input)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec update_multi_is_repeat_blocks_multi #a block_length update acc input =
// Lib.UpdateMulti side
let n_blocks = S.length input / block_length in
// triggers!
let blocks, rest = S.split input (n_blocks * block_length) in
FStar.Math.Lemmas.nat_over_pos_is_nat (S.length input) block_length;
// Lib.Sequence side
let repeat_f = repeat_f block_length update in
let repeat_blocks_f = Lib.Sequence.repeat_blocks_f in
if S.length input = 0 then begin
Lib.Sequence.lemma_repeat_blocks_multi block_length input repeat_f acc;
Lib.LoopCombinators.eq_repeati0 n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc;
Lib.UpdateMulti.update_multi_zero block_length update acc
end else
let split_index = S.length input - block_length in
FStar.Math.Lemmas.modulo_lemma 0 block_length;
FStar.Math.Lemmas.lemma_mod_plus (S.length input) (-1) block_length;
Lib.Sequence.Lemmas.repeat_blocks_multi_split block_length split_index input repeat_f acc;
let acc0 = Lib.UpdateMulti.mk_update_multi block_length update acc (S.slice input 0 split_index) in
let f = repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1 in
calc (==) {
Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc;
(==) { Lib.Sequence.Lemmas.repeat_blocks_multi_split block_length split_index input repeat_f acc }
Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input split_index (S.length input)) repeat_f
(Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input 0 split_index) repeat_f acc);
(==) { update_multi_is_repeat_blocks_multi block_length update acc (S.slice input 0 split_index) }
Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input split_index (S.length input)) repeat_f
acc0;
(==) { Lib.Sequence.lemma_repeat_blocks_multi block_length (S.slice input split_index (S.length input)) repeat_f
acc0
}
Lib.LoopCombinators.repeati 1 (repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1) acc0;
(==) { Lib.LoopCombinators.unfold_repeati 1
(repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1)
acc0
0
}
f 0 (Lib.LoopCombinators.repeati 0 f acc0);
(==) { Lib.LoopCombinators.eq_repeati0 0 f acc0 }
f 0 acc0;
(==) { }
update acc0 (S.slice input split_index (S.length input));
(==) { update_multi_one block_length update acc0 (S.slice input split_index (S.length input)) }
Lib.UpdateMulti.mk_update_multi block_length update acc0 (S.slice input split_index (S.length input));
(==) { Lib.UpdateMulti.update_multi_associative block_length update acc
(S.slice input 0 split_index) (S.slice input split_index (S.length input)) }
Lib.UpdateMulti.mk_update_multi block_length update acc (S.append
(S.slice input 0 split_index) (S.slice input split_index (S.length input)));
(==) { assert (
(S.append (S.slice input 0 split_index) (S.slice input split_index (S.length input))) `S.equal`
input) }
Lib.UpdateMulti.mk_update_multi block_length update acc input;
} | val update_multi_is_repeat_blocks_multi:
#a:Type0 ->
block_length:pos{ block_length < pow2 32 } ->
update: (a -> s:S.seq uint8 { S.length s = block_length } -> a) ->
acc:a ->
input:S.seq uint8 ->
Lemma
(requires (S.length input % block_length == 0))
(ensures (
let repeat_f = repeat_f block_length update in
Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc ==
Lib.UpdateMulti.mk_update_multi block_length update acc input))
(decreases (S.length input))
let rec update_multi_is_repeat_blocks_multi #a block_length update acc input = | false | null | true | let n_blocks = S.length input / block_length in
let blocks, rest = S.split input (n_blocks * block_length) in
FStar.Math.Lemmas.nat_over_pos_is_nat (S.length input) block_length;
let repeat_f = repeat_f block_length update in
let repeat_blocks_f = Lib.Sequence.repeat_blocks_f in
if S.length input = 0
then
(Lib.Sequence.lemma_repeat_blocks_multi block_length input repeat_f acc;
Lib.LoopCombinators.eq_repeati0 n_blocks
(Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks)
acc;
Lib.UpdateMulti.update_multi_zero block_length update acc)
else
let split_index = S.length input - block_length in
FStar.Math.Lemmas.modulo_lemma 0 block_length;
FStar.Math.Lemmas.lemma_mod_plus (S.length input) (- 1) block_length;
Lib.Sequence.Lemmas.repeat_blocks_multi_split block_length split_index input repeat_f acc;
let acc0 =
Lib.UpdateMulti.mk_update_multi block_length update acc (S.slice input 0 split_index)
in
let f = repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1 in
calc ( == ) {
Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc;
( == ) { Lib.Sequence.Lemmas.repeat_blocks_multi_split block_length
split_index
input
repeat_f
acc }
Lib.Sequence.repeat_blocks_multi #uint8
block_length
(S.slice input split_index (S.length input))
repeat_f
(Lib.Sequence.repeat_blocks_multi #uint8
block_length
(S.slice input 0 split_index)
repeat_f
acc);
( == ) { update_multi_is_repeat_blocks_multi block_length
update
acc
(S.slice input 0 split_index) }
Lib.Sequence.repeat_blocks_multi #uint8
block_length
(S.slice input split_index (S.length input))
repeat_f
acc0;
( == ) { Lib.Sequence.lemma_repeat_blocks_multi block_length
(S.slice input split_index (S.length input))
repeat_f
acc0 }
Lib.LoopCombinators.repeati 1
(repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1)
acc0;
( == ) { Lib.LoopCombinators.unfold_repeati 1
(repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1)
acc0
0 }
f 0 (Lib.LoopCombinators.repeati 0 f acc0);
( == ) { Lib.LoopCombinators.eq_repeati0 0 f acc0 }
f 0 acc0;
( == ) { () }
update acc0 (S.slice input split_index (S.length input));
( == ) { update_multi_one block_length update acc0 (S.slice input split_index (S.length input)) }
Lib.UpdateMulti.mk_update_multi block_length
update
acc0
(S.slice input split_index (S.length input));
( == ) { Lib.UpdateMulti.update_multi_associative block_length
update
acc
(S.slice input 0 split_index)
(S.slice input split_index (S.length input)) }
Lib.UpdateMulti.mk_update_multi block_length
update
acc
(S.append (S.slice input 0 split_index) (S.slice input split_index (S.length input)));
( == ) { assert ((S.append (S.slice input 0 split_index)
(S.slice input split_index (S.length input)))
`S.equal`
input) }
Lib.UpdateMulti.mk_update_multi block_length update acc input;
} | {
"checked_file": "Lib.UpdateMulti.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.UpdateMulti.Lemmas.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Seq.Base.seq",
"Lib.UpdateMulti.Lemmas.uint8",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.l_and",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"Lib.UpdateMulti.update_multi_zero",
"Prims.unit",
"Lib.LoopCombinators.eq_repeati0",
"Lib.Sequence.repeat_blocks_f",
"Lib.Sequence.lemma_repeat_blocks_multi",
"Prims.bool",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Lib.Sequence.repeat_blocks_multi",
"Lib.UpdateMulti.mk_update_multi",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Seq.Base.append",
"FStar.Seq.Base.slice",
"Lib.LoopCombinators.repeati",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Lib.Sequence.Lemmas.repeat_blocks_multi_split",
"Prims.squash",
"Lib.UpdateMulti.Lemmas.update_multi_is_repeat_blocks_multi",
"Lib.LoopCombinators.unfold_repeati",
"Lib.UpdateMulti.Lemmas.update_multi_one",
"Lib.UpdateMulti.update_multi_associative",
"Prims._assert",
"FStar.Seq.Base.equal",
"Prims.nat",
"FStar.Math.Lemmas.lemma_mod_plus",
"Prims.op_Minus",
"FStar.Math.Lemmas.modulo_lemma",
"Prims.op_Subtraction",
"Prims.op_LessThanOrEqual",
"Lib.Sequence.seq",
"Lib.Sequence.lseq",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.UpdateMulti.Lemmas.repeat_f",
"FStar.Math.Lemmas.nat_over_pos_is_nat",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.split",
"FStar.Mul.op_Star"
] | [] | module Lib.UpdateMulti.Lemmas
/// This first auxiliary lemma only manipulates the lengths of the sequences.
#push-options "--z3cliopt smt.arith.nl=false"
let split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) :
Lemma
(requires (
rest <= l /\
(rest = 0 ==> d = 0) /\
d = n * l + rest))
(ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) =
(* We call ``split_at_last_lazy_nb_rem`` at the beginning to have its
* postcondition in the context (the return values are only used in the second
* branch *)
let n', rest' = split_at_last_lazy_nb_rem l d in
if d = 0 then
begin
Math.Lemmas.nat_times_nat_is_nat n l;
Math.Lemmas.int_times_int_equal_zero_lemma n l;
assert(n = 0)
end
else
begin
assert(d > 0);
(* In order to prove the equality between all the lengths, we use the unicity
* of the modulo to prove that the rests are equal, then that the numbers
* of blocks are equal. *)
let blocks = n * l in
let rest = d - blocks in
let blocks' = n' * l in
Math.Lemmas.cancel_mul_mod n l;
assert(blocks % l = 0);
assert(blocks' % l = 0); (* comes from the spec of [split_at_last_lazy_nb_rem] *)
Math.Lemmas.euclidean_division_definition blocks l;
(* First, prove that the lengths of the rests are equal modulo the size of
* a block *)
assert(rest' % l = d % l); (* comes from the spec of [split_at_last] *)
assert(rest + n * l = d);
Math.Lemmas.lemma_mod_plus rest n l; (* doesn't work inside a calc: typing problem with squash *)
assert(d % l = rest % l);
assert(rest % l = rest' % l);
(* If both rests are stricly smaller than a block, we can directly apply
* the modulo injectivity and the rest follows immediately *)
if rest < l && rest' < l then
begin
Math.Lemmas.lemma_mod_injective l rest rest';
assert(rest = rest');
assert(n * l + rest = n' * l + rest');
assert(n * l = n' * l);
Math.Lemmas.lemma_cancel_mul n n' l;
assert(n = n')
end
(* Otherwise, case one: both rests are equal to block length (even easier) *)
else if rest = l && rest' = l then
Math.Lemmas.lemma_cancel_mul n n' l
(* Last two cases: one of the rests is smaller than a block, and the other is
* of the size of a block. Because of modulo properties, the smaller rest
* must be equal to 0, which gives us that the data is actually of length 0:
* contradiction. *)
else
begin
assert((rest = l && rest' < l) \/ (rest < l && rest' = l));
let rest, rest' = if rest = l then rest, rest' else rest', rest in
assert(rest = l && rest' < l);
(* [rest % l = 0] *)
assert(rest = 1 * l);
Math.Lemmas.cancel_mul_mod 1 l;
assert(rest % l = 0);
(* [rest' = 0 ] *)
Math.Lemmas.modulo_lemma rest' l;
assert(rest' = 0);
(* By the current hypotheses, if rest' = 0 then d = 0 (contradiction) *)
assert(False)
end
end
#pop-options
/// This second lemma characterizes the sequences themselves.
/// The proof strategy is to first prove that the blocks and rest sequences have
/// the expected lengths, and the equality between the sequences is then trivial
/// to get.
#push-options "--z3cliopt smt.arith.nl=false"
let split_at_last_lazy_spec (l : pos)
(b blocks rest: S.seq uint8):
Lemma
(requires (
S.length blocks % l = 0 /\
S.length rest <= l /\
(S.length rest = 0 ==> S.length b = 0) /\
b `Seq.equal` Seq.append blocks rest))
(ensures (
(blocks, rest) == split_at_last_lazy l b)) =
(* We need to introduce the variables with which to call [split_at_last_lazy_nb_rem_spec] *)
let b_l = Seq.length b in
let blocks_l = Seq.length blocks in
let rest_l = Seq.length rest in
let blocks', rest' = split_at_last_lazy l b in
let n' = Seq.length blocks' / l in
let n = blocks_l / l in
Math.Lemmas.nat_over_pos_is_nat blocks_l l;
assert(n >= 0);
Math.Lemmas.euclidean_division_definition (S.length blocks) l;
split_at_last_lazy_nb_rem_spec l b_l n rest_l;
assert(((n <: nat), rest_l) = split_at_last_lazy_nb_rem l b_l);
assert(n = n'); (* comes from the spec of [split_at_last_lazy] *)
assert(rest_l = Seq.length rest');
(* We have the equalities between the sequence lengths, so the rest follows
* naturally *)
assert(blocks `Seq.equal` blocks');
assert(rest `Seq.equal` rest')
#pop-options
/// This is the reason why repeat_l is hoisted
let repeat_l_input #a (block_length:pos { block_length < pow2 32 })
(update_last: (a -> s:S.seq uint8 { S.length s < block_length } -> a))
(input1 input2:S.seq uint8)
(l: Lib.IntTypes.size_nat { l < block_length })
(s: Lib.Sequence.lseq uint8 l)
(acc: a): Lemma
(requires S.length input1 % block_length == S.length input2 % block_length)
(ensures repeat_l block_length update_last input1 l s acc ==
repeat_l block_length update_last input2 l s acc)
[ SMTPat (repeat_l block_length update_last input1 l s acc);
SMTPat (repeat_l block_length update_last input2 l s acc) ]
=
()
// NOTE: this proof is fragile but could be greatly simplified by using the
// (more robust) proof immediately below.
#set-options "--fuel 0 --ifuel 0 --z3rlimit 300"
let rec update_full_is_repeat_blocks #a block_length update update_last acc input input' =
// Lib.UpdateMulti side
let n_blocks = S.length input / block_length in
let blocks, rest = S.split input (n_blocks * block_length) in
// Lib.Sequence side
let repeat_f = repeat_f block_length update in
let repeat_l = repeat_l block_length update_last input' in
let repeat_acc =
Lib.LoopCombinators.repeati n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc
in
let last = Seq.slice input (n_blocks * block_length) (S.length input) in
let repeat_final_acc = repeat_l (S.length input % block_length) last repeat_acc in
Lib.Sequence.lemma_repeat_blocks #uint8 block_length input repeat_f repeat_l acc;
assert (repeat_final_acc == Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc);
// General, useful facts.
Math.Lemmas.euclidean_division_definition (S.length input) block_length;
S.lemma_eq_intro last rest;
assert (S.length rest == S.length input % block_length);
Math.Lemmas.multiple_modulo_lemma n_blocks block_length;
assert (S.length blocks % block_length = 0);
if S.length input < block_length then begin
Lib.UpdateMulti.update_multi_zero block_length update acc;
Math.Lemmas.small_mod (S.length input) block_length;
S.lemma_eq_intro input rest;
assert (update_full block_length update update_last acc input == update_last acc input);
Lib.LoopCombinators.eq_repeati0 n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc;
assert (repeat_acc == acc);
assert (repeat_final_acc == update_last acc input);
assert (repeat_final_acc == update_full block_length update update_last acc input)
end else begin
let head, tail = Lib.UpdateMulti.split_block block_length blocks 1 in
assert (S.length head % block_length = 0);
S.lemma_eq_intro (head `S.append` tail `S.append` rest) input;
S.lemma_eq_intro (head `S.append` (tail `S.append` rest)) input;
S.lemma_eq_intro (S.slice input 0 block_length) head;
S.lemma_eq_intro (S.slice input block_length (S.length input)) (tail `S.append` rest);
S.lemma_len_append head (tail `S.append` rest);
S.lemma_len_append tail rest;
calc (==) {
S.length (tail `S.append` rest) / block_length;
(==) { }
(S.length input - S.length head) / block_length;
(==) { }
(S.length input + (- 1) * block_length) / block_length;
(==) { Math.Lemmas.division_addition_lemma (S.length input) block_length (-1) }
n_blocks - 1;
};
// After a detailed investigation with quake, the two calls below seem to be
// flaky. Probably worth doing a detailed proof of these two in case this
// proof breaks in the future.
S.lemma_eq_intro (fst (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length))) tail;
S.lemma_eq_intro (snd (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length))) rest;
assert (S.length (tail `S.append` rest) % block_length == S.length input % block_length);
norm_spec [zeta; iota; primops; delta_only [`%mk_update_multi]]
(mk_update_multi block_length update acc (head `S.append` tail));
calc (==) {
Lib.UpdateMulti.update_full block_length update update_last acc input;
(==) { }
update_last (mk_update_multi block_length update (update acc head) tail) rest;
(==) { }
Lib.UpdateMulti.update_full block_length update update_last (update acc head) (tail `S.append` rest);
(==) { update_full_is_repeat_blocks #a block_length update update_last (update acc head) (tail `S.append` rest) input' }
Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l (update acc head);
(==) { }
Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l (repeat_f head acc);
(==) {
Lib.LoopCombinators.eq_repeati0 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc;
Lib.LoopCombinators.unfold_repeati 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc 0
}
Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l
(Lib.LoopCombinators.repeati 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc);
(==) { Lib.Sequence.lemma_repeat_blocks_multi block_length head repeat_f acc }
Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l
(Lib.Sequence.repeat_blocks_multi block_length head repeat_f acc);
(==) { Lib.Sequence.Lemmas.repeat_blocks_split block_length block_length input repeat_f repeat_l acc }
Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc;
}
end
#push-options "--fuel 2"
let update_multi_one #a (block_length: pos)
(update: update_t a block_length)
(acc0: a)
(input: S.seq uint8 { S.length input == block_length }): Lemma
(ensures
update acc0 input ==
Lib.UpdateMulti.mk_update_multi block_length update acc0 input)
=
()
#pop-options | false | false | Lib.UpdateMulti.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_multi_is_repeat_blocks_multi:
#a:Type0 ->
block_length:pos{ block_length < pow2 32 } ->
update: (a -> s:S.seq uint8 { S.length s = block_length } -> a) ->
acc:a ->
input:S.seq uint8 ->
Lemma
(requires (S.length input % block_length == 0))
(ensures (
let repeat_f = repeat_f block_length update in
Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc ==
Lib.UpdateMulti.mk_update_multi block_length update acc input))
(decreases (S.length input)) | [
"recursion"
] | Lib.UpdateMulti.Lemmas.update_multi_is_repeat_blocks_multi | {
"file_name": "lib/Lib.UpdateMulti.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
block_length: Prims.pos{block_length < Prims.pow2 32} ->
update:
(
_: a ->
s:
FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8
{FStar.Seq.Base.length s = block_length}
-> a) ->
acc: a ->
input: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length input % block_length == 0)
(ensures
(let repeat_f = Lib.UpdateMulti.Lemmas.repeat_f block_length update in
Lib.Sequence.repeat_blocks_multi block_length input repeat_f acc ==
Lib.UpdateMulti.mk_update_multi block_length update acc input))
(decreases FStar.Seq.Base.length input) | {
"end_col": 5,
"end_line": 285,
"start_col": 78,
"start_line": 231
} |
FStar.Pervasives.Lemma | val update_full_is_repeat_blocks:
#a:Type0 ->
block_length:pos { block_length < pow2 32 } ->
update: (a -> s:S.seq uint8 { S.length s = block_length } -> a) ->
update_last: (a -> s:S.seq uint8 { S.length s < block_length } -> a) ->
acc:a ->
input:S.seq uint8 ->
input':S.seq uint8 ->
Lemma
(requires (
S.length input % block_length == S.length input' % block_length))
(ensures (
let repeat_f = repeat_f block_length update in
let repeat_l = repeat_l block_length update_last input' in
Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc ==
Lib.UpdateMulti.update_full block_length update update_last acc input))
(decreases (S.length input)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.UpdateMulti",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec update_full_is_repeat_blocks #a block_length update update_last acc input input' =
// Lib.UpdateMulti side
let n_blocks = S.length input / block_length in
let blocks, rest = S.split input (n_blocks * block_length) in
// Lib.Sequence side
let repeat_f = repeat_f block_length update in
let repeat_l = repeat_l block_length update_last input' in
let repeat_acc =
Lib.LoopCombinators.repeati n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc
in
let last = Seq.slice input (n_blocks * block_length) (S.length input) in
let repeat_final_acc = repeat_l (S.length input % block_length) last repeat_acc in
Lib.Sequence.lemma_repeat_blocks #uint8 block_length input repeat_f repeat_l acc;
assert (repeat_final_acc == Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc);
// General, useful facts.
Math.Lemmas.euclidean_division_definition (S.length input) block_length;
S.lemma_eq_intro last rest;
assert (S.length rest == S.length input % block_length);
Math.Lemmas.multiple_modulo_lemma n_blocks block_length;
assert (S.length blocks % block_length = 0);
if S.length input < block_length then begin
Lib.UpdateMulti.update_multi_zero block_length update acc;
Math.Lemmas.small_mod (S.length input) block_length;
S.lemma_eq_intro input rest;
assert (update_full block_length update update_last acc input == update_last acc input);
Lib.LoopCombinators.eq_repeati0 n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc;
assert (repeat_acc == acc);
assert (repeat_final_acc == update_last acc input);
assert (repeat_final_acc == update_full block_length update update_last acc input)
end else begin
let head, tail = Lib.UpdateMulti.split_block block_length blocks 1 in
assert (S.length head % block_length = 0);
S.lemma_eq_intro (head `S.append` tail `S.append` rest) input;
S.lemma_eq_intro (head `S.append` (tail `S.append` rest)) input;
S.lemma_eq_intro (S.slice input 0 block_length) head;
S.lemma_eq_intro (S.slice input block_length (S.length input)) (tail `S.append` rest);
S.lemma_len_append head (tail `S.append` rest);
S.lemma_len_append tail rest;
calc (==) {
S.length (tail `S.append` rest) / block_length;
(==) { }
(S.length input - S.length head) / block_length;
(==) { }
(S.length input + (- 1) * block_length) / block_length;
(==) { Math.Lemmas.division_addition_lemma (S.length input) block_length (-1) }
n_blocks - 1;
};
// After a detailed investigation with quake, the two calls below seem to be
// flaky. Probably worth doing a detailed proof of these two in case this
// proof breaks in the future.
S.lemma_eq_intro (fst (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length))) tail;
S.lemma_eq_intro (snd (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length))) rest;
assert (S.length (tail `S.append` rest) % block_length == S.length input % block_length);
norm_spec [zeta; iota; primops; delta_only [`%mk_update_multi]]
(mk_update_multi block_length update acc (head `S.append` tail));
calc (==) {
Lib.UpdateMulti.update_full block_length update update_last acc input;
(==) { }
update_last (mk_update_multi block_length update (update acc head) tail) rest;
(==) { }
Lib.UpdateMulti.update_full block_length update update_last (update acc head) (tail `S.append` rest);
(==) { update_full_is_repeat_blocks #a block_length update update_last (update acc head) (tail `S.append` rest) input' }
Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l (update acc head);
(==) { }
Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l (repeat_f head acc);
(==) {
Lib.LoopCombinators.eq_repeati0 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc;
Lib.LoopCombinators.unfold_repeati 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc 0
}
Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l
(Lib.LoopCombinators.repeati 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc);
(==) { Lib.Sequence.lemma_repeat_blocks_multi block_length head repeat_f acc }
Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l
(Lib.Sequence.repeat_blocks_multi block_length head repeat_f acc);
(==) { Lib.Sequence.Lemmas.repeat_blocks_split block_length block_length input repeat_f repeat_l acc }
Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc;
}
end | val update_full_is_repeat_blocks:
#a:Type0 ->
block_length:pos { block_length < pow2 32 } ->
update: (a -> s:S.seq uint8 { S.length s = block_length } -> a) ->
update_last: (a -> s:S.seq uint8 { S.length s < block_length } -> a) ->
acc:a ->
input:S.seq uint8 ->
input':S.seq uint8 ->
Lemma
(requires (
S.length input % block_length == S.length input' % block_length))
(ensures (
let repeat_f = repeat_f block_length update in
let repeat_l = repeat_l block_length update_last input' in
Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc ==
Lib.UpdateMulti.update_full block_length update update_last acc input))
(decreases (S.length input))
let rec update_full_is_repeat_blocks #a block_length update update_last acc input input' = | false | null | true | let n_blocks = S.length input / block_length in
let blocks, rest = S.split input (n_blocks * block_length) in
let repeat_f = repeat_f block_length update in
let repeat_l = repeat_l block_length update_last input' in
let repeat_acc =
Lib.LoopCombinators.repeati n_blocks
(Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks)
acc
in
let last = Seq.slice input (n_blocks * block_length) (S.length input) in
let repeat_final_acc = repeat_l (S.length input % block_length) last repeat_acc in
Lib.Sequence.lemma_repeat_blocks #uint8 block_length input repeat_f repeat_l acc;
assert (repeat_final_acc ==
Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc);
Math.Lemmas.euclidean_division_definition (S.length input) block_length;
S.lemma_eq_intro last rest;
assert (S.length rest == S.length input % block_length);
Math.Lemmas.multiple_modulo_lemma n_blocks block_length;
assert (S.length blocks % block_length = 0);
if S.length input < block_length
then
(Lib.UpdateMulti.update_multi_zero block_length update acc;
Math.Lemmas.small_mod (S.length input) block_length;
S.lemma_eq_intro input rest;
assert (update_full block_length update update_last acc input == update_last acc input);
Lib.LoopCombinators.eq_repeati0 n_blocks
(Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks)
acc;
assert (repeat_acc == acc);
assert (repeat_final_acc == update_last acc input);
assert (repeat_final_acc == update_full block_length update update_last acc input))
else
let head, tail = Lib.UpdateMulti.split_block block_length blocks 1 in
assert (S.length head % block_length = 0);
S.lemma_eq_intro ((head `S.append` tail) `S.append` rest) input;
S.lemma_eq_intro (head `S.append` (tail `S.append` rest)) input;
S.lemma_eq_intro (S.slice input 0 block_length) head;
S.lemma_eq_intro (S.slice input block_length (S.length input)) (tail `S.append` rest);
S.lemma_len_append head (tail `S.append` rest);
S.lemma_len_append tail rest;
calc ( == ) {
S.length (tail `S.append` rest) / block_length;
( == ) { () }
(S.length input - S.length head) / block_length;
( == ) { () }
(S.length input + (- 1) * block_length) / block_length;
( == ) { Math.Lemmas.division_addition_lemma (S.length input) block_length (- 1) }
n_blocks - 1;
};
S.lemma_eq_intro (fst (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length))) tail;
S.lemma_eq_intro (snd (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length))) rest;
assert (S.length (tail `S.append` rest) % block_length == S.length input % block_length);
norm_spec [zeta; iota; primops; delta_only [`%mk_update_multi]]
(mk_update_multi block_length update acc (head `S.append` tail));
calc ( == ) {
Lib.UpdateMulti.update_full block_length update update_last acc input;
( == ) { () }
update_last (mk_update_multi block_length update (update acc head) tail) rest;
( == ) { () }
Lib.UpdateMulti.update_full block_length
update
update_last
(update acc head)
(tail `S.append` rest);
( == ) { update_full_is_repeat_blocks #a
block_length
update
update_last
(update acc head)
(tail `S.append` rest)
input' }
Lib.Sequence.repeat_blocks #uint8
block_length
(tail `S.append` rest)
repeat_f
repeat_l
(update acc head);
( == ) { () }
Lib.Sequence.repeat_blocks #uint8
block_length
(tail `S.append` rest)
repeat_f
repeat_l
(repeat_f head acc);
( == ) { (Lib.LoopCombinators.eq_repeati0 1
(Lib.Sequence.repeat_blocks_f block_length head repeat_f 1)
acc;
Lib.LoopCombinators.unfold_repeati 1
(Lib.Sequence.repeat_blocks_f block_length head repeat_f 1)
acc
0) }
Lib.Sequence.repeat_blocks #uint8
block_length
(tail `S.append` rest)
repeat_f
repeat_l
(Lib.LoopCombinators.repeati 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc
);
( == ) { Lib.Sequence.lemma_repeat_blocks_multi block_length head repeat_f acc }
Lib.Sequence.repeat_blocks #uint8
block_length
(tail `S.append` rest)
repeat_f
repeat_l
(Lib.Sequence.repeat_blocks_multi block_length head repeat_f acc);
( == ) { Lib.Sequence.Lemmas.repeat_blocks_split block_length
block_length
input
repeat_f
repeat_l
acc }
Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc;
} | {
"checked_file": "Lib.UpdateMulti.Lemmas.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.Lemmas.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.UpdateMulti.Lemmas.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Seq.Base.seq",
"Lib.UpdateMulti.Lemmas.uint8",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.l_and",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"Prims._assert",
"Prims.eq2",
"Lib.UpdateMulti.update_full",
"Prims.unit",
"Lib.LoopCombinators.eq_repeati0",
"Lib.Sequence.repeat_blocks_f",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Math.Lemmas.small_mod",
"Lib.UpdateMulti.update_multi_zero",
"Prims.bool",
"Lib.UpdateMulti.uint8",
"FStar.Calc.calc_finish",
"Lib.Sequence.repeat_blocks",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Seq.Base.append",
"Lib.Sequence.repeat_blocks_multi",
"Lib.LoopCombinators.repeati",
"Lib.UpdateMulti.mk_update_multi",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Lib.UpdateMulti.Lemmas.update_full_is_repeat_blocks",
"Lib.LoopCombinators.unfold_repeati",
"Lib.Sequence.lemma_repeat_blocks_multi",
"Lib.Sequence.Lemmas.repeat_blocks_split",
"FStar.Pervasives.norm_spec",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"FStar.Pervasives.primops",
"FStar.Pervasives.delta_only",
"Prims.string",
"Prims.op_Modulus",
"FStar.Pervasives.Native.snd",
"FStar.Seq.Properties.split",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.fst",
"Prims.op_Division",
"Prims.op_Addition",
"Prims.op_Minus",
"FStar.Math.Lemmas.division_addition_lemma",
"FStar.Seq.Base.lemma_len_append",
"FStar.Seq.Base.slice",
"FStar.Pervasives.Native.tuple2",
"Lib.UpdateMulti.split_block",
"FStar.Math.Lemmas.multiple_modulo_lemma",
"FStar.Math.Lemmas.euclidean_division_definition",
"Lib.Sequence.lemma_repeat_blocks",
"Prims.nat",
"Prims.op_LessThanOrEqual",
"Lib.Sequence.lseq",
"Lib.UpdateMulti.Lemmas.repeat_l",
"Lib.UpdateMulti.Lemmas.repeat_f"
] | [] | module Lib.UpdateMulti.Lemmas
/// This first auxiliary lemma only manipulates the lengths of the sequences.
#push-options "--z3cliopt smt.arith.nl=false"
let split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) :
Lemma
(requires (
rest <= l /\
(rest = 0 ==> d = 0) /\
d = n * l + rest))
(ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) =
(* We call ``split_at_last_lazy_nb_rem`` at the beginning to have its
* postcondition in the context (the return values are only used in the second
* branch *)
let n', rest' = split_at_last_lazy_nb_rem l d in
if d = 0 then
begin
Math.Lemmas.nat_times_nat_is_nat n l;
Math.Lemmas.int_times_int_equal_zero_lemma n l;
assert(n = 0)
end
else
begin
assert(d > 0);
(* In order to prove the equality between all the lengths, we use the unicity
* of the modulo to prove that the rests are equal, then that the numbers
* of blocks are equal. *)
let blocks = n * l in
let rest = d - blocks in
let blocks' = n' * l in
Math.Lemmas.cancel_mul_mod n l;
assert(blocks % l = 0);
assert(blocks' % l = 0); (* comes from the spec of [split_at_last_lazy_nb_rem] *)
Math.Lemmas.euclidean_division_definition blocks l;
(* First, prove that the lengths of the rests are equal modulo the size of
* a block *)
assert(rest' % l = d % l); (* comes from the spec of [split_at_last] *)
assert(rest + n * l = d);
Math.Lemmas.lemma_mod_plus rest n l; (* doesn't work inside a calc: typing problem with squash *)
assert(d % l = rest % l);
assert(rest % l = rest' % l);
(* If both rests are stricly smaller than a block, we can directly apply
* the modulo injectivity and the rest follows immediately *)
if rest < l && rest' < l then
begin
Math.Lemmas.lemma_mod_injective l rest rest';
assert(rest = rest');
assert(n * l + rest = n' * l + rest');
assert(n * l = n' * l);
Math.Lemmas.lemma_cancel_mul n n' l;
assert(n = n')
end
(* Otherwise, case one: both rests are equal to block length (even easier) *)
else if rest = l && rest' = l then
Math.Lemmas.lemma_cancel_mul n n' l
(* Last two cases: one of the rests is smaller than a block, and the other is
* of the size of a block. Because of modulo properties, the smaller rest
* must be equal to 0, which gives us that the data is actually of length 0:
* contradiction. *)
else
begin
assert((rest = l && rest' < l) \/ (rest < l && rest' = l));
let rest, rest' = if rest = l then rest, rest' else rest', rest in
assert(rest = l && rest' < l);
(* [rest % l = 0] *)
assert(rest = 1 * l);
Math.Lemmas.cancel_mul_mod 1 l;
assert(rest % l = 0);
(* [rest' = 0 ] *)
Math.Lemmas.modulo_lemma rest' l;
assert(rest' = 0);
(* By the current hypotheses, if rest' = 0 then d = 0 (contradiction) *)
assert(False)
end
end
#pop-options
/// This second lemma characterizes the sequences themselves.
/// The proof strategy is to first prove that the blocks and rest sequences have
/// the expected lengths, and the equality between the sequences is then trivial
/// to get.
#push-options "--z3cliopt smt.arith.nl=false"
let split_at_last_lazy_spec (l : pos)
(b blocks rest: S.seq uint8):
Lemma
(requires (
S.length blocks % l = 0 /\
S.length rest <= l /\
(S.length rest = 0 ==> S.length b = 0) /\
b `Seq.equal` Seq.append blocks rest))
(ensures (
(blocks, rest) == split_at_last_lazy l b)) =
(* We need to introduce the variables with which to call [split_at_last_lazy_nb_rem_spec] *)
let b_l = Seq.length b in
let blocks_l = Seq.length blocks in
let rest_l = Seq.length rest in
let blocks', rest' = split_at_last_lazy l b in
let n' = Seq.length blocks' / l in
let n = blocks_l / l in
Math.Lemmas.nat_over_pos_is_nat blocks_l l;
assert(n >= 0);
Math.Lemmas.euclidean_division_definition (S.length blocks) l;
split_at_last_lazy_nb_rem_spec l b_l n rest_l;
assert(((n <: nat), rest_l) = split_at_last_lazy_nb_rem l b_l);
assert(n = n'); (* comes from the spec of [split_at_last_lazy] *)
assert(rest_l = Seq.length rest');
(* We have the equalities between the sequence lengths, so the rest follows
* naturally *)
assert(blocks `Seq.equal` blocks');
assert(rest `Seq.equal` rest')
#pop-options
/// This is the reason why repeat_l is hoisted
let repeat_l_input #a (block_length:pos { block_length < pow2 32 })
(update_last: (a -> s:S.seq uint8 { S.length s < block_length } -> a))
(input1 input2:S.seq uint8)
(l: Lib.IntTypes.size_nat { l < block_length })
(s: Lib.Sequence.lseq uint8 l)
(acc: a): Lemma
(requires S.length input1 % block_length == S.length input2 % block_length)
(ensures repeat_l block_length update_last input1 l s acc ==
repeat_l block_length update_last input2 l s acc)
[ SMTPat (repeat_l block_length update_last input1 l s acc);
SMTPat (repeat_l block_length update_last input2 l s acc) ]
=
()
// NOTE: this proof is fragile but could be greatly simplified by using the
// (more robust) proof immediately below. | false | false | Lib.UpdateMulti.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_full_is_repeat_blocks:
#a:Type0 ->
block_length:pos { block_length < pow2 32 } ->
update: (a -> s:S.seq uint8 { S.length s = block_length } -> a) ->
update_last: (a -> s:S.seq uint8 { S.length s < block_length } -> a) ->
acc:a ->
input:S.seq uint8 ->
input':S.seq uint8 ->
Lemma
(requires (
S.length input % block_length == S.length input' % block_length))
(ensures (
let repeat_f = repeat_f block_length update in
let repeat_l = repeat_l block_length update_last input' in
Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc ==
Lib.UpdateMulti.update_full block_length update update_last acc input))
(decreases (S.length input)) | [
"recursion"
] | Lib.UpdateMulti.Lemmas.update_full_is_repeat_blocks | {
"file_name": "lib/Lib.UpdateMulti.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
block_length: Prims.pos{block_length < Prims.pow2 32} ->
update:
(
_: a ->
s:
FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8
{FStar.Seq.Base.length s = block_length}
-> a) ->
update_last:
(
_: a ->
s:
FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8
{FStar.Seq.Base.length s < block_length}
-> a) ->
acc: a ->
input: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8 ->
input': FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length input % block_length == FStar.Seq.Base.length input' % block_length)
(ensures
(let repeat_f = Lib.UpdateMulti.Lemmas.repeat_f block_length update in
let repeat_l = Lib.UpdateMulti.Lemmas.repeat_l block_length update_last input' in
Lib.Sequence.repeat_blocks block_length input repeat_f repeat_l acc ==
Lib.UpdateMulti.update_full block_length update update_last acc input))
(decreases FStar.Seq.Base.length input) | {
"end_col": 5,
"end_line": 217,
"start_col": 90,
"start_line": 133
} |
Prims.Tot | val aes_reqs
(alg: algorithm)
(key: seq nat32)
(round_keys: seq quad32)
(keys_b: buffer128)
(key_ptr: int)
(heap0: vale_heap)
(layout: vale_heap_layout)
: prop0 | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aes_reqs
(alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128)
(key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0
=
aesni_enabled /\ avx_enabled /\
(alg = AES_128 \/ alg = AES_256) /\
is_aes_key_LE alg key /\
length(round_keys) == nr(alg) + 1 /\
round_keys == key_to_round_keys_LE alg key /\
validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\
s128 heap0 keys_b == round_keys | val aes_reqs
(alg: algorithm)
(key: seq nat32)
(round_keys: seq quad32)
(keys_b: buffer128)
(key_ptr: int)
(heap0: vale_heap)
(layout: vale_heap_layout)
: prop0
let aes_reqs
(alg: algorithm)
(key: seq nat32)
(round_keys: seq quad32)
(keys_b: buffer128)
(key_ptr: int)
(heap0: vale_heap)
(layout: vale_heap_layout)
: prop0 = | false | null | false | aesni_enabled /\ avx_enabled /\ (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_LE alg key /\
length (round_keys) == nr (alg) + 1 /\ round_keys == key_to_round_keys_LE alg key /\
validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ s128 heap0 keys_b == round_keys | {
"checked_file": "Vale.AES.X64.GCMdecryptOpt.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fsti"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.buffer128",
"Prims.int",
"Vale.X64.InsBasic.vale_heap",
"Vale.Arch.HeapImpl.vale_heap_layout",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.CPU_Features_s.aesni_enabled",
"Vale.X64.CPU_Features_s.avx_enabled",
"Prims.l_or",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.AES_common_s.AES_256",
"Vale.AES.AES_s.is_aes_key_LE",
"Prims.eq2",
"FStar.Seq.Base.length",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.key_to_round_keys_LE",
"Vale.X64.Decls.validSrcAddrs128",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.X64.Decls.s128",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
let aes_reqs
(alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128)
(key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 | false | true | Vale.AES.X64.GCMdecryptOpt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aes_reqs
(alg: algorithm)
(key: seq nat32)
(round_keys: seq quad32)
(keys_b: buffer128)
(key_ptr: int)
(heap0: vale_heap)
(layout: vale_heap_layout)
: prop0 | [] | Vale.AES.X64.GCMdecryptOpt.aes_reqs | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
key_ptr: Prims.int ->
heap0: Vale.X64.InsBasic.vale_heap ->
layout: Vale.Arch.HeapImpl.vale_heap_layout
-> Vale.Def.Prop_s.prop0 | {
"end_col": 33,
"end_line": 56,
"start_col": 2,
"start_line": 50
} |
Prims.Tot | val va_quick_Gcm_blocks_decrypt_stdcall
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_quick_Gcm_blocks_decrypt_stdcall (win:bool) (alg:algorithm) (auth_b:buffer128)
(auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128)
(len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64)
(inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32))
: (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) =
(va_QProc (va_code_Gcm_blocks_decrypt_stdcall win alg) ([va_Mod_stackTaint; va_Mod_stack;
va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64
rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks_decrypt_stdcall win alg auth_b
auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b
out128_b len128_num inout_b cipher_num scratch_b tag_b key)
(va_wpProof_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv
hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key)) | val va_quick_Gcm_blocks_decrypt_stdcall
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg))
let va_quick_Gcm_blocks_decrypt_stdcall
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) = | false | null | false | (va_QProc (va_code_Gcm_blocks_decrypt_stdcall win alg)
([
va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4;
va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14;
va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9;
va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem
])
(va_wp_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b
abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num
scratch_b tag_b key)
(va_wpProof_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b
abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num
scratch_b tag_b key)) | {
"checked_file": "Vale.AES.X64.GCMdecryptOpt.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fsti"
} | [
"total"
] | [
"Prims.bool",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"Vale.X64.Memory.nat64",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_stackTaint",
"Vale.X64.QuickCode.va_Mod_stack",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_layout",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Vale.AES.X64.GCMdecryptOpt.va_wp_Gcm_blocks_decrypt_stdcall",
"Vale.AES.X64.GCMdecryptOpt.va_wpProof_Gcm_blocks_decrypt_stdcall",
"Vale.X64.QuickCode.va_quickCode"
] | [] | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
let aes_reqs
(alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128)
(key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0
=
aesni_enabled /\ avx_enabled /\
(alg = AES_128 \/ alg = AES_256) /\
is_aes_key_LE alg key /\
length(round_keys) == nr(alg) + 1 /\
round_keys == key_to_round_keys_LE alg key /\
validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\
s128 heap0 keys_b == round_keys
#reset-options "--z3rlimit 100 --max_ifuel 0"
//-- Gcm_blocks_decrypt_stdcall
val va_code_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_code
val va_codegen_success_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_pbool
let va_req_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) : prop =
(va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok va_s0 /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 ==
len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem
va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem
va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128
tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b])
/\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128
scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b;
out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b;
abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv)))
let va_ens_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) (va_sM:va_state) (va_fM:va_fuel) : prop =
(va_req_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b iv
hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM
(va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout
va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3
va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM
(va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM
(va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15
va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM
(va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks_decrypt_stdcall : va_b0:va_code -> va_s0:va_state -> win:bool ->
alg:algorithm -> auth_b:buffer128 -> auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 ->
iv_b:buffer128 -> iv:supported_iv_LE -> hkeys_b:buffer128 -> abytes_b:buffer128 ->
in128x6_b:buffer128 -> out128x6_b:buffer128 -> len128x6_num:nat64 -> in128_b:buffer128 ->
out128_b:buffer128 -> len128_num:nat64 -> inout_b:buffer128 -> cipher_num:nat64 ->
scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq nat32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok
va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx
va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0
18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in
let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 ==
len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem
va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem
va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128
tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b])
/\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128
scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b;
out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b;
abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM
(va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout
va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3
va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM
(va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM
(va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15
va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM
(va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))))))
[@ va_qattr]
let va_wp_Gcm_blocks_decrypt_stdcall (win:bool) (alg:algorithm) (auth_b:buffer128)
(auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128)
(len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64)
(inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let
(auth_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx
va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64
rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR8 va_s0) in let
(xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR9 va_s0)
in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let
(in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let
(out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in
let (len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in
let (in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in
let (out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in
let (inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in
let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in
let (tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in
sse_enabled /\ movbe_enabled /\ va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp
(va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem
va_s0) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ auth_len == auth_num /\ auth_num_bytes ==
auth_bytes /\ len128x6 == len128x6_num /\ len128 == len128_num /\ cipher_num_bytes ==
cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) auth_ptr auth_b auth_len
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) iv_ptr iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128_ptr in128_b len128 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128_ptr out128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) scratch_ptr scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) tag_ptr tag_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 tag_b ([auth_b; abytes_b; iv_b; in128x6_b;
out128x6_b; in128_b; out128_b; inout_b; scratch_b]) /\ Vale.X64.Decls.buffer_disjoints128 iv_b
([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; auth_b; abytes_b;
in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b; abytes_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64)
(va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64)
(va_x_rsp:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_memLayout:vale_heap_layout) (va_x_efl:Vale.X64.Flags.t) (va_x_stack:vale_stack)
(va_x_stackTaint:memtaint) . let va_sM = va_upd_stackTaint va_x_stackTaint (va_upd_stack
va_x_stack (va_upd_flags va_x_efl (va_upd_mem_layout va_x_memLayout (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsp va_x_rsp (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx
va_x_rdx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax
(va_upd_mem va_x_mem va_s0))))))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0)
(fun _ -> va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64
rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64
rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) (fun
_ -> va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = va_if win
(fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack
va_s0)) (fun _ -> va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 16) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 24) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 32) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 40) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 48) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 56) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 64) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 72) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 80) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 88) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 96) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> auth_b:buffer128 ->
auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
hkeys_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
len128x6_num:nat64 -> in128_b:buffer128 -> out128_b:buffer128 -> len128_num:nat64 ->
inout_b:buffer128 -> cipher_num:nat64 -> scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq
nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes
auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b
len128_num inout_b cipher_num scratch_b tag_b key va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_decrypt_stdcall win alg)
([va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64
rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks_decrypt_stdcall (win:bool) (alg:algorithm) (auth_b:buffer128)
(auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128)
(len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64)
(inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32)) | false | false | Vale.AES.X64.GCMdecryptOpt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_quick_Gcm_blocks_decrypt_stdcall
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) | [] | Vale.AES.X64.GCMdecryptOpt.va_quick_Gcm_blocks_decrypt_stdcall | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
win: Prims.bool ->
alg: Vale.AES.AES_common_s.algorithm ->
auth_b: Vale.X64.Memory.buffer128 ->
auth_bytes: Vale.X64.Memory.nat64 ->
auth_num: Vale.X64.Memory.nat64 ->
keys_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
hkeys_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
len128x6_num: Vale.X64.Memory.nat64 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
len128_num: Vale.X64.Memory.nat64 ->
inout_b: Vale.X64.Memory.buffer128 ->
cipher_num: Vale.X64.Memory.nat64 ->
scratch_b: Vale.X64.Memory.buffer128 ->
tag_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall win alg) | {
"end_col": 36,
"end_line": 855,
"start_col": 2,
"start_line": 842
} |
Prims.Tot | val va_ens_Gcm_blocks_decrypt_stdcall
(va_b0: va_code)
(va_s0: va_state)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
(va_sM: va_state)
(va_fM: va_fuel)
: prop | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_ens_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) (va_sM:va_state) (va_fM:va_fuel) : prop =
(va_req_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b iv
hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM
(va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout
va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3
va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM
(va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM
(va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15
va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM
(va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))))) | val va_ens_Gcm_blocks_decrypt_stdcall
(va_b0: va_code)
(va_s0: va_state)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
(va_sM: va_state)
(va_fM: va_fuel)
: prop
let va_ens_Gcm_blocks_decrypt_stdcall
(va_b0: va_code)
(va_s0: va_state)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
(va_sM: va_state)
(va_fM: va_fuel)
: prop = | false | null | false | (va_req_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b iv
hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let auth_ptr:(va_int_range 0 18446744073709551615) =
(if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0)
in
let auth_num_bytes:(va_int_range 0 18446744073709551615) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0)
in
let auth_len:(va_int_range 0 18446744073709551615) =
(if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0)
in
let keys_ptr:(va_int_range 0 18446744073709551615) =
(if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0)
in
let iv_ptr:(va_int_range 0 18446744073709551615) =
(if win
then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0)
else va_get_reg64 rR8 va_s0)
in
let xip:(va_int_range 0 18446744073709551615) =
(if win
then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)
else va_get_reg64 rR9 va_s0)
in
let abytes_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0))
in
let in128x6_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0))
in
let out128x6_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0))
in
let len128x6:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0))
in
let in128_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0))
in
let out128_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0))
in
let len128:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0))
in
let inout_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0))
in
let cipher_num_bytes:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0))
in
let scratch_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0))
in
let tag_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0))
in
Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b)))))
(va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in
let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b)
in
let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
auth_num_bytes
in
let cipher_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b))
(Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b)
in
let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads)
0
cipher_num_bytes
in
let plain_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem va_sM) out128_b))
(Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b)
in
let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
cipher_num_bytes
in
let expected_tag =
Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b
0
(va_get_mem va_s0))
in
l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)
#bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
cipher_bytes
auth_bytes
expected_tag)))
(va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)
#bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
cipher_bytes
auth_bytes
expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\
(win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\
(win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\
(win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\
(win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\
(win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\
(win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\
(win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\
(win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\
(win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\
(win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\
(win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\
(win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\
(win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\
(win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\
(~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\
(~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\
(~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\
(~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\
(~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\
va_state_eq va_sM
(va_update_stackTaint va_sM
(va_update_stack va_sM
(va_update_flags va_sM
(va_update_mem_layout va_sM
(va_update_mem_heaplet 6
va_sM
(va_update_mem_heaplet 5
va_sM
(va_update_mem_heaplet 3
va_sM
(va_update_mem_heaplet 2
va_sM
(va_update_mem_heaplet 1
va_sM
(va_update_xmm 15
va_sM
(va_update_xmm 14
va_sM
(va_update_xmm 13
va_sM
(va_update_xmm 12
va_sM
(va_update_xmm 11
va_sM
(va_update_xmm 10
va_sM
(va_update_xmm 9
va_sM
(va_update_xmm 8
va_sM
(va_update_xmm 7
va_sM
(va_update_xmm 6
va_sM
(va_update_xmm 5
va_sM
(va_update_xmm 4
va_sM
(va_update_xmm
3
va_sM
(va_update_xmm
2
va_sM
(va_update_xmm
1
va_sM
(
va_update_xmm
0
va_sM
(
va_update_reg64
rR15
va_sM
(
va_update_reg64
rR14
va_sM
(
va_update_reg64
rR13
va_sM
(
va_update_reg64
rR12
va_sM
(
va_update_reg64
rR11
va_sM
(
va_update_reg64
rR10
va_sM
(
va_update_reg64
rR9
va_sM
(
va_update_reg64
rR8
va_sM
(
va_update_reg64
rRbp
va_sM
(
va_update_reg64
rRsp
va_sM
(
va_update_reg64
rRsi
va_sM
(
va_update_reg64
rRdi
va_sM
(
va_update_reg64
rRdx
va_sM
(
va_update_reg64
rRcx
va_sM
(
va_update_reg64
rRbx
va_sM
(
va_update_reg64
rRax
va_sM
(
va_update_ok
va_sM
(
va_update_mem
va_sM
va_s0
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
))
))))))))))))
))))))))))) | {
"checked_file": "Vale.AES.X64.GCMdecryptOpt.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Prims.bool",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"Vale.X64.Memory.nat64",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.va_fuel",
"Prims.l_and",
"Vale.AES.X64.GCMdecryptOpt.va_req_Gcm_blocks_decrypt_stdcall",
"Vale.X64.Decls.va_ensure_total",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.Decls.modifies_mem",
"Vale.X64.Decls.loc_union",
"Vale.X64.Decls.loc_buffer",
"Vale.X64.Memory.vuint128",
"Vale.X64.Decls.va_get_mem",
"Prims.op_LessThan",
"Vale.X64.Machine_s.pow2_32",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"Vale.AES.AES_common_s.is_aes_key",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"Prims.eq2",
"FStar.Pervasives.Native.__proj__Mktuple2__item___1",
"Vale.AES.GCM_s.gcm_decrypt_LE",
"Prims.op_Equality",
"Prims.int",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rRax",
"FStar.Pervasives.Native.__proj__Mktuple2__item___2",
"Vale.Def.Types_s.nat64",
"Vale.X64.Machine_s.rRsp",
"Prims.l_imp",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Decls.quad32",
"Vale.X64.Decls.va_get_xmm",
"Prims.l_not",
"Vale.Def.Words_s.nat8",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.X64.Decls.buffer128_read",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.append",
"Vale.X64.Decls.s128",
"Vale.X64.Decls.va_int_range",
"Vale.X64.Stack_i.load_stack64",
"Prims.op_Addition",
"Vale.X64.Decls.va_get_stack",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_stackTaint",
"Vale.X64.Decls.va_update_stack",
"Vale.X64.Decls.va_update_flags",
"Vale.X64.Decls.va_update_mem_layout",
"Vale.X64.Decls.va_update_mem_heaplet",
"Vale.X64.Decls.va_update_xmm",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_update_mem",
"Prims.prop"
] | [] | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
let aes_reqs
(alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128)
(key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0
=
aesni_enabled /\ avx_enabled /\
(alg = AES_128 \/ alg = AES_256) /\
is_aes_key_LE alg key /\
length(round_keys) == nr(alg) + 1 /\
round_keys == key_to_round_keys_LE alg key /\
validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\
s128 heap0 keys_b == round_keys
#reset-options "--z3rlimit 100 --max_ifuel 0"
//-- Gcm_blocks_decrypt_stdcall
val va_code_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_code
val va_codegen_success_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_pbool
let va_req_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) : prop =
(va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok va_s0 /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 ==
len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem
va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem
va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128
tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b])
/\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128
scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b;
out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b;
abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv)))
let va_ens_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) | false | true | Vale.AES.X64.GCMdecryptOpt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_ens_Gcm_blocks_decrypt_stdcall
(va_b0: va_code)
(va_s0: va_state)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
(va_sM: va_state)
(va_fM: va_fuel)
: prop | [] | Vale.AES.X64.GCMdecryptOpt.va_ens_Gcm_blocks_decrypt_stdcall | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
win: Prims.bool ->
alg: Vale.AES.AES_common_s.algorithm ->
auth_b: Vale.X64.Memory.buffer128 ->
auth_bytes: Vale.X64.Memory.nat64 ->
auth_num: Vale.X64.Memory.nat64 ->
keys_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
hkeys_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
len128x6_num: Vale.X64.Memory.nat64 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
len128_num: Vale.X64.Memory.nat64 ->
inout_b: Vale.X64.Memory.buffer128 ->
cipher_num: Vale.X64.Memory.nat64 ->
scratch_b: Vale.X64.Memory.buffer128 ->
tag_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
va_sM: Vale.X64.Decls.va_state ->
va_fM: Vale.X64.Decls.va_fuel
-> Prims.prop | {
"end_col": 94,
"end_line": 311,
"start_col": 2,
"start_line": 210
} |
Prims.Tot | val va_req_Gcm_blocks_decrypt_stdcall
(va_b0: va_code)
(va_s0: va_state)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: prop | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_req_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) : prop =
(va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok va_s0 /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 ==
len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem
va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem
va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128
tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b])
/\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128
scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b;
out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b;
abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv))) | val va_req_Gcm_blocks_decrypt_stdcall
(va_b0: va_code)
(va_s0: va_state)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: prop
let va_req_Gcm_blocks_decrypt_stdcall
(va_b0: va_code)
(va_s0: va_state)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: prop = | false | null | false | (va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok va_s0 /\
(let auth_ptr:(va_int_range 0 18446744073709551615) =
(if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0)
in
let auth_num_bytes:(va_int_range 0 18446744073709551615) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0)
in
let auth_len:(va_int_range 0 18446744073709551615) =
(if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0)
in
let keys_ptr:(va_int_range 0 18446744073709551615) =
(if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0)
in
let iv_ptr:(va_int_range 0 18446744073709551615) =
(if win
then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0)
else va_get_reg64 rR8 va_s0)
in
let xip:(va_int_range 0 18446744073709551615) =
(if win
then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)
else va_get_reg64 rR9 va_s0)
in
let abytes_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0))
in
let in128x6_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0))
in
let out128x6_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0))
in
let len128x6:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0))
in
let in128_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0))
in
let out128_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0))
in
let len128:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0))
in
let inout_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0))
in
let cipher_num_bytes:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0))
in
let scratch_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0))
in
let tag_ptr:(va_int_range 0 18446744073709551615) =
(if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0))
in
sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 8)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 24)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 40)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 56)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 72)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 0)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 16)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 32)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 48)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 64)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 80)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 96)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\ auth_len == auth_num /\ auth_num_bytes == auth_bytes /\
len128x6 == len128x6_num /\ len128 == len128_num /\ cipher_num_bytes == cipher_num /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
auth_ptr
auth_b
auth_len
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
abytes_ptr
abytes_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
iv_ptr
iv_b
1
(va_get_mem_layout va_s0)
Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr
in128x6_b
len128x6
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
out128x6_ptr
out128x6_b
len128x6
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr
in128_b
len128
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
out128_ptr
out128_b
len128
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
inout_ptr
inout_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
scratch_ptr
scratch_b
9
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
xip
hkeys_b
8
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
tag_ptr
tag_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.buffer_disjoints128 tag_b
([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b]) /\
Vale.X64.Decls.buffer_disjoints128 iv_b
([
keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b;
hkeys_b
]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b
([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 inout_b
([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b; abytes_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b
([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 in128x6_b
([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\
auth_ptr + 16 `op_Multiply` auth_len < pow2_64 /\
in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\
inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == len128x6 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == len128 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64 /\
len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 < pow2_32 /\
(va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) <=
cipher_num_bytes /\
cipher_num_bytes <
va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) +
128
`op_Division`
8) /\
(va_mul_nat auth_len (128 `op_Division` 8) <= auth_num_bytes /\
auth_num_bytes < va_mul_nat auth_len (128 `op_Division` 8) + 128 `op_Division` 8) /\
aes_reqs alg
key
(Vale.X64.Decls.buffer128_as_seq (va_get_mem va_s0) keys_b)
keys_b
keys_ptr
(va_get_mem va_s0)
(va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\
(let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in
let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in
iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))) | {
"checked_file": "Vale.AES.X64.GCMdecryptOpt.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fsti"
} | [
"total"
] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Prims.bool",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"Vale.X64.Memory.nat64",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Prims.l_and",
"Vale.X64.Decls.va_require_total",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sse_enabled",
"Vale.X64.CPU_Features_s.movbe_enabled",
"Prims.eq2",
"Vale.Def.Words_s.nat64",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Stack_i.init_rsp",
"Vale.X64.Decls.va_get_stack",
"Vale.X64.Memory.is_initial_heap",
"Vale.X64.Decls.va_get_mem_layout",
"Vale.X64.Decls.va_get_mem",
"Prims.l_imp",
"Prims.l_not",
"Vale.X64.Stack_i.valid_stack_slot64",
"Prims.op_Addition",
"Vale.Arch.HeapTypes_s.Public",
"Vale.X64.Decls.va_get_stackTaint",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_64",
"Prims.op_LessThanOrEqual",
"Vale.X64.Decls.validSrcAddrs128",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.X64.Decls.validDstAddrs128",
"Vale.X64.Decls.buffer_disjoints128",
"Prims.Cons",
"Prims.Nil",
"Vale.X64.Decls.buffers_disjoint128",
"Prims.op_Multiply",
"Vale.X64.Machine_s.pow2_64",
"Vale.X64.Decls.buffer_length",
"Vale.X64.Memory.vuint128",
"Prims.nat",
"Vale.X64.Machine_s.pow2_32",
"Vale.X64.Memory.buffer_addr",
"Prims.op_Modulus",
"Prims.op_GreaterThan",
"Vale.X64.Decls.va_mul_nat",
"Prims.op_Division",
"Vale.AES.X64.GCMdecryptOpt.aes_reqs",
"Vale.X64.Decls.buffer128_as_seq",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"Vale.AES.OptPublic.hkeys_reqs_pub",
"Vale.X64.Decls.s128",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.quad32",
"Vale.AES.GCM_s.compute_iv_BE",
"Vale.X64.Decls.buffer128_read",
"Vale.X64.Decls.va_int_range",
"Vale.X64.Stack_i.load_stack64",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Prims.prop"
] | [] | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
let aes_reqs
(alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128)
(key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0
=
aesni_enabled /\ avx_enabled /\
(alg = AES_128 \/ alg = AES_256) /\
is_aes_key_LE alg key /\
length(round_keys) == nr(alg) + 1 /\
round_keys == key_to_round_keys_LE alg key /\
validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\
s128 heap0 keys_b == round_keys
#reset-options "--z3rlimit 100 --max_ifuel 0"
//-- Gcm_blocks_decrypt_stdcall
val va_code_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_code
val va_codegen_success_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_pbool
let va_req_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) | false | true | Vale.AES.X64.GCMdecryptOpt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_req_Gcm_blocks_decrypt_stdcall
(va_b0: va_code)
(va_s0: va_state)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: prop | [] | Vale.AES.X64.GCMdecryptOpt.va_req_Gcm_blocks_decrypt_stdcall | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
win: Prims.bool ->
alg: Vale.AES.AES_common_s.algorithm ->
auth_b: Vale.X64.Memory.buffer128 ->
auth_bytes: Vale.X64.Memory.nat64 ->
auth_num: Vale.X64.Memory.nat64 ->
keys_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
hkeys_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
len128x6_num: Vale.X64.Memory.nat64 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
len128_num: Vale.X64.Memory.nat64 ->
inout_b: Vale.X64.Memory.buffer128 ->
cipher_num: Vale.X64.Memory.nat64 ->
scratch_b: Vale.X64.Memory.buffer128 ->
tag_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32
-> Prims.prop | {
"end_col": 43,
"end_line": 203,
"start_col": 2,
"start_line": 69
} |
Prims.Tot | val va_wp_Gcm_blocks_decrypt_stdcall
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_Gcm_blocks_decrypt_stdcall (win:bool) (alg:algorithm) (auth_b:buffer128)
(auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128)
(len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64)
(inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let
(auth_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx
va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64
rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR8 va_s0) in let
(xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR9 va_s0)
in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let
(in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let
(out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in
let (len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in
let (in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in
let (out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in
let (inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in
let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in
let (tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in
sse_enabled /\ movbe_enabled /\ va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp
(va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem
va_s0) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ auth_len == auth_num /\ auth_num_bytes ==
auth_bytes /\ len128x6 == len128x6_num /\ len128 == len128_num /\ cipher_num_bytes ==
cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) auth_ptr auth_b auth_len
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) iv_ptr iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128_ptr in128_b len128 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128_ptr out128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) scratch_ptr scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) tag_ptr tag_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 tag_b ([auth_b; abytes_b; iv_b; in128x6_b;
out128x6_b; in128_b; out128_b; inout_b; scratch_b]) /\ Vale.X64.Decls.buffer_disjoints128 iv_b
([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; auth_b; abytes_b;
in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b; abytes_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64)
(va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64)
(va_x_rsp:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_memLayout:vale_heap_layout) (va_x_efl:Vale.X64.Flags.t) (va_x_stack:vale_stack)
(va_x_stackTaint:memtaint) . let va_sM = va_upd_stackTaint va_x_stackTaint (va_upd_stack
va_x_stack (va_upd_flags va_x_efl (va_upd_mem_layout va_x_memLayout (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsp va_x_rsp (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx
va_x_rdx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax
(va_upd_mem va_x_mem va_s0))))))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0)
(fun _ -> va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64
rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64
rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) (fun
_ -> va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = va_if win
(fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack
va_s0)) (fun _ -> va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 16) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 24) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 32) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 40) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 48) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 56) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 64) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 72) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 80) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 88) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 40 + 96) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) ==> va_k va_sM (()))) | val va_wp_Gcm_blocks_decrypt_stdcall
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_Gcm_blocks_decrypt_stdcall
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_get_ok va_s0 /\
(let auth_ptr:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0)
in
let auth_num_bytes:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0)
in
let auth_len:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0)
in
let keys_ptr:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0)
in
let iv_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0)
(va_get_stack va_s0))
(fun _ -> va_get_reg64 rR8 va_s0)
in
let xip:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8)
(va_get_stack va_s0))
(fun _ -> va_get_reg64 rR9 va_s0)
in
let abytes_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0))
in
let in128x6_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0))
in
let out128x6_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0))
in
let len128x6:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0))
in
let in128_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0))
in
let out128_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0))
in
let len128:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0))
in
let inout_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0))
in
let cipher_num_bytes:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0))
in
let scratch_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0))
in
let tag_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0))
in
sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 8)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 24)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 40)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 56)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 72)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 0)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 16)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 32)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 48)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 64)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 80)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\
(win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 96)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0)) /\ auth_len == auth_num /\ auth_num_bytes == auth_bytes /\
len128x6 == len128x6_num /\ len128 == len128_num /\ cipher_num_bytes == cipher_num /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
auth_ptr
auth_b
auth_len
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
abytes_ptr
abytes_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
iv_ptr
iv_b
1
(va_get_mem_layout va_s0)
Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr
in128x6_b
len128x6
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
out128x6_ptr
out128x6_b
len128x6
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr
in128_b
len128
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
out128_ptr
out128_b
len128
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
inout_ptr
inout_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
scratch_ptr
scratch_b
9
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
xip
hkeys_b
8
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0)
tag_ptr
tag_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.buffer_disjoints128 tag_b
([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b]) /\
Vale.X64.Decls.buffer_disjoints128 iv_b
([
keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b;
hkeys_b
]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b
([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 inout_b
([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b; abytes_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b
([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 in128x6_b
([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\
auth_ptr + 16 `op_Multiply` auth_len < pow2_64 /\
in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\
inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == len128x6 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == len128 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64 /\
len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 < pow2_32 /\
(va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) <=
cipher_num_bytes /\
cipher_num_bytes <
va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) +
128
`op_Division`
8) /\
(va_mul_nat auth_len (128 `op_Division` 8) <= auth_num_bytes /\
auth_num_bytes < va_mul_nat auth_len (128 `op_Division` 8) + 128 `op_Division` 8) /\
aes_reqs alg
key
(Vale.X64.Decls.buffer128_as_seq (va_get_mem va_s0) keys_b)
keys_b
keys_ptr
(va_get_mem va_s0)
(va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\
(let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in
let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in
iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\
(forall (va_x_mem: vale_heap) (va_x_rax: nat64) (va_x_rbx: nat64) (va_x_rcx: nat64)
(va_x_rdx: nat64) (va_x_rdi: nat64) (va_x_rsi: nat64) (va_x_rsp: nat64) (va_x_rbp: nat64)
(va_x_r8: nat64) (va_x_r9: nat64) (va_x_r10: nat64) (va_x_r11: nat64) (va_x_r12: nat64)
(va_x_r13: nat64) (va_x_r14: nat64) (va_x_r15: nat64) (va_x_xmm0: quad32) (va_x_xmm1: quad32)
(va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_xmm4: quad32) (va_x_xmm5: quad32)
(va_x_xmm6: quad32) (va_x_xmm7: quad32) (va_x_xmm8: quad32) (va_x_xmm9: quad32)
(va_x_xmm10: quad32) (va_x_xmm11: quad32) (va_x_xmm12: quad32) (va_x_xmm13: quad32)
(va_x_xmm14: quad32) (va_x_xmm15: quad32) (va_x_heap1: vale_heap) (va_x_heap2: vale_heap)
(va_x_heap3: vale_heap) (va_x_heap5: vale_heap) (va_x_heap6: vale_heap)
(va_x_memLayout: vale_heap_layout) (va_x_efl: Vale.X64.Flags.t) (va_x_stack: vale_stack)
(va_x_stackTaint: memtaint).
let va_sM =
va_upd_stackTaint va_x_stackTaint
(va_upd_stack va_x_stack
(va_upd_flags va_x_efl
(va_upd_mem_layout va_x_memLayout
(va_upd_mem_heaplet 6
va_x_heap6
(va_upd_mem_heaplet 5
va_x_heap5
(va_upd_mem_heaplet 3
va_x_heap3
(va_upd_mem_heaplet 2
va_x_heap2
(va_upd_mem_heaplet 1
va_x_heap1
(va_upd_xmm 15
va_x_xmm15
(va_upd_xmm 14
va_x_xmm14
(va_upd_xmm 13
va_x_xmm13
(va_upd_xmm 12
va_x_xmm12
(va_upd_xmm 11
va_x_xmm11
(va_upd_xmm 10
va_x_xmm10
(va_upd_xmm 9
va_x_xmm9
(va_upd_xmm 8
va_x_xmm8
(va_upd_xmm 7
va_x_xmm7
(va_upd_xmm 6
va_x_xmm6
(va_upd_xmm 5
va_x_xmm5
(va_upd_xmm 4
va_x_xmm4
(va_upd_xmm
3
va_x_xmm3
(va_upd_xmm
2
va_x_xmm2
(va_upd_xmm
1
va_x_xmm1
(
va_upd_xmm
0
va_x_xmm0
(
va_upd_reg64
rR15
va_x_r15
(
va_upd_reg64
rR14
va_x_r14
(
va_upd_reg64
rR13
va_x_r13
(
va_upd_reg64
rR12
va_x_r12
(
va_upd_reg64
rR11
va_x_r11
(
va_upd_reg64
rR10
va_x_r10
(
va_upd_reg64
rR9
va_x_r9
(
va_upd_reg64
rR8
va_x_r8
(
va_upd_reg64
rRbp
va_x_rbp
(
va_upd_reg64
rRsp
va_x_rsp
(
va_upd_reg64
rRsi
va_x_rsi
(
va_upd_reg64
rRdi
va_x_rdi
(
va_upd_reg64
rRdx
va_x_rdx
(
va_upd_reg64
rRcx
va_x_rcx
(
va_upd_reg64
rRbx
va_x_rbx
(
va_upd_reg64
rRax
va_x_rax
(
va_upd_mem
va_x_mem
va_s0
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
))
))))))))))
)))))))))))
in
va_get_ok va_sM /\
(let auth_ptr:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0)
in
let auth_num_bytes:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0)
in
let auth_len:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0)
in
let keys_ptr:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0)
in
let iv_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0)
(va_get_stack va_s0))
(fun _ -> va_get_reg64 rR8 va_s0)
in
let xip:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8)
(va_get_stack va_s0))
(fun _ -> va_get_reg64 rR9 va_s0)
in
let abytes_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
)
in
let in128x6_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)
)
in
let out128x6_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16)
(va_get_stack va_s0))
in
let len128x6:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24)
(va_get_stack va_s0))
in
let in128_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32)
(va_get_stack va_s0))
in
let out128_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40)
(va_get_stack va_s0))
in
let len128:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48)
(va_get_stack va_s0))
in
let inout_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56)
(va_get_stack va_s0))
in
let cipher_num_bytes:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64)
(va_get_stack va_s0))
in
let scratch_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72)
(va_get_stack va_s0))
in
let tag_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80)
(va_get_stack va_s0))
in
Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b)))))
(va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in
let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b)
in
let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
auth_num_bytes
in
let cipher_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b))
(Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b)
in
let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads)
0
cipher_num_bytes
in
let plain_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem va_sM) out128_b))
(Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b)
in
let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
cipher_num_bytes
in
let expected_tag =
Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b
0
(va_get_mem va_s0))
in
l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes <
pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)
#bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
cipher_bytes
auth_bytes
expected_tag)))
(va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)
#bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
cipher_bytes
auth_bytes
expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\
(win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\
(win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\
(win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\
(win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\
(win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\
(win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\
(win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\
(win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\
(win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\
(win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\
(win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\
(win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\
(win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\
(win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\
(~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\
(~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\
(~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\
(~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\
(~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.AES.X64.GCMdecryptOpt.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fsti"
} | [
"total"
] | [
"Prims.bool",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"Vale.X64.Memory.nat64",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sse_enabled",
"Vale.X64.CPU_Features_s.movbe_enabled",
"Prims.eq2",
"Vale.Def.Words_s.nat64",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Stack_i.init_rsp",
"Vale.X64.Decls.va_get_stack",
"Vale.X64.Memory.is_initial_heap",
"Vale.X64.Decls.va_get_mem_layout",
"Vale.X64.Decls.va_get_mem",
"Prims.l_imp",
"Prims.l_not",
"Vale.X64.Stack_i.valid_stack_slot64",
"Prims.op_Addition",
"Vale.Arch.HeapTypes_s.Public",
"Vale.X64.Decls.va_get_stackTaint",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_64",
"Prims.op_LessThanOrEqual",
"Vale.X64.Decls.validSrcAddrs128",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.X64.Decls.validDstAddrs128",
"Vale.X64.Decls.buffer_disjoints128",
"Prims.Cons",
"Prims.Nil",
"Vale.X64.Decls.buffers_disjoint128",
"Prims.op_Multiply",
"Vale.X64.Machine_s.pow2_64",
"Vale.X64.Decls.buffer_length",
"Vale.X64.Memory.vuint128",
"Prims.nat",
"Vale.X64.Machine_s.pow2_32",
"Vale.X64.Memory.buffer_addr",
"Prims.op_Modulus",
"Prims.op_GreaterThan",
"Vale.X64.Decls.va_mul_nat",
"Prims.op_Division",
"Vale.AES.X64.GCMdecryptOpt.aes_reqs",
"Vale.X64.Decls.buffer128_as_seq",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"Vale.AES.OptPublic.hkeys_reqs_pub",
"Vale.X64.Decls.s128",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.quad32",
"Vale.AES.GCM_s.compute_iv_BE",
"Vale.X64.Decls.buffer128_read",
"Vale.X64.Decls.va_int_range",
"Vale.X64.Decls.va_if",
"Vale.X64.Stack_i.load_stack64",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.Def.Types_s.nat64",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Prims.l_Forall",
"Vale.X64.InsBasic.vale_heap",
"Vale.X64.Decls.quad32",
"Vale.Arch.HeapImpl.vale_heap_layout",
"Vale.X64.Flags.t",
"Vale.X64.InsBasic.vale_stack",
"Vale.X64.Memory.memtaint",
"Vale.X64.Decls.modifies_mem",
"Vale.X64.Decls.loc_union",
"Vale.X64.Decls.loc_buffer",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"Vale.AES.AES_common_s.is_aes_key",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"FStar.Pervasives.Native.__proj__Mktuple2__item___1",
"Vale.AES.GCM_s.gcm_decrypt_LE",
"Prims.op_Equality",
"Vale.X64.Machine_s.rRax",
"FStar.Pervasives.Native.__proj__Mktuple2__item___2",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Decls.va_get_xmm",
"Vale.Def.Words_s.nat8",
"Vale.Def.Types_s.le_quad32_to_bytes",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"FStar.Seq.Base.append",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_stackTaint",
"Vale.X64.Decls.va_upd_stack",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_mem_layout",
"Vale.X64.Decls.va_upd_mem_heaplet",
"Vale.X64.Decls.va_upd_xmm",
"Vale.X64.Decls.va_upd_reg64",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Decls.va_upd_mem"
] | [] | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
let aes_reqs
(alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128)
(key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0
=
aesni_enabled /\ avx_enabled /\
(alg = AES_128 \/ alg = AES_256) /\
is_aes_key_LE alg key /\
length(round_keys) == nr(alg) + 1 /\
round_keys == key_to_round_keys_LE alg key /\
validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\
s128 heap0 keys_b == round_keys
#reset-options "--z3rlimit 100 --max_ifuel 0"
//-- Gcm_blocks_decrypt_stdcall
val va_code_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_code
val va_codegen_success_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_pbool
let va_req_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) : prop =
(va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok va_s0 /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 ==
len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem
va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem
va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128
tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b])
/\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128
scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b;
out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b;
abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv)))
let va_ens_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) (va_sM:va_state) (va_fM:va_fuel) : prop =
(va_req_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b iv
hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM
(va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout
va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3
va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM
(va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM
(va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15
va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM
(va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks_decrypt_stdcall : va_b0:va_code -> va_s0:va_state -> win:bool ->
alg:algorithm -> auth_b:buffer128 -> auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 ->
iv_b:buffer128 -> iv:supported_iv_LE -> hkeys_b:buffer128 -> abytes_b:buffer128 ->
in128x6_b:buffer128 -> out128x6_b:buffer128 -> len128x6_num:nat64 -> in128_b:buffer128 ->
out128_b:buffer128 -> len128_num:nat64 -> inout_b:buffer128 -> cipher_num:nat64 ->
scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq nat32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok
va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx
va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0
18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in
let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 ==
len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem
va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem
va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128
tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b])
/\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128
scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b;
out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b;
abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM
(va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout
va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3
va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM
(va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM
(va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15
va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM
(va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))))))
[@ va_qattr]
let va_wp_Gcm_blocks_decrypt_stdcall (win:bool) (alg:algorithm) (auth_b:buffer128)
(auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128)
(len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64)
(inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32)) | false | true | Vale.AES.X64.GCMdecryptOpt.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_Gcm_blocks_decrypt_stdcall
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.AES.X64.GCMdecryptOpt.va_wp_Gcm_blocks_decrypt_stdcall | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
win: Prims.bool ->
alg: Vale.AES.AES_common_s.algorithm ->
auth_b: Vale.X64.Memory.buffer128 ->
auth_bytes: Vale.X64.Memory.nat64 ->
auth_num: Vale.X64.Memory.nat64 ->
keys_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
hkeys_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
len128x6_num: Vale.X64.Memory.nat64 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
len128_num: Vale.X64.Memory.nat64 ->
inout_b: Vale.X64.Memory.buffer128 ->
cipher_num: Vale.X64.Memory.nat64 ->
scratch_b: Vale.X64.Memory.buffer128 ->
tag_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 79,
"end_line": 813,
"start_col": 2,
"start_line": 562
} |
FStar.HyperStack.ST.Stack | val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit
(requires fun h ->
live h y1 /\ live h z1 /\ live h z3 /\
live h yy /\ live h tmp /\
disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\
disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\
disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\
inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\
feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\
inv_lazy_reduced2 h1 z3) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let calc_z3 y1 z1 z3 yy tmp =
fmul tmp yy y1; //tmp = yy*y
fmul z3 tmp z1; //z3 = tmp*z = yy*y*z
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 x3);
//assert (inv_lazy_reduced2 h1 tmp);
//assert (inv_lazy_reduced2 h1 z3);
fmul_8_normalize_weak z3 z3 | val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit
(requires fun h ->
live h y1 /\ live h z1 /\ live h z3 /\
live h yy /\ live h tmp /\
disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\
disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\
disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\
inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\
feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\
inv_lazy_reduced2 h1 z3)
let calc_z3 y1 z1 z3 yy tmp = | true | null | false | fmul tmp yy y1;
fmul z3 tmp z1;
let h1 = ST.get () in
fmul_8_normalize_weak z3 z3 | {
"checked_file": "Hacl.Impl.K256.PointDouble.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.K256.PointDouble.fst"
} | [] | [
"Hacl.K256.Field.felem",
"Hacl.K256.Field.fmul_8_normalize_weak",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fmul"
] | [] | module Hacl.Impl.K256.PointDouble
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 300 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit
(requires fun h ->
live h y1 /\ live h z1 /\ live h z3 /\
live h yy /\ live h tmp /\
disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\
disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\
disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\
inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\
feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\
inv_lazy_reduced2 h1 z3) | false | false | Hacl.Impl.K256.PointDouble.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit
(requires fun h ->
live h y1 /\ live h z1 /\ live h z3 /\
live h yy /\ live h tmp /\
disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\
disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\
disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\
inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\
feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\
inv_lazy_reduced2 h1 z3) | [] | Hacl.Impl.K256.PointDouble.calc_z3 | {
"file_name": "code/k256/Hacl.Impl.K256.PointDouble.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
y1: Hacl.K256.Field.felem ->
z1: Hacl.K256.Field.felem ->
z3: Hacl.K256.Field.felem ->
yy: Hacl.K256.Field.felem ->
tmp: Hacl.K256.Field.felem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 42,
"start_col": 2,
"start_line": 35
} |
FStar.HyperStack.ST.Stack | val calc_y3 (y3 tmp: felem) : Stack unit
(requires fun h ->
live h y3 /\ live h tmp /\ disjoint y3 tmp /\
inv_lazy_reduced2 h y3 /\ inv_lazy_reduced2 h tmp)
(ensures fun h0 _ h1 -> modifies (loc y3) h0 h1 /\
feval h1 y3 = S.fadd (feval h0 tmp) (S.fmul (S.fmul 24 S.b) (feval h0 y3))/\
inv_lazy_reduced2 h1 y3) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let calc_y3 y3 tmp =
let h0 = ST.get () in
fmul_small_num y3 y3 (u64 168); //y3 = t = (24*b)*y3 = (24*b)*yy_zz
let h1 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 168 (as_felem5 h0 y3) (u64 168);
//assert (felem_fits5 (as_felem5 h1 y3) (168,168,168,168,336));
fadd y3 tmp y3; //y3 = tmp+y3 = yy_m_bzz9*yy_p_bzz3+t
let h2 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (168,168,168,168,336) (as_felem5 h0 tmp) (as_felem5 h1 y3);
//assert (felem_fits5 (as_felem5 h2 y3) (169,169,169,169,338));
fnormalize_weak y3 y3;
BL.normalize_weak5_lemma (169,169,169,169,338) (as_felem5 h2 y3) | val calc_y3 (y3 tmp: felem) : Stack unit
(requires fun h ->
live h y3 /\ live h tmp /\ disjoint y3 tmp /\
inv_lazy_reduced2 h y3 /\ inv_lazy_reduced2 h tmp)
(ensures fun h0 _ h1 -> modifies (loc y3) h0 h1 /\
feval h1 y3 = S.fadd (feval h0 tmp) (S.fmul (S.fmul 24 S.b) (feval h0 y3))/\
inv_lazy_reduced2 h1 y3)
let calc_y3 y3 tmp = | true | null | false | let h0 = ST.get () in
fmul_small_num y3 y3 (u64 168);
let h1 = ST.get () in
BL.fmul15_lemma (1, 1, 1, 1, 2) 168 (as_felem5 h0 y3) (u64 168);
fadd y3 tmp y3;
let h2 = ST.get () in
BL.fadd5_lemma (1, 1, 1, 1, 2) (168, 168, 168, 168, 336) (as_felem5 h0 tmp) (as_felem5 h1 y3);
fnormalize_weak y3 y3;
BL.normalize_weak5_lemma (169, 169, 169, 169, 338) (as_felem5 h2 y3) | {
"checked_file": "Hacl.Impl.K256.PointDouble.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.K256.PointDouble.fst"
} | [] | [
"Hacl.K256.Field.felem",
"Hacl.Spec.K256.Field52.Lemmas.normalize_weak5_lemma",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Hacl.K256.Field.as_felem5",
"Prims.unit",
"Hacl.K256.Field.fnormalize_weak",
"Hacl.Spec.K256.Field52.Lemmas.fadd5_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fadd",
"Hacl.Spec.K256.Field52.Lemmas.fmul15_lemma",
"Lib.IntTypes.u64",
"Hacl.K256.Field.fmul_small_num"
] | [] | module Hacl.Impl.K256.PointDouble
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 300 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit
(requires fun h ->
live h y1 /\ live h z1 /\ live h z3 /\
live h yy /\ live h tmp /\
disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\
disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\
disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\
inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\
feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\
inv_lazy_reduced2 h1 z3)
let calc_z3 y1 z1 z3 yy tmp =
fmul tmp yy y1; //tmp = yy*y
fmul z3 tmp z1; //z3 = tmp*z = yy*y*z
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 x3);
//assert (inv_lazy_reduced2 h1 tmp);
//assert (inv_lazy_reduced2 h1 z3);
fmul_8_normalize_weak z3 z3 //z3 = z3*8=yy*y*z*8
inline_for_extraction noextract
val calc_bzz9_tmp (yy zz bzz3 bzz9 tmp:felem) : Stack unit
(requires fun h ->
live h yy /\ live h zz /\ live h bzz3 /\ live h bzz9 /\ live h tmp /\
disjoint yy zz /\ disjoint yy bzz3 /\ disjoint yy bzz9 /\
disjoint yy tmp /\ disjoint zz bzz3 /\ disjoint zz bzz9 /\
disjoint zz tmp /\ disjoint bzz3 bzz9 /\ disjoint bzz3 tmp /\
disjoint bzz9 tmp /\
inv_lazy_reduced2 h yy /\ inv_lazy_reduced2 h zz)
(ensures fun h0 _ h1 ->
modifies (loc bzz3 |+| loc bzz9 |+| loc tmp) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 bzz9 = S.fsub (feval h0 yy) (S.fmul 3 bzz3) /\
feval h1 tmp = S.fmul (feval h1 bzz9) (S.fadd (feval h0 yy) bzz3) /\
inv_lazy_reduced2 h1 tmp /\ felem_fits5 (as_felem5 h1 bzz9) (13,13,13,13,14)))
let calc_bzz9_tmp yy zz bzz3 bzz9 tmp =
fmul_3b_normalize_weak bzz3 zz; //bzz3 = (3*b)*zz
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 bzz3);
fmul_small_num bzz9 bzz3 (u64 3); //bzz9 = 3*bzz3
let h2 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 3 (as_felem5 h1 bzz3) (u64 3);
//assert (felem_fits5 (as_felem5 h2 bzz9) (3,3,3,3,6));
BL.fsub5_lemma (1,1,1,1,2) (3,3,3,3,6) (as_felem5 h1 yy) (as_felem5 h2 bzz9) (u64 6);
fsub bzz9 yy bzz9 (u64 6); //bzz9 = yy_m_bzz9 = yy-bzz9
let h3 = ST.get () in
//assert (felem_fits5 (as_felem5 h3 bzz9) (13,13,13,13,14));
fadd tmp yy bzz3; //tmp = yy_p_bzz3 = yy+bzz3
let h4 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 yy) (as_felem5 h1 bzz3);
//assert (felem_fits5 (as_felem5 h4 tmp) (2,2,2,2,4));
fmul tmp bzz9 tmp //tmp = bzz9*tmp = yy_m_bzz9*yy_p_bzz3
inline_for_extraction noextract
val calc_y3 (y3 tmp: felem) : Stack unit
(requires fun h ->
live h y3 /\ live h tmp /\ disjoint y3 tmp /\
inv_lazy_reduced2 h y3 /\ inv_lazy_reduced2 h tmp)
(ensures fun h0 _ h1 -> modifies (loc y3) h0 h1 /\
feval h1 y3 = S.fadd (feval h0 tmp) (S.fmul (S.fmul 24 S.b) (feval h0 y3))/\
inv_lazy_reduced2 h1 y3) | false | false | Hacl.Impl.K256.PointDouble.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val calc_y3 (y3 tmp: felem) : Stack unit
(requires fun h ->
live h y3 /\ live h tmp /\ disjoint y3 tmp /\
inv_lazy_reduced2 h y3 /\ inv_lazy_reduced2 h tmp)
(ensures fun h0 _ h1 -> modifies (loc y3) h0 h1 /\
feval h1 y3 = S.fadd (feval h0 tmp) (S.fmul (S.fmul 24 S.b) (feval h0 y3))/\
inv_lazy_reduced2 h1 y3) | [] | Hacl.Impl.K256.PointDouble.calc_y3 | {
"file_name": "code/k256/Hacl.Impl.K256.PointDouble.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | y3: Hacl.K256.Field.felem -> tmp: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 66,
"end_line": 105,
"start_col": 20,
"start_line": 93
} |
FStar.HyperStack.ST.Stack | val point_double (out p:point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint out p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_double out p =
push_frame ();
let tmp = create (5ul *! nlimb) (u64 0) in
point_double_no_alloc out p tmp;
pop_frame () | val point_double (out p:point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint out p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p))
let point_double out p = | true | null | false | push_frame ();
let tmp = create (5ul *! nlimb) (u64 0) in
point_double_no_alloc out p tmp;
pop_frame () | {
"checked_file": "Hacl.Impl.K256.PointDouble.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.K256.PointDouble.fst"
} | [] | [
"Hacl.Impl.K256.Point.point",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.K256.PointDouble.point_double_no_alloc",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Hacl.K256.Field.nlimb",
"Lib.Buffer.create",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.K256.PointDouble
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 300 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit
(requires fun h ->
live h y1 /\ live h z1 /\ live h z3 /\
live h yy /\ live h tmp /\
disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\
disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\
disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\
inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\
feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\
inv_lazy_reduced2 h1 z3)
let calc_z3 y1 z1 z3 yy tmp =
fmul tmp yy y1; //tmp = yy*y
fmul z3 tmp z1; //z3 = tmp*z = yy*y*z
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 x3);
//assert (inv_lazy_reduced2 h1 tmp);
//assert (inv_lazy_reduced2 h1 z3);
fmul_8_normalize_weak z3 z3 //z3 = z3*8=yy*y*z*8
inline_for_extraction noextract
val calc_bzz9_tmp (yy zz bzz3 bzz9 tmp:felem) : Stack unit
(requires fun h ->
live h yy /\ live h zz /\ live h bzz3 /\ live h bzz9 /\ live h tmp /\
disjoint yy zz /\ disjoint yy bzz3 /\ disjoint yy bzz9 /\
disjoint yy tmp /\ disjoint zz bzz3 /\ disjoint zz bzz9 /\
disjoint zz tmp /\ disjoint bzz3 bzz9 /\ disjoint bzz3 tmp /\
disjoint bzz9 tmp /\
inv_lazy_reduced2 h yy /\ inv_lazy_reduced2 h zz)
(ensures fun h0 _ h1 ->
modifies (loc bzz3 |+| loc bzz9 |+| loc tmp) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 bzz9 = S.fsub (feval h0 yy) (S.fmul 3 bzz3) /\
feval h1 tmp = S.fmul (feval h1 bzz9) (S.fadd (feval h0 yy) bzz3) /\
inv_lazy_reduced2 h1 tmp /\ felem_fits5 (as_felem5 h1 bzz9) (13,13,13,13,14)))
let calc_bzz9_tmp yy zz bzz3 bzz9 tmp =
fmul_3b_normalize_weak bzz3 zz; //bzz3 = (3*b)*zz
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 bzz3);
fmul_small_num bzz9 bzz3 (u64 3); //bzz9 = 3*bzz3
let h2 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 3 (as_felem5 h1 bzz3) (u64 3);
//assert (felem_fits5 (as_felem5 h2 bzz9) (3,3,3,3,6));
BL.fsub5_lemma (1,1,1,1,2) (3,3,3,3,6) (as_felem5 h1 yy) (as_felem5 h2 bzz9) (u64 6);
fsub bzz9 yy bzz9 (u64 6); //bzz9 = yy_m_bzz9 = yy-bzz9
let h3 = ST.get () in
//assert (felem_fits5 (as_felem5 h3 bzz9) (13,13,13,13,14));
fadd tmp yy bzz3; //tmp = yy_p_bzz3 = yy+bzz3
let h4 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 yy) (as_felem5 h1 bzz3);
//assert (felem_fits5 (as_felem5 h4 tmp) (2,2,2,2,4));
fmul tmp bzz9 tmp //tmp = bzz9*tmp = yy_m_bzz9*yy_p_bzz3
inline_for_extraction noextract
val calc_y3 (y3 tmp: felem) : Stack unit
(requires fun h ->
live h y3 /\ live h tmp /\ disjoint y3 tmp /\
inv_lazy_reduced2 h y3 /\ inv_lazy_reduced2 h tmp)
(ensures fun h0 _ h1 -> modifies (loc y3) h0 h1 /\
feval h1 y3 = S.fadd (feval h0 tmp) (S.fmul (S.fmul 24 S.b) (feval h0 y3))/\
inv_lazy_reduced2 h1 y3)
let calc_y3 y3 tmp =
let h0 = ST.get () in
fmul_small_num y3 y3 (u64 168); //y3 = t = (24*b)*y3 = (24*b)*yy_zz
let h1 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 168 (as_felem5 h0 y3) (u64 168);
//assert (felem_fits5 (as_felem5 h1 y3) (168,168,168,168,336));
fadd y3 tmp y3; //y3 = tmp+y3 = yy_m_bzz9*yy_p_bzz3+t
let h2 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (168,168,168,168,336) (as_felem5 h0 tmp) (as_felem5 h1 y3);
//assert (felem_fits5 (as_felem5 h2 y3) (169,169,169,169,338));
fnormalize_weak y3 y3;
BL.normalize_weak5_lemma (169,169,169,169,338) (as_felem5 h2 y3)
inline_for_extraction noextract
val point_double_no_alloc (out p:point) (tmp:lbuffer uint64 (5ul *! nlimb)) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h tmp /\
eq_or_disjoint out p /\ disjoint out tmp /\ disjoint p tmp /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p))
let point_double_no_alloc out p tmp =
let x1, y1, z1 = getx p, gety p, getz p in
let x3, y3, z3 = getx out, gety out, getz out in
let yy = sub tmp 0ul nlimb in
let zz = sub tmp nlimb nlimb in
let bzz3 = sub tmp (2ul *! nlimb) nlimb in
let bzz9 = sub tmp (3ul *! nlimb) nlimb in
let tmp = sub tmp (4ul *! nlimb) nlimb in
let h0 = ST.get () in
fsqr yy y1; //yy = y*y
fsqr zz z1; //zz = z*z
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 yy);
//assert (inv_lazy_reduced2 h1 zz);
fmul_small_num x3 x1 (u64 2); //x3 = 2*x
let h2 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 2 (as_felem5 h1 x1) (u64 2);
//assert (felem_fits5 (as_felem5 h2 x3) (2,2,2,2,4));
fmul x3 x3 y1; //x3 = xy2 = x3*y = (2*x)*y
calc_z3 y1 z1 z3 yy tmp;
calc_bzz9_tmp yy zz bzz3 bzz9 tmp;
fmul y3 yy zz; //y3 = yy_zz = yy*zz
fmul x3 x3 bzz9; //x3 = x3*bzz9 = xy2*yy_m_bzz9
calc_y3 y3 tmp
val point_double (out p:point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint out p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p)) | false | false | Hacl.Impl.K256.PointDouble.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_double (out p:point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ eq_or_disjoint out p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p)) | [] | Hacl.Impl.K256.PointDouble.point_double | {
"file_name": "code/k256/Hacl.Impl.K256.PointDouble.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | out: Hacl.Impl.K256.Point.point -> p: Hacl.Impl.K256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 159,
"start_col": 2,
"start_line": 156
} |
FStar.HyperStack.ST.Stack | val calc_bzz9_tmp (yy zz bzz3 bzz9 tmp:felem) : Stack unit
(requires fun h ->
live h yy /\ live h zz /\ live h bzz3 /\ live h bzz9 /\ live h tmp /\
disjoint yy zz /\ disjoint yy bzz3 /\ disjoint yy bzz9 /\
disjoint yy tmp /\ disjoint zz bzz3 /\ disjoint zz bzz9 /\
disjoint zz tmp /\ disjoint bzz3 bzz9 /\ disjoint bzz3 tmp /\
disjoint bzz9 tmp /\
inv_lazy_reduced2 h yy /\ inv_lazy_reduced2 h zz)
(ensures fun h0 _ h1 ->
modifies (loc bzz3 |+| loc bzz9 |+| loc tmp) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 bzz9 = S.fsub (feval h0 yy) (S.fmul 3 bzz3) /\
feval h1 tmp = S.fmul (feval h1 bzz9) (S.fadd (feval h0 yy) bzz3) /\
inv_lazy_reduced2 h1 tmp /\ felem_fits5 (as_felem5 h1 bzz9) (13,13,13,13,14))) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let calc_bzz9_tmp yy zz bzz3 bzz9 tmp =
fmul_3b_normalize_weak bzz3 zz; //bzz3 = (3*b)*zz
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 bzz3);
fmul_small_num bzz9 bzz3 (u64 3); //bzz9 = 3*bzz3
let h2 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 3 (as_felem5 h1 bzz3) (u64 3);
//assert (felem_fits5 (as_felem5 h2 bzz9) (3,3,3,3,6));
BL.fsub5_lemma (1,1,1,1,2) (3,3,3,3,6) (as_felem5 h1 yy) (as_felem5 h2 bzz9) (u64 6);
fsub bzz9 yy bzz9 (u64 6); //bzz9 = yy_m_bzz9 = yy-bzz9
let h3 = ST.get () in
//assert (felem_fits5 (as_felem5 h3 bzz9) (13,13,13,13,14));
fadd tmp yy bzz3; //tmp = yy_p_bzz3 = yy+bzz3
let h4 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 yy) (as_felem5 h1 bzz3);
//assert (felem_fits5 (as_felem5 h4 tmp) (2,2,2,2,4));
fmul tmp bzz9 tmp | val calc_bzz9_tmp (yy zz bzz3 bzz9 tmp:felem) : Stack unit
(requires fun h ->
live h yy /\ live h zz /\ live h bzz3 /\ live h bzz9 /\ live h tmp /\
disjoint yy zz /\ disjoint yy bzz3 /\ disjoint yy bzz9 /\
disjoint yy tmp /\ disjoint zz bzz3 /\ disjoint zz bzz9 /\
disjoint zz tmp /\ disjoint bzz3 bzz9 /\ disjoint bzz3 tmp /\
disjoint bzz9 tmp /\
inv_lazy_reduced2 h yy /\ inv_lazy_reduced2 h zz)
(ensures fun h0 _ h1 ->
modifies (loc bzz3 |+| loc bzz9 |+| loc tmp) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 bzz9 = S.fsub (feval h0 yy) (S.fmul 3 bzz3) /\
feval h1 tmp = S.fmul (feval h1 bzz9) (S.fadd (feval h0 yy) bzz3) /\
inv_lazy_reduced2 h1 tmp /\ felem_fits5 (as_felem5 h1 bzz9) (13,13,13,13,14)))
let calc_bzz9_tmp yy zz bzz3 bzz9 tmp = | true | null | false | fmul_3b_normalize_weak bzz3 zz;
let h1 = ST.get () in
fmul_small_num bzz9 bzz3 (u64 3);
let h2 = ST.get () in
BL.fmul15_lemma (1, 1, 1, 1, 2) 3 (as_felem5 h1 bzz3) (u64 3);
BL.fsub5_lemma (1, 1, 1, 1, 2) (3, 3, 3, 3, 6) (as_felem5 h1 yy) (as_felem5 h2 bzz9) (u64 6);
fsub bzz9 yy bzz9 (u64 6);
let h3 = ST.get () in
fadd tmp yy bzz3;
let h4 = ST.get () in
BL.fadd5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (as_felem5 h1 yy) (as_felem5 h1 bzz3);
fmul tmp bzz9 tmp | {
"checked_file": "Hacl.Impl.K256.PointDouble.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.K256.PointDouble.fst"
} | [] | [
"Hacl.K256.Field.felem",
"Hacl.K256.Field.fmul",
"Prims.unit",
"Hacl.Spec.K256.Field52.Lemmas.fadd5_lemma",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Hacl.K256.Field.as_felem5",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fadd",
"Hacl.K256.Field.fsub",
"Lib.IntTypes.u64",
"Hacl.Spec.K256.Field52.Lemmas.fsub5_lemma",
"Hacl.Spec.K256.Field52.Lemmas.fmul15_lemma",
"Hacl.K256.Field.fmul_small_num",
"Hacl.K256.Field.fmul_3b_normalize_weak"
] | [] | module Hacl.Impl.K256.PointDouble
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 300 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit
(requires fun h ->
live h y1 /\ live h z1 /\ live h z3 /\
live h yy /\ live h tmp /\
disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\
disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\
disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\
inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\
feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\
inv_lazy_reduced2 h1 z3)
let calc_z3 y1 z1 z3 yy tmp =
fmul tmp yy y1; //tmp = yy*y
fmul z3 tmp z1; //z3 = tmp*z = yy*y*z
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 x3);
//assert (inv_lazy_reduced2 h1 tmp);
//assert (inv_lazy_reduced2 h1 z3);
fmul_8_normalize_weak z3 z3 //z3 = z3*8=yy*y*z*8
inline_for_extraction noextract
val calc_bzz9_tmp (yy zz bzz3 bzz9 tmp:felem) : Stack unit
(requires fun h ->
live h yy /\ live h zz /\ live h bzz3 /\ live h bzz9 /\ live h tmp /\
disjoint yy zz /\ disjoint yy bzz3 /\ disjoint yy bzz9 /\
disjoint yy tmp /\ disjoint zz bzz3 /\ disjoint zz bzz9 /\
disjoint zz tmp /\ disjoint bzz3 bzz9 /\ disjoint bzz3 tmp /\
disjoint bzz9 tmp /\
inv_lazy_reduced2 h yy /\ inv_lazy_reduced2 h zz)
(ensures fun h0 _ h1 ->
modifies (loc bzz3 |+| loc bzz9 |+| loc tmp) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 bzz9 = S.fsub (feval h0 yy) (S.fmul 3 bzz3) /\
feval h1 tmp = S.fmul (feval h1 bzz9) (S.fadd (feval h0 yy) bzz3) /\
inv_lazy_reduced2 h1 tmp /\ felem_fits5 (as_felem5 h1 bzz9) (13,13,13,13,14))) | false | false | Hacl.Impl.K256.PointDouble.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val calc_bzz9_tmp (yy zz bzz3 bzz9 tmp:felem) : Stack unit
(requires fun h ->
live h yy /\ live h zz /\ live h bzz3 /\ live h bzz9 /\ live h tmp /\
disjoint yy zz /\ disjoint yy bzz3 /\ disjoint yy bzz9 /\
disjoint yy tmp /\ disjoint zz bzz3 /\ disjoint zz bzz9 /\
disjoint zz tmp /\ disjoint bzz3 bzz9 /\ disjoint bzz3 tmp /\
disjoint bzz9 tmp /\
inv_lazy_reduced2 h yy /\ inv_lazy_reduced2 h zz)
(ensures fun h0 _ h1 ->
modifies (loc bzz3 |+| loc bzz9 |+| loc tmp) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 bzz9 = S.fsub (feval h0 yy) (S.fmul 3 bzz3) /\
feval h1 tmp = S.fmul (feval h1 bzz9) (S.fadd (feval h0 yy) bzz3) /\
inv_lazy_reduced2 h1 tmp /\ felem_fits5 (as_felem5 h1 bzz9) (13,13,13,13,14))) | [] | Hacl.Impl.K256.PointDouble.calc_bzz9_tmp | {
"file_name": "code/k256/Hacl.Impl.K256.PointDouble.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
yy: Hacl.K256.Field.felem ->
zz: Hacl.K256.Field.felem ->
bzz3: Hacl.K256.Field.felem ->
bzz9: Hacl.K256.Field.felem ->
tmp: Hacl.K256.Field.felem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 19,
"end_line": 81,
"start_col": 2,
"start_line": 62
} |
FStar.HyperStack.ST.Stack | val point_double_no_alloc (out p:point) (tmp:lbuffer uint64 (5ul *! nlimb)) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h tmp /\
eq_or_disjoint out p /\ disjoint out tmp /\ disjoint p tmp /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_double_no_alloc out p tmp =
let x1, y1, z1 = getx p, gety p, getz p in
let x3, y3, z3 = getx out, gety out, getz out in
let yy = sub tmp 0ul nlimb in
let zz = sub tmp nlimb nlimb in
let bzz3 = sub tmp (2ul *! nlimb) nlimb in
let bzz9 = sub tmp (3ul *! nlimb) nlimb in
let tmp = sub tmp (4ul *! nlimb) nlimb in
let h0 = ST.get () in
fsqr yy y1; //yy = y*y
fsqr zz z1; //zz = z*z
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 yy);
//assert (inv_lazy_reduced2 h1 zz);
fmul_small_num x3 x1 (u64 2); //x3 = 2*x
let h2 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 2 (as_felem5 h1 x1) (u64 2);
//assert (felem_fits5 (as_felem5 h2 x3) (2,2,2,2,4));
fmul x3 x3 y1; //x3 = xy2 = x3*y = (2*x)*y
calc_z3 y1 z1 z3 yy tmp;
calc_bzz9_tmp yy zz bzz3 bzz9 tmp;
fmul y3 yy zz; //y3 = yy_zz = yy*zz
fmul x3 x3 bzz9; //x3 = x3*bzz9 = xy2*yy_m_bzz9
calc_y3 y3 tmp | val point_double_no_alloc (out p:point) (tmp:lbuffer uint64 (5ul *! nlimb)) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h tmp /\
eq_or_disjoint out p /\ disjoint out tmp /\ disjoint p tmp /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p))
let point_double_no_alloc out p tmp = | true | null | false | let x1, y1, z1 = getx p, gety p, getz p in
let x3, y3, z3 = getx out, gety out, getz out in
let yy = sub tmp 0ul nlimb in
let zz = sub tmp nlimb nlimb in
let bzz3 = sub tmp (2ul *! nlimb) nlimb in
let bzz9 = sub tmp (3ul *! nlimb) nlimb in
let tmp = sub tmp (4ul *! nlimb) nlimb in
let h0 = ST.get () in
fsqr yy y1;
fsqr zz z1;
let h1 = ST.get () in
fmul_small_num x3 x1 (u64 2);
let h2 = ST.get () in
BL.fmul15_lemma (1, 1, 1, 1, 2) 2 (as_felem5 h1 x1) (u64 2);
fmul x3 x3 y1;
calc_z3 y1 z1 z3 yy tmp;
calc_bzz9_tmp yy zz bzz3 bzz9 tmp;
fmul y3 yy zz;
fmul x3 x3 bzz9;
calc_y3 y3 tmp | {
"checked_file": "Hacl.Impl.K256.PointDouble.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.K256.PointDouble.fst"
} | [] | [
"Hacl.Impl.K256.Point.point",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.K256.Field.nlimb",
"Hacl.K256.Field.felem",
"Hacl.Impl.K256.PointDouble.calc_y3",
"Prims.unit",
"Hacl.K256.Field.fmul",
"Hacl.Impl.K256.PointDouble.calc_bzz9_tmp",
"Hacl.Impl.K256.PointDouble.calc_z3",
"Hacl.Spec.K256.Field52.Lemmas.fmul15_lemma",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Hacl.K256.Field.as_felem5",
"Lib.IntTypes.u64",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fmul_small_num",
"Hacl.K256.Field.fsqr",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"Hacl.Impl.K256.Point.getz",
"Hacl.Impl.K256.Point.gety",
"Hacl.Impl.K256.Point.getx"
] | [] | module Hacl.Impl.K256.PointDouble
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 300 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit
(requires fun h ->
live h y1 /\ live h z1 /\ live h z3 /\
live h yy /\ live h tmp /\
disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\
disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\
disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\
inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\
feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\
inv_lazy_reduced2 h1 z3)
let calc_z3 y1 z1 z3 yy tmp =
fmul tmp yy y1; //tmp = yy*y
fmul z3 tmp z1; //z3 = tmp*z = yy*y*z
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 x3);
//assert (inv_lazy_reduced2 h1 tmp);
//assert (inv_lazy_reduced2 h1 z3);
fmul_8_normalize_weak z3 z3 //z3 = z3*8=yy*y*z*8
inline_for_extraction noextract
val calc_bzz9_tmp (yy zz bzz3 bzz9 tmp:felem) : Stack unit
(requires fun h ->
live h yy /\ live h zz /\ live h bzz3 /\ live h bzz9 /\ live h tmp /\
disjoint yy zz /\ disjoint yy bzz3 /\ disjoint yy bzz9 /\
disjoint yy tmp /\ disjoint zz bzz3 /\ disjoint zz bzz9 /\
disjoint zz tmp /\ disjoint bzz3 bzz9 /\ disjoint bzz3 tmp /\
disjoint bzz9 tmp /\
inv_lazy_reduced2 h yy /\ inv_lazy_reduced2 h zz)
(ensures fun h0 _ h1 ->
modifies (loc bzz3 |+| loc bzz9 |+| loc tmp) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 bzz9 = S.fsub (feval h0 yy) (S.fmul 3 bzz3) /\
feval h1 tmp = S.fmul (feval h1 bzz9) (S.fadd (feval h0 yy) bzz3) /\
inv_lazy_reduced2 h1 tmp /\ felem_fits5 (as_felem5 h1 bzz9) (13,13,13,13,14)))
let calc_bzz9_tmp yy zz bzz3 bzz9 tmp =
fmul_3b_normalize_weak bzz3 zz; //bzz3 = (3*b)*zz
let h1 = ST.get () in
//assert (inv_lazy_reduced2 h1 bzz3);
fmul_small_num bzz9 bzz3 (u64 3); //bzz9 = 3*bzz3
let h2 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 3 (as_felem5 h1 bzz3) (u64 3);
//assert (felem_fits5 (as_felem5 h2 bzz9) (3,3,3,3,6));
BL.fsub5_lemma (1,1,1,1,2) (3,3,3,3,6) (as_felem5 h1 yy) (as_felem5 h2 bzz9) (u64 6);
fsub bzz9 yy bzz9 (u64 6); //bzz9 = yy_m_bzz9 = yy-bzz9
let h3 = ST.get () in
//assert (felem_fits5 (as_felem5 h3 bzz9) (13,13,13,13,14));
fadd tmp yy bzz3; //tmp = yy_p_bzz3 = yy+bzz3
let h4 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 yy) (as_felem5 h1 bzz3);
//assert (felem_fits5 (as_felem5 h4 tmp) (2,2,2,2,4));
fmul tmp bzz9 tmp //tmp = bzz9*tmp = yy_m_bzz9*yy_p_bzz3
inline_for_extraction noextract
val calc_y3 (y3 tmp: felem) : Stack unit
(requires fun h ->
live h y3 /\ live h tmp /\ disjoint y3 tmp /\
inv_lazy_reduced2 h y3 /\ inv_lazy_reduced2 h tmp)
(ensures fun h0 _ h1 -> modifies (loc y3) h0 h1 /\
feval h1 y3 = S.fadd (feval h0 tmp) (S.fmul (S.fmul 24 S.b) (feval h0 y3))/\
inv_lazy_reduced2 h1 y3)
let calc_y3 y3 tmp =
let h0 = ST.get () in
fmul_small_num y3 y3 (u64 168); //y3 = t = (24*b)*y3 = (24*b)*yy_zz
let h1 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 168 (as_felem5 h0 y3) (u64 168);
//assert (felem_fits5 (as_felem5 h1 y3) (168,168,168,168,336));
fadd y3 tmp y3; //y3 = tmp+y3 = yy_m_bzz9*yy_p_bzz3+t
let h2 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (168,168,168,168,336) (as_felem5 h0 tmp) (as_felem5 h1 y3);
//assert (felem_fits5 (as_felem5 h2 y3) (169,169,169,169,338));
fnormalize_weak y3 y3;
BL.normalize_weak5_lemma (169,169,169,169,338) (as_felem5 h2 y3)
inline_for_extraction noextract
val point_double_no_alloc (out p:point) (tmp:lbuffer uint64 (5ul *! nlimb)) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h tmp /\
eq_or_disjoint out p /\ disjoint out tmp /\ disjoint p tmp /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p)) | false | false | Hacl.Impl.K256.PointDouble.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_double_no_alloc (out p:point) (tmp:lbuffer uint64 (5ul *! nlimb)) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h tmp /\
eq_or_disjoint out p /\ disjoint out tmp /\ disjoint p tmp /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_double (point_eval h0 p)) | [] | Hacl.Impl.K256.PointDouble.point_double_no_alloc | {
"file_name": "code/k256/Hacl.Impl.K256.PointDouble.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
out: Hacl.Impl.K256.Point.point ->
p: Hacl.Impl.K256.Point.point ->
tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 (5ul *! Hacl.K256.Field.nlimb)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 16,
"end_line": 145,
"start_col": 37,
"start_line": 117
} |
Prims.Tot | val write_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (leaf_writer_strong (serialize_bounded_bcvli min max)) | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (leaf_writer_strong (serialize_bounded_bcvli min max))
= leaf_writer_strong_of_serializer32 (serialize32_bounded_bcvli min max) () | val write_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (leaf_writer_strong (serialize_bounded_bcvli min max))
let write_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (leaf_writer_strong (serialize_bounded_bcvli min max)) = | false | null | false | leaf_writer_strong_of_serializer32 (serialize32_bounded_bcvli min max) () | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Low.Base.leaf_writer_strong_of_serializer32",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BCVLI.parse_bounded_bcvli",
"LowParse.Spec.BCVLI.serialize_bounded_bcvli",
"LowParse.Low.BCVLI.serialize32_bounded_bcvli",
"LowParse.Low.Base.leaf_writer_strong"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end
inline_for_extraction
let serialize32_bcvli : serializer32 serialize_bcvli =
fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos
let write_bcvli : leaf_writer_strong serialize_bcvli =
leaf_writer_strong_of_serializer32 serialize32_bcvli ()
let validate_bounded_bcvli'
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 })
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32)))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_bounded_bcvli (U32.v min32) (U32.v max32)) h input (uint64_to_uint32 pos);
parse_bounded_bcvli_eq (U32.v min32) (U32.v max32) (bytes_of_slice_from h input (uint64_to_uint32 pos));
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul && min32 `U32.lte` r && r `U32.lte` max32
then pos1
else if max32 `U32.lt` 253ul
then validator_error_generic
else if r = 253ul
then
if 65536ul `U32.lte` min32
then validator_error_generic
else
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else if max32 `U32.lt` 65536ul
then validator_error_generic
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else validator_error_generic
inline_for_extraction
noextract
let validate_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max })
: Tot (validator (parse_bounded_bcvli min max))
= validate_bounded_bcvli' min32 max32
inline_for_extraction
noextract
let jump_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (jumper (parse_bounded_bcvli min max))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let]
let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
jump_bcvli input pos
inline_for_extraction
noextract
let read_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (leaf_reader (parse_bounded_bcvli min max))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let]
let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
read_bcvli input pos <: bounded_int32 min max
inline_for_extraction
noextract
let serialize32_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (serializer32 (serialize_bounded_bcvli min max))
= fun (x: bounded_int32 min max) #rrel #rel b pos ->
[@inline_let]
let _ = serialize_bounded_bcvli_eq min max x in
serialize32_bcvli x b pos
inline_for_extraction
noextract
let write_bounded_bcvli
(min: nat)
(max: nat { min <= max }) | false | false | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (leaf_writer_strong (serialize_bounded_bcvli min max)) | [] | LowParse.Low.BCVLI.write_bounded_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | min: Prims.nat -> max: Prims.nat{min <= max}
-> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BCVLI.serialize_bounded_bcvli min max) | {
"end_col": 75,
"end_line": 292,
"start_col": 2,
"start_line": 292
} |
Prims.Tot | val serialize32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (serializer32 (serialize_bounded_bcvli min max)) | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let serialize32_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (serializer32 (serialize_bounded_bcvli min max))
= fun (x: bounded_int32 min max) #rrel #rel b pos ->
[@inline_let]
let _ = serialize_bounded_bcvli_eq min max x in
serialize32_bcvli x b pos | val serialize32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (serializer32 (serialize_bounded_bcvli min max))
let serialize32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (serializer32 (serialize_bounded_bcvli min max)) = | false | null | false | fun (x: bounded_int32 min max) #rrel #rel b pos ->
[@@ inline_let ]let _ = serialize_bounded_bcvli_eq min max x in
serialize32_bcvli x b pos | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowStar.Monotonic.Buffer.srel",
"LowParse.Bytes.byte",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.t",
"LowParse.Low.BCVLI.serialize32_bcvli",
"Prims.unit",
"LowParse.Spec.BCVLI.serialize_bounded_bcvli_eq",
"LowParse.Low.Base.serializer32",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bounded_bcvli",
"LowParse.Spec.BCVLI.serialize_bounded_bcvli"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end
inline_for_extraction
let serialize32_bcvli : serializer32 serialize_bcvli =
fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos
let write_bcvli : leaf_writer_strong serialize_bcvli =
leaf_writer_strong_of_serializer32 serialize32_bcvli ()
let validate_bounded_bcvli'
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 })
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32)))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_bounded_bcvli (U32.v min32) (U32.v max32)) h input (uint64_to_uint32 pos);
parse_bounded_bcvli_eq (U32.v min32) (U32.v max32) (bytes_of_slice_from h input (uint64_to_uint32 pos));
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul && min32 `U32.lte` r && r `U32.lte` max32
then pos1
else if max32 `U32.lt` 253ul
then validator_error_generic
else if r = 253ul
then
if 65536ul `U32.lte` min32
then validator_error_generic
else
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else if max32 `U32.lt` 65536ul
then validator_error_generic
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else validator_error_generic
inline_for_extraction
noextract
let validate_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max })
: Tot (validator (parse_bounded_bcvli min max))
= validate_bounded_bcvli' min32 max32
inline_for_extraction
noextract
let jump_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (jumper (parse_bounded_bcvli min max))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let]
let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
jump_bcvli input pos
inline_for_extraction
noextract
let read_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (leaf_reader (parse_bounded_bcvli min max))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let]
let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
read_bcvli input pos <: bounded_int32 min max
inline_for_extraction
noextract
let serialize32_bounded_bcvli
(min: nat)
(max: nat { min <= max }) | false | false | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val serialize32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (serializer32 (serialize_bounded_bcvli min max)) | [] | LowParse.Low.BCVLI.serialize32_bounded_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | min: Prims.nat -> max: Prims.nat{min <= max}
-> LowParse.Low.Base.serializer32 (LowParse.Spec.BCVLI.serialize_bounded_bcvli min max) | {
"end_col": 29,
"end_line": 284,
"start_col": 2,
"start_line": 281
} |
Prims.Tot | val jump_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (jumper (parse_bounded_bcvli min max)) | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (jumper (parse_bounded_bcvli min max))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let]
let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
jump_bcvli input pos | val jump_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (jumper (parse_bounded_bcvli min max))
let jump_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (jumper (parse_bounded_bcvli min max)) = | false | null | false | fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
jump_bcvli input pos | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Low.BCVLI.jump_bcvli",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BCVLI.parse_bounded_bcvli",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowParse.Low.Base.jumper"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end
inline_for_extraction
let serialize32_bcvli : serializer32 serialize_bcvli =
fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos
let write_bcvli : leaf_writer_strong serialize_bcvli =
leaf_writer_strong_of_serializer32 serialize32_bcvli ()
let validate_bounded_bcvli'
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 })
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32)))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_bounded_bcvli (U32.v min32) (U32.v max32)) h input (uint64_to_uint32 pos);
parse_bounded_bcvli_eq (U32.v min32) (U32.v max32) (bytes_of_slice_from h input (uint64_to_uint32 pos));
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul && min32 `U32.lte` r && r `U32.lte` max32
then pos1
else if max32 `U32.lt` 253ul
then validator_error_generic
else if r = 253ul
then
if 65536ul `U32.lte` min32
then validator_error_generic
else
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else if max32 `U32.lt` 65536ul
then validator_error_generic
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else validator_error_generic
inline_for_extraction
noextract
let validate_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max })
: Tot (validator (parse_bounded_bcvli min max))
= validate_bounded_bcvli' min32 max32
inline_for_extraction
noextract
let jump_bounded_bcvli
(min: nat)
(max: nat { min <= max }) | false | false | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (jumper (parse_bounded_bcvli min max)) | [] | LowParse.Low.BCVLI.jump_bounded_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | min: Prims.nat -> max: Prims.nat{min <= max}
-> LowParse.Low.Base.jumper (LowParse.Spec.BCVLI.parse_bounded_bcvli min max) | {
"end_col": 24,
"end_line": 257,
"start_col": 2,
"start_line": 249
} |
Prims.Tot | val validate_bounded_bcvli
(min: nat)
(min32: U32.t{U32.v min32 == min})
(max: nat{min <= max})
(max32: U32.t{U32.v max32 == max})
: Tot (validator (parse_bounded_bcvli min max)) | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max })
: Tot (validator (parse_bounded_bcvli min max))
= validate_bounded_bcvli' min32 max32 | val validate_bounded_bcvli
(min: nat)
(min32: U32.t{U32.v min32 == min})
(max: nat{min <= max})
(max32: U32.t{U32.v max32 == max})
: Tot (validator (parse_bounded_bcvli min max))
let validate_bounded_bcvli
(min: nat)
(min32: U32.t{U32.v min32 == min})
(max: nat{min <= max})
(max32: U32.t{U32.v max32 == max})
: Tot (validator (parse_bounded_bcvli min max)) = | false | null | false | validate_bounded_bcvli' min32 max32 | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"Prims.nat",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"LowParse.Low.BCVLI.validate_bounded_bcvli'",
"LowParse.Low.Base.validator",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BCVLI.parse_bounded_bcvli"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end
inline_for_extraction
let serialize32_bcvli : serializer32 serialize_bcvli =
fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos
let write_bcvli : leaf_writer_strong serialize_bcvli =
leaf_writer_strong_of_serializer32 serialize32_bcvli ()
let validate_bounded_bcvli'
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 })
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32)))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_bounded_bcvli (U32.v min32) (U32.v max32)) h input (uint64_to_uint32 pos);
parse_bounded_bcvli_eq (U32.v min32) (U32.v max32) (bytes_of_slice_from h input (uint64_to_uint32 pos));
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul && min32 `U32.lte` r && r `U32.lte` max32
then pos1
else if max32 `U32.lt` 253ul
then validator_error_generic
else if r = 253ul
then
if 65536ul `U32.lte` min32
then validator_error_generic
else
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else if max32 `U32.lt` 65536ul
then validator_error_generic
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else validator_error_generic
inline_for_extraction
noextract
let validate_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max }) | false | false | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_bounded_bcvli
(min: nat)
(min32: U32.t{U32.v min32 == min})
(max: nat{min <= max})
(max32: U32.t{U32.v max32 == max})
: Tot (validator (parse_bounded_bcvli min max)) | [] | LowParse.Low.BCVLI.validate_bounded_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
min: Prims.nat ->
min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} ->
max: Prims.nat{min <= max} ->
max32: FStar.UInt32.t{FStar.UInt32.v max32 == max}
-> LowParse.Low.Base.validator (LowParse.Spec.BCVLI.parse_bounded_bcvli min max) | {
"end_col": 37,
"end_line": 241,
"start_col": 2,
"start_line": 241
} |
Prims.Tot | val read_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (leaf_reader (parse_bounded_bcvli min max)) | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (leaf_reader (parse_bounded_bcvli min max))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let]
let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
read_bcvli input pos <: bounded_int32 min max | val read_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (leaf_reader (parse_bounded_bcvli min max))
let read_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (leaf_reader (parse_bounded_bcvli min max)) = | false | null | false | fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
read_bcvli input pos <: bounded_int32 min max | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Low.BCVLI.read_bcvli",
"LowParse.Spec.BoundedInt.bounded_int32",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bounded_bcvli",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowParse.Low.Base.leaf_reader"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end
inline_for_extraction
let serialize32_bcvli : serializer32 serialize_bcvli =
fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos
let write_bcvli : leaf_writer_strong serialize_bcvli =
leaf_writer_strong_of_serializer32 serialize32_bcvli ()
let validate_bounded_bcvli'
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 })
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32)))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_bounded_bcvli (U32.v min32) (U32.v max32)) h input (uint64_to_uint32 pos);
parse_bounded_bcvli_eq (U32.v min32) (U32.v max32) (bytes_of_slice_from h input (uint64_to_uint32 pos));
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul && min32 `U32.lte` r && r `U32.lte` max32
then pos1
else if max32 `U32.lt` 253ul
then validator_error_generic
else if r = 253ul
then
if 65536ul `U32.lte` min32
then validator_error_generic
else
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else if max32 `U32.lt` 65536ul
then validator_error_generic
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else validator_error_generic
inline_for_extraction
noextract
let validate_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max })
: Tot (validator (parse_bounded_bcvli min max))
= validate_bounded_bcvli' min32 max32
inline_for_extraction
noextract
let jump_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (jumper (parse_bounded_bcvli min max))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let]
let _ =
valid_facts (parse_bounded_bcvli min max) h input pos;
parse_bounded_bcvli_eq min max (bytes_of_slice_from h input pos);
valid_facts parse_bcvli h input pos
in
jump_bcvli input pos
inline_for_extraction
noextract
let read_bounded_bcvli
(min: nat)
(max: nat { min <= max }) | false | false | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (leaf_reader (parse_bounded_bcvli min max)) | [] | LowParse.Low.BCVLI.read_bounded_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | min: Prims.nat -> max: Prims.nat{min <= max}
-> LowParse.Low.Base.leaf_reader (LowParse.Spec.BCVLI.parse_bounded_bcvli min max) | {
"end_col": 49,
"end_line": 273,
"start_col": 2,
"start_line": 265
} |
Prims.Tot | val write_bcvli:leaf_writer_strong serialize_bcvli | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_bcvli : leaf_writer_strong serialize_bcvli =
leaf_writer_strong_of_serializer32 serialize32_bcvli () | val write_bcvli:leaf_writer_strong serialize_bcvli
let write_bcvli:leaf_writer_strong serialize_bcvli = | false | null | false | leaf_writer_strong_of_serializer32 serialize32_bcvli () | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"LowParse.Low.Base.leaf_writer_strong_of_serializer32",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"FStar.UInt32.t",
"LowParse.Spec.BCVLI.parse_bcvli",
"LowParse.Spec.BCVLI.serialize_bcvli",
"LowParse.Low.BCVLI.serialize32_bcvli"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end
inline_for_extraction
let serialize32_bcvli : serializer32 serialize_bcvli =
fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos | false | true | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_bcvli:leaf_writer_strong serialize_bcvli | [] | LowParse.Low.BCVLI.write_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.leaf_writer_strong LowParse.Spec.BCVLI.serialize_bcvli | {
"end_col": 57,
"end_line": 177,
"start_col": 2,
"start_line": 177
} |
Prims.Tot | val serialize32_bcvli:serializer32 serialize_bcvli | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let serialize32_bcvli : serializer32 serialize_bcvli =
fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos | val serialize32_bcvli:serializer32 serialize_bcvli
let serialize32_bcvli:serializer32 serialize_bcvli = | false | null | false | fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.srel",
"LowParse.Bytes.byte",
"LowStar.Monotonic.Buffer.mbuffer",
"LowParse.Low.BCVLI.serialize32_bcvli'"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end
inline_for_extraction | false | true | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val serialize32_bcvli:serializer32 serialize_bcvli | [] | LowParse.Low.BCVLI.serialize32_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.serializer32 LowParse.Spec.BCVLI.serialize_bcvli | {
"end_col": 63,
"end_line": 174,
"start_col": 2,
"start_line": 174
} |
Prims.Tot | val jump_bcvli:jumper parse_bcvli | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1 | val jump_bcvli:jumper parse_bcvli
let jump_bcvli:jumper parse_bcvli = | false | null | false | fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@@ inline_let ]let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else
if r = 253ul
then jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1 | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.op_Equality",
"LowParse.Low.Base.jump_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Low.BoundedInt.read_bounded_integer_le_1",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.BCVLI.parse_bcvli_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic | false | true | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_bcvli:jumper parse_bcvli | [] | LowParse.Low.BCVLI.jump_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.jumper LowParse.Spec.BCVLI.parse_bcvli | {
"end_col": 69,
"end_line": 79,
"start_col": 2,
"start_line": 60
} |
Prims.Tot | val read_bcvli:leaf_reader parse_bcvli | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t | val read_bcvli:leaf_reader parse_bcvli
let read_bcvli:leaf_reader parse_bcvli = | false | null | false | fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@@ inline_let ]let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.op_Equality",
"LowParse.Low.BoundedInt.read_bounded_integer_le_2",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Low.BoundedInt.read_bounded_integer_le_4",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Low.Base.jump_constant_size",
"LowParse.Low.BoundedInt.read_bounded_integer_le_1",
"LowParse.Spec.BCVLI.parse_bcvli_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1 | false | true | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_bcvli:leaf_reader parse_bcvli | [] | LowParse.Low.BCVLI.read_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.leaf_reader LowParse.Spec.BCVLI.parse_bcvli | {
"end_col": 54,
"end_line": 100,
"start_col": 2,
"start_line": 82
} |
FStar.HyperStack.ST.Stack | val serialize32_bcvli' (x: U32.t) (#rrel #rel: _) (b: B.mbuffer U8.t rrel rel) (pos: U32.t)
: HST.Stack U32.t
(requires
(fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\ U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h))
(ensures
(fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\
(B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\
(Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len))
`Seq.equal`
(serialize serialize_bcvli x)))) | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end | val serialize32_bcvli' (x: U32.t) (#rrel #rel: _) (b: B.mbuffer U8.t rrel rel) (pos: U32.t)
: HST.Stack U32.t
(requires
(fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\ U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h))
(ensures
(fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\
(B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\
(Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len))
`Seq.equal`
(serialize serialize_bcvli x))))
let serialize32_bcvli' (x: U32.t) (#rrel #rel: _) (b: B.mbuffer U8.t rrel rel) (pos: U32.t)
: HST.Stack U32.t
(requires
(fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\ U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h))
(ensures
(fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\
(B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\
(Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len))
`Seq.equal`
(serialize serialize_bcvli x)))) = | true | null | false | serialize_bcvli_eq x;
let c:bounded_integer 1 =
if x `U32.lt` 253ul then x else if x `U32.lt` 65536ul then 253ul else 254ul
in
[@@ inline_let ]let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@@ inline_let ]let _ =
writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1)
in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@@ inline_let ]let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then len1
else
if c = 253ul
then
[@@ inline_let ]let _ = assert (U32.v x < 65536) in
[@@ inline_let ]let _ =
writable_weaken b
(U32.v pos)
(Ghost.reveal pos')
h1
(U32.v pos + U32.v len1)
((U32.v pos + U32.v len1) + 2)
in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@@ inline_let ]let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b
pos
(pos `U32.add` len1)
(B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len))
h1
h';
len
else
[@@ inline_let ]let _ =
writable_weaken b
(U32.v pos)
(Ghost.reveal pos')
h1
(U32.v pos + U32.v len1)
((U32.v pos + U32.v len1) + 4)
in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@@ inline_let ]let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b
pos
(pos `U32.add` len1)
(B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len))
h1
h';
len | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [] | [
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.srel",
"FStar.UInt8.t",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.op_Equality",
"Prims.unit",
"LowStar.Monotonic.Buffer.modifies_buffer_from_to_elim",
"FStar.UInt32.add",
"LowStar.Monotonic.Buffer.loc_buffer_from_to",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowParse.Low.BoundedInt.serialize32_bounded_integer_le_2",
"LowParse.Low.Base.writable_weaken",
"FStar.UInt32.v",
"FStar.Ghost.reveal",
"Prims.nat",
"Prims.op_Addition",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThan",
"LowParse.Low.BoundedInt.serialize32_bounded_integer_le_4",
"LowParse.Low.Base.writable_modifies",
"LowStar.Monotonic.Buffer.loc_none",
"LowParse.Low.BoundedInt.serialize32_bounded_integer_le_1",
"FStar.Ghost.erased",
"FStar.Ghost.hide",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"LowParse.Spec.BCVLI.serialize_bcvli",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BCVLI.serialize_bcvli_eq",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Prims.op_LessThanOrEqual",
"LowStar.Monotonic.Buffer.length",
"LowParse.Low.Base.writable",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"LowStar.Monotonic.Buffer.modifies",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.as_seq"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
))) | false | false | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val serialize32_bcvli' (x: U32.t) (#rrel #rel: _) (b: B.mbuffer U8.t rrel rel) (pos: U32.t)
: HST.Stack U32.t
(requires
(fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\ U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h))
(ensures
(fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\
(B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\
(Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len))
`Seq.equal`
(serialize serialize_bcvli x)))) | [] | LowParse.Low.BCVLI.serialize32_bcvli' | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
x: FStar.UInt32.t ->
b: LowStar.Monotonic.Buffer.mbuffer FStar.UInt8.t rrel rel ->
pos: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack FStar.UInt32.t | {
"end_col": 5,
"end_line": 170,
"start_col": 4,
"start_line": 128
} |
Prims.Tot | val validate_bcvli:validator parse_bcvli | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic | val validate_bcvli:validator parse_bcvli
let validate_bcvli:validator parse_bcvli = | false | null | false | fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@@ inline_let ]let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else
if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul then validator_error_generic else pos2
else
if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul then validator_error_generic else pos2
else validator_error_generic | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt64.t",
"LowParse.Low.ErrorCode.is_error",
"Prims.bool",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"Prims.op_Equality",
"FStar.UInt32.t",
"LowParse.Low.ErrorCode.validator_error_generic",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Low.BoundedInt.read_bounded_integer_le_2",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"LowParse.Low.Base.validate_total_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"FStar.UInt64.__uint_to_t",
"LowParse.Low.BoundedInt.read_bounded_integer_le_4",
"LowParse.Low.BoundedInt.read_bounded_integer_le_1",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.BCVLI.parse_bcvli_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16" | false | true | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_bcvli:validator parse_bcvli | [] | LowParse.Low.BCVLI.validate_bcvli | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.validator LowParse.Spec.BCVLI.parse_bcvli | {
"end_col": 32,
"end_line": 57,
"start_col": 2,
"start_line": 17
} |
Prims.Tot | val validate_bounded_bcvli' (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32})
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32))) | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_bounded_bcvli'
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 })
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32)))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_bounded_bcvli (U32.v min32) (U32.v max32)) h input (uint64_to_uint32 pos);
parse_bounded_bcvli_eq (U32.v min32) (U32.v max32) (bytes_of_slice_from h input (uint64_to_uint32 pos));
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul && min32 `U32.lte` r && r `U32.lte` max32
then pos1
else if max32 `U32.lt` 253ul
then validator_error_generic
else if r = 253ul
then
if 65536ul `U32.lte` min32
then validator_error_generic
else
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else if max32 `U32.lt` 65536ul
then validator_error_generic
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else validator_error_generic | val validate_bounded_bcvli' (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32})
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32)))
let validate_bounded_bcvli' (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32})
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32))) = | false | null | false | fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts (parse_bounded_bcvli (U32.v min32) (U32.v max32)) h input (uint64_to_uint32 pos);
parse_bounded_bcvli_eq (U32.v min32)
(U32.v max32)
(bytes_of_slice_from h input (uint64_to_uint32 pos));
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@@ inline_let ]let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul && min32 `U32.lte` r && r `U32.lte` max32
then pos1
else
if max32 `U32.lt` 253ul
then validator_error_generic
else
if r = 253ul
then
if 65536ul `U32.lte` min32
then validator_error_generic
else
let pos2 =
validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1
in
if is_error pos2
then pos2
else
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else
if max32 `U32.lt` 65536ul
then validator_error_generic
else
if r = 254ul
then
let pos2 =
validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1
in
if is_error pos2
then pos2
else
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul || r `U32.lt` min32 || max32 `U32.lt` r
then validator_error_generic
else pos2
else validator_error_generic | {
"checked_file": "LowParse.Low.BCVLI.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.BCVLI.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt64.t",
"LowParse.Low.ErrorCode.is_error",
"Prims.bool",
"Prims.op_AmpAmp",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.lte",
"LowParse.Low.ErrorCode.validator_error_generic",
"Prims.op_Equality",
"Prims.op_BarBar",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Low.BoundedInt.read_bounded_integer_le_2",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"LowParse.Low.Base.validate_total_constant_size",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"FStar.UInt64.__uint_to_t",
"LowParse.Low.BoundedInt.read_bounded_integer_le_4",
"LowParse.Low.BoundedInt.read_bounded_integer_le_1",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.BCVLI.parse_bcvli_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_eq",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BCVLI.parse_bounded_bcvli",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowParse.Low.Base.validator"
] | [] | module LowParse.Low.BCVLI
include LowParse.Spec.BCVLI
include LowParse.Low.Combinators
include LowParse.Low.BoundedInt
module B = LowStar.Buffer
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U32 = FStar.UInt32
module U64 = FStar.UInt64
#reset-options "--z3cliopt smt.arith.nl=false --max_fuel 0"
#push-options "--z3rlimit 16"
let validate_bcvli : validator parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input (uint64_to_uint32 pos);
parse_bcvli_eq (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts (parse_bounded_integer_le 1) h input (uint64_to_uint32 pos)
in
let pos1 = validate_total_constant_size (parse_bounded_integer_le 1) 1uL () input pos in
if is_error pos1
then pos1
else
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input (uint64_to_uint32 pos1);
valid_facts (parse_bounded_integer_le 4) h input (uint64_to_uint32 pos1)
in
let r = read_bounded_integer_le_1 input (uint64_to_uint32 pos) in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 2) 2uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_2 input (uint64_to_uint32 pos1) in
if r `U32.lt` 253ul
then validator_error_generic
else pos2
else if r = 254ul
then
let pos2 = validate_total_constant_size (parse_bounded_integer_le 4) 4uL () input pos1 in
if is_error pos2
then pos2
else
(* because of the non-malleability constraint, I need to actually read the value and check whether it is not a lower integer *)
let r = read_bounded_integer_le_4 input (uint64_to_uint32 pos1) in
if r `U32.lt` 65536ul
then validator_error_generic
else pos2
else validator_error_generic
let jump_bcvli : jumper parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then pos1
else if r = 253ul
then
jump_constant_size (parse_bounded_integer_le 2) 2ul () input pos1
else
jump_constant_size (parse_bounded_integer_le 4) 4ul () input pos1
let read_bcvli : leaf_reader parse_bcvli =
fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts parse_bcvli h input pos;
parse_bcvli_eq (bytes_of_slice_from h input pos);
valid_facts (parse_bounded_integer_le 1) h input pos
in
let r = read_bounded_integer_le_1 input pos in
if r `U32.lt` 253ul
then (r <: U32.t)
else
let pos1 = jump_constant_size (parse_bounded_integer_le 1) 1ul () input pos in
[@inline_let] let _ =
valid_facts (parse_bounded_integer_le 2) h input pos1;
valid_facts (parse_bounded_integer_le 4) h input pos1
in
if r = 253ul
then read_bounded_integer_le_2 input pos1 <: U32.t
else read_bounded_integer_le_4 input pos1 <: U32.t
#pop-options
module U8 = FStar.UInt8
#push-options "--z3rlimit 32"
inline_for_extraction
let serialize32_bcvli'
(x: U32.t)
(#rrel #rel: _)
(b: B.mbuffer U8.t rrel rel)
(pos: U32.t)
: HST.Stack U32.t
(requires (fun h ->
let len = Seq.length (serialize serialize_bcvli x) in
B.live h b /\
U32.v pos + len <= B.length b /\
writable b (U32.v pos) (U32.v pos + len) h
))
(ensures (fun h len h' ->
Seq.length (serialize serialize_bcvli x) == U32.v len /\ (
B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\
B.live h b /\
Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` serialize serialize_bcvli x
)))
= // [@inline_let] let _ =
serialize_bcvli_eq x
; // in
let c : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
[@inline_let]
let pos' = Ghost.hide (U32.v pos + Seq.length (serialize serialize_bcvli x)) in
let h = HST.get () in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h (U32.v pos) (U32.v pos + 1) in
let len1 = serialize32_bounded_integer_le_1 c b pos in
let h1 = HST.get () in
[@inline_let]
let _ = writable_modifies b (U32.v pos) (Ghost.reveal pos') h B.loc_none h1 in
if c `U32.lt` 253ul
then begin
len1
end else if c = 253ul
then begin
[@inline_let]
let _ = assert (U32.v x < 65536) in
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 2) in
let len2 = serialize32_bounded_integer_le_2 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end else begin
[@inline_let]
let _ = writable_weaken b (U32.v pos) (Ghost.reveal pos') h1 (U32.v pos + U32.v len1) ((U32.v pos + U32.v len1) + 4) in
let len2 = serialize32_bounded_integer_le_4 x b (pos `U32.add` len1) in
let h' = HST.get () in
[@inline_let]
let len = len1 `U32.add` len2 in
B.modifies_buffer_from_to_elim b pos (pos `U32.add` len1) (B.loc_buffer_from_to b (pos `U32.add` len1) (pos `U32.add` len)) h1 h';
len
end
inline_for_extraction
let serialize32_bcvli : serializer32 serialize_bcvli =
fun (x: U32.t) #rrel #rel b pos -> serialize32_bcvli' x b pos
let write_bcvli : leaf_writer_strong serialize_bcvli =
leaf_writer_strong_of_serializer32 serialize32_bcvli ()
let validate_bounded_bcvli'
(min32: U32.t)
(max32: U32.t { U32.v min32 <= U32.v max32 }) | false | false | LowParse.Low.BCVLI.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_bounded_bcvli' (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32})
: Tot (validator (parse_bounded_bcvli (U32.v min32) (U32.v max32))) | [] | LowParse.Low.BCVLI.validate_bounded_bcvli' | {
"file_name": "src/lowparse/LowParse.Low.BCVLI.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | min32: FStar.UInt32.t -> max32: FStar.UInt32.t{FStar.UInt32.v min32 <= FStar.UInt32.v max32}
-> LowParse.Low.Base.validator (LowParse.Spec.BCVLI.parse_bounded_bcvli (FStar.UInt32.v min32)
(FStar.UInt32.v max32)) | {
"end_col": 32,
"end_line": 231,
"start_col": 2,
"start_line": 183
} |
Prims.GTot | val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_region_of #_ v = V.frameOf v | val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = | false | null | false | V.frameOf v | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"sometrivial"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash_vec",
"LowStar.Vector.frameOf",
"MerkleTree.Low.Datastructures.hash",
"FStar.Monotonic.HyperHeap.rid"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid | [] | MerkleTree.Low.Datastructures.hash_vec_region_of | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | v: MerkleTree.Low.Datastructures.hash_vec -> Prims.GTot FStar.Monotonic.HyperHeap.rid | {
"end_col": 41,
"end_line": 202,
"start_col": 30,
"start_line": 202
} |
Prims.GTot | val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0 | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz | val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v = | false | null | false | B.live h v /\ B.freeable v /\ B.len v = hsz | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"sometrivial"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.Low.Datastructures.hash",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.freeable",
"Prims.b2t",
"Prims.op_Equality",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.len"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0 | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0 | [] | MerkleTree.Low.Datastructures.hash_r_inv | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | h: FStar.Monotonic.HyperStack.mem -> v: MerkleTree.Low.Datastructures.hash -> Prims.GTot Type0 | {
"end_col": 15,
"end_line": 63,
"start_col": 2,
"start_line": 62
} |
Prims.GTot | val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_region_of #_ v = B.frameOf v | val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = | false | null | false | B.frameOf v | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"sometrivial"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash",
"LowStar.Monotonic.Buffer.frameOf",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"FStar.Monotonic.HyperHeap.rid"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid | [] | MerkleTree.Low.Datastructures.hash_region_of | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | v: MerkleTree.Low.Datastructures.hash -> Prims.GTot FStar.Monotonic.HyperHeap.rid | {
"end_col": 37,
"end_line": 52,
"start_col": 26,
"start_line": 52
} |
Prims.GTot | val hash_vec_r_alloc_p: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot Type0 | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_r_alloc_p #_ v = V.size_of v = 0ul | val hash_vec_r_alloc_p: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_alloc_p #_ v = | false | null | false | V.size_of v = 0ul | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"sometrivial"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash_vec",
"Prims.b2t",
"Prims.op_Equality",
"FStar.UInt32.t",
"LowStar.Vector.size_of",
"MerkleTree.Low.Datastructures.hash",
"FStar.UInt32.__uint_to_t"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v =
RV.as_seq h v
noextract
val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v))
let hash_vec_r_sep #_ v p h0 h1 =
RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1
noextract
val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz)
let hash_vec_irepr #_ = Ghost.hide S.empty
noextract | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_r_alloc_p: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot Type0 | [] | MerkleTree.Low.Datastructures.hash_vec_r_alloc_p | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | v: MerkleTree.Low.Datastructures.hash_vec -> Prims.GTot Type0 | {
"end_col": 47,
"end_line": 253,
"start_col": 30,
"start_line": 253
} |
Prims.Tot | val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_dummy #_ = V.alloc_empty (hash #_) | val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = | false | null | false | V.alloc_empty (hash #_) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"MerkleTree.Low.Datastructures.hash_size_t",
"LowStar.Vector.alloc_empty",
"MerkleTree.Low.Datastructures.hash",
"FStar.Ghost.reveal",
"MerkleTree.Low.Datastructures.hash_vec"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz | [] | MerkleTree.Low.Datastructures.hash_vec_dummy | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | MerkleTree.Low.Datastructures.hash_vec | {
"end_col": 47,
"end_line": 206,
"start_col": 24,
"start_line": 206
} |
Prims.GTot | val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0 | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_r_alloc_p #_ v = True | val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = | false | null | false | True | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"sometrivial"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash",
"Prims.l_True"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0 | [] | MerkleTree.Low.Datastructures.hash_r_alloc_p | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | v: MerkleTree.Low.Datastructures.hash -> Prims.GTot Type0 | {
"end_col": 30,
"end_line": 112,
"start_col": 26,
"start_line": 112
} |
Prims.Tot | val hvvreg (hsz:hash_size_t): regional (regional hash_size_t (hash_vec #hsz)) (hash_vv hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hvvreg hsz = RVI.vector_regional (hvreg hsz) | val hvvreg (hsz:hash_size_t): regional (regional hash_size_t (hash_vec #hsz)) (hash_vv hsz)
let hvvreg hsz = | false | null | false | RVI.vector_regional (hvreg hsz) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"LowStar.Regional.Instances.vector_regional",
"MerkleTree.Low.Datastructures.hash_vec",
"MerkleTree.Low.Datastructures.hvreg",
"LowStar.Regional.regional",
"MerkleTree.Low.Datastructures.hash_vv"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v =
RV.as_seq h v
noextract
val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v))
let hash_vec_r_sep #_ v p h0 h1 =
RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1
noextract
val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz)
let hash_vec_irepr #_ = Ghost.hide S.empty
noextract
val hash_vec_r_alloc_p: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_alloc_p #_ v = V.size_of v = 0ul
#push-options "--initial_fuel 1 --max_fuel 1"
val hash_vec_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash_vec #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_vec_r_alloc_p v /\
hash_vec_r_inv h1 v /\
hash_vec_region_of v = r /\
hash_vec_r_repr h1 v == Ghost.reveal hash_vec_irepr /\
B.fresh_loc (V.loc_vector v) h0 h1))
let hash_vec_r_alloc #_ hsz r =
let nrid = HST.new_region r in
// Note: here we are not creating a generic parameterized regional, we are
// creating a specialized regional vector of hashes, so we don't need to go
// through a run-time indirection to figure out what the dummy default element
// is; we know it's the one for hashes
V.alloc_reserve 1ul (hash_dummy #hsz) r
#pop-options
val hash_vec_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash_vec #hsz ->
HST.ST unit
(requires (fun h0 -> hash_vec_r_inv h0 v))
(ensures (fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_vec_region_of #hsz v)) h0 h1))
let hash_vec_r_free #_ hsz v =
RV.free v
/// This is nice because the only piece of state that we are keeping is one
/// word, the hash size, since we are implementing a specialized instance of
/// RVector over hashes of a known length. We could also, for genericity, make
/// this a mere application of RVector over hreg, which would be less
/// implementation effort, at the expense of a bigger run-time cost since there
/// would be extra space in the struct (which is passed by value!) and also a
/// run-time indirection to do the lookup of the type class instance for the
/// elements of the rvector.
noextract inline_for_extraction
val hvreg (hsz:hash_size_t): regional hash_size_t (hash_vec #hsz)
let hvreg hsz =
Rgl hsz
(hash_vec_region_of #hsz)
V.loc_vector
(hash_vec_dummy #hsz)
(hash_vec_r_inv #hsz)
(hash_vec_r_inv_reg #hsz)
(hash_vec_repr #hsz)
(hash_vec_r_repr #hsz)
(hash_vec_r_sep #hsz)
(hash_vec_irepr #hsz)
(hash_vec_r_alloc_p #hsz)
(hash_vec_r_alloc #hsz)
(hash_vec_r_free #hsz)
/// 3. A vector of hash vectors is also regional
type hash_vv (hsz:hash_size_t) = RV.rvector (hvreg hsz)
noextract inline_for_extraction | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hvvreg (hsz:hash_size_t): regional (regional hash_size_t (hash_vec #hsz)) (hash_vv hsz) | [] | MerkleTree.Low.Datastructures.hvvreg | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | hsz: MerkleTree.Low.Datastructures.hash_size_t
-> LowStar.Regional.regional (LowStar.Regional.regional MerkleTree.Low.Datastructures.hash_size_t
MerkleTree.Low.Datastructures.hash_vec)
(MerkleTree.Low.Datastructures.hash_vv hsz) | {
"end_col": 48,
"end_line": 322,
"start_col": 17,
"start_line": 322
} |
Prims.GTot | val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0 | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_r_inv #hsz h v = RV.rv_inv h v | val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = | false | null | false | RV.rv_inv h v | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"sometrivial"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.Low.Datastructures.hash_vec",
"LowStar.RVector.rv_inv",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hreg"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0 | [] | MerkleTree.Low.Datastructures.hash_vec_r_inv | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | h: FStar.Monotonic.HyperStack.mem -> v: MerkleTree.Low.Datastructures.hash_vec -> Prims.GTot Type0 | {
"end_col": 43,
"end_line": 210,
"start_col": 30,
"start_line": 210
} |
Prims.Tot | val hash_repr (#hsz:hash_size_t): Type0 | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_repr #hsz = MTH.hash #(U32.v hsz) | val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = | false | null | false | MTH.hash #(U32.v hsz) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.New.High.hash",
"FStar.UInt32.v"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract | false | true | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_repr (#hsz:hash_size_t): Type0 | [] | MerkleTree.Low.Datastructures.hash_repr | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | Type0 | {
"end_col": 42,
"end_line": 77,
"start_col": 21,
"start_line": 77
} |
Prims.Tot | val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hcpy hsz =
Cpy (hash_copy #hsz) | val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz = | false | null | false | Cpy (hash_copy #hsz) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"LowStar.RVector.Cpy",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hreg",
"MerkleTree.Low.Datastructures.hash_copy",
"FStar.Ghost.hide",
"LowStar.RVector.copyable"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz) | [] | MerkleTree.Low.Datastructures.hcpy | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | hsz: MerkleTree.Low.Datastructures.hash_size_t
-> LowStar.RVector.copyable MerkleTree.Low.Datastructures.hash
(MerkleTree.Low.Datastructures.hreg hsz) | {
"end_col": 22,
"end_line": 191,
"start_col": 2,
"start_line": 191
} |
Prims.Tot | val hvreg (hsz:hash_size_t): regional hash_size_t (hash_vec #hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hvreg hsz =
Rgl hsz
(hash_vec_region_of #hsz)
V.loc_vector
(hash_vec_dummy #hsz)
(hash_vec_r_inv #hsz)
(hash_vec_r_inv_reg #hsz)
(hash_vec_repr #hsz)
(hash_vec_r_repr #hsz)
(hash_vec_r_sep #hsz)
(hash_vec_irepr #hsz)
(hash_vec_r_alloc_p #hsz)
(hash_vec_r_alloc #hsz)
(hash_vec_r_free #hsz) | val hvreg (hsz:hash_size_t): regional hash_size_t (hash_vec #hsz)
let hvreg hsz = | false | null | false | Rgl hsz
(hash_vec_region_of #hsz)
V.loc_vector
(hash_vec_dummy #hsz)
(hash_vec_r_inv #hsz)
(hash_vec_r_inv_reg #hsz)
(hash_vec_repr #hsz)
(hash_vec_r_repr #hsz)
(hash_vec_r_sep #hsz)
(hash_vec_irepr #hsz)
(hash_vec_r_alloc_p #hsz)
(hash_vec_r_alloc #hsz)
(hash_vec_r_free #hsz) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"LowStar.Regional.Rgl",
"MerkleTree.Low.Datastructures.hash_vec",
"MerkleTree.Low.Datastructures.hash_vec_region_of",
"LowStar.Vector.loc_vector",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hash_vec_dummy",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_vec_r_inv",
"MerkleTree.Low.Datastructures.hash_vec_r_inv_reg",
"MerkleTree.Low.Datastructures.hash_vec_repr",
"MerkleTree.Low.Datastructures.hash_vec_r_repr",
"MerkleTree.Low.Datastructures.hash_vec_r_sep",
"MerkleTree.Low.Datastructures.hash_vec_irepr",
"MerkleTree.Low.Datastructures.hash_vec_r_alloc_p",
"MerkleTree.Low.Datastructures.hash_vec_r_alloc",
"MerkleTree.Low.Datastructures.hash_vec_r_free",
"LowStar.Regional.regional"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v =
RV.as_seq h v
noextract
val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v))
let hash_vec_r_sep #_ v p h0 h1 =
RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1
noextract
val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz)
let hash_vec_irepr #_ = Ghost.hide S.empty
noextract
val hash_vec_r_alloc_p: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_alloc_p #_ v = V.size_of v = 0ul
#push-options "--initial_fuel 1 --max_fuel 1"
val hash_vec_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash_vec #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_vec_r_alloc_p v /\
hash_vec_r_inv h1 v /\
hash_vec_region_of v = r /\
hash_vec_r_repr h1 v == Ghost.reveal hash_vec_irepr /\
B.fresh_loc (V.loc_vector v) h0 h1))
let hash_vec_r_alloc #_ hsz r =
let nrid = HST.new_region r in
// Note: here we are not creating a generic parameterized regional, we are
// creating a specialized regional vector of hashes, so we don't need to go
// through a run-time indirection to figure out what the dummy default element
// is; we know it's the one for hashes
V.alloc_reserve 1ul (hash_dummy #hsz) r
#pop-options
val hash_vec_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash_vec #hsz ->
HST.ST unit
(requires (fun h0 -> hash_vec_r_inv h0 v))
(ensures (fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_vec_region_of #hsz v)) h0 h1))
let hash_vec_r_free #_ hsz v =
RV.free v
/// This is nice because the only piece of state that we are keeping is one
/// word, the hash size, since we are implementing a specialized instance of
/// RVector over hashes of a known length. We could also, for genericity, make
/// this a mere application of RVector over hreg, which would be less
/// implementation effort, at the expense of a bigger run-time cost since there
/// would be extra space in the struct (which is passed by value!) and also a
/// run-time indirection to do the lookup of the type class instance for the
/// elements of the rvector.
noextract inline_for_extraction
val hvreg (hsz:hash_size_t): regional hash_size_t (hash_vec #hsz) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hvreg (hsz:hash_size_t): regional hash_size_t (hash_vec #hsz) | [] | MerkleTree.Low.Datastructures.hvreg | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | hsz: MerkleTree.Low.Datastructures.hash_size_t
-> LowStar.Regional.regional MerkleTree.Low.Datastructures.hash_size_t
MerkleTree.Low.Datastructures.hash_vec | {
"end_col": 28,
"end_line": 314,
"start_col": 2,
"start_line": 302
} |
Prims.Tot | val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_dummy #_ = B.null | val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = | false | null | false | B.null | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"MerkleTree.Low.Datastructures.hash_size_t",
"LowStar.Buffer.null",
"Lib.IntTypes.uint8",
"MerkleTree.Low.Datastructures.hash",
"FStar.Ghost.reveal"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz) | [] | MerkleTree.Low.Datastructures.hash_dummy | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | MerkleTree.Low.Datastructures.hash | {
"end_col": 26,
"end_line": 56,
"start_col": 20,
"start_line": 56
} |
Prims.Tot | val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0)) | val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz = | false | null | false | Ghost.hide (S.create (U32.v hsz) (u8 0)) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_repr",
"FStar.Seq.Base.create",
"Lib.IntTypes.uint8",
"FStar.UInt32.v",
"Lib.IntTypes.u8",
"FStar.Ghost.erased"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz) | [] | MerkleTree.Low.Datastructures.hash_irepr | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | FStar.Ghost.erased MerkleTree.Low.Datastructures.hash_repr | {
"end_col": 42,
"end_line": 107,
"start_col": 2,
"start_line": 107
} |
Prims.GTot | val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_r_repr #_ h v = B.as_seq h v | val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = | false | null | false | B.as_seq h v | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"sometrivial"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hash_r_inv",
"LowStar.Monotonic.Buffer.as_seq",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"MerkleTree.Low.Datastructures.hash_repr"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz) | [] | MerkleTree.Low.Datastructures.hash_r_repr | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
h: FStar.Monotonic.HyperStack.mem ->
v: MerkleTree.Low.Datastructures.hash{MerkleTree.Low.Datastructures.hash_r_inv h v}
-> Prims.GTot MerkleTree.Low.Datastructures.hash_repr | {
"end_col": 37,
"end_line": 82,
"start_col": 25,
"start_line": 82
} |
Prims.GTot | val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_r_repr #_ h v =
RV.as_seq h v | val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v = | false | null | false | RV.as_seq h v | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"sometrivial"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.Low.Datastructures.hash_vec",
"MerkleTree.Low.Datastructures.hash_vec_r_inv",
"LowStar.RVector.as_seq",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hreg",
"MerkleTree.Low.Datastructures.hash_vec_repr"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz) | [] | MerkleTree.Low.Datastructures.hash_vec_r_repr | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
h: FStar.Monotonic.HyperStack.mem ->
v: MerkleTree.Low.Datastructures.hash_vec{MerkleTree.Low.Datastructures.hash_vec_r_inv h v}
-> Prims.GTot MerkleTree.Low.Datastructures.hash_vec_repr | {
"end_col": 15,
"end_line": 230,
"start_col": 2,
"start_line": 230
} |
Prims.Tot | val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz) | val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz = | false | null | false | Rgl #(hash_size_t)
#(hash #hsz)
hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"LowStar.Regional.Rgl",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hash_region_of",
"LowStar.Monotonic.Buffer.loc_buffer",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"MerkleTree.Low.Datastructures.hash_dummy",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_r_inv",
"MerkleTree.Low.Datastructures.hash_r_inv_reg",
"MerkleTree.Low.Datastructures.hash_repr",
"MerkleTree.Low.Datastructures.hash_r_repr",
"MerkleTree.Low.Datastructures.hash_r_sep",
"MerkleTree.Low.Datastructures.hash_irepr",
"MerkleTree.Low.Datastructures.hash_r_alloc_p",
"MerkleTree.Low.Datastructures.hash_r_alloc",
"MerkleTree.Low.Datastructures.hash_r_free",
"LowStar.Regional.regional"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz) | [] | MerkleTree.Low.Datastructures.hreg | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | hsz: MerkleTree.Low.Datastructures.hash_size_t
-> LowStar.Regional.regional MerkleTree.Low.Datastructures.hash_size_t
MerkleTree.Low.Datastructures.hash | {
"end_col": 24,
"end_line": 158,
"start_col": 2,
"start_line": 146
} |
FStar.HyperStack.ST.ST | val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_r_free #_ _ v =
B.free v | val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v = | true | null | false | B.free v | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [] | [
"FStar.Ghost.erased",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.eq2",
"FStar.Ghost.reveal",
"MerkleTree.Low.Datastructures.hash",
"LowStar.Monotonic.Buffer.free",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"Prims.unit"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1) | [] | MerkleTree.Low.Datastructures.hash_r_free | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hsz: MerkleTree.Low.Datastructures.hash_size_t{hsz == FStar.Ghost.reveal hsz'} ->
v: MerkleTree.Low.Datastructures.hash
-> FStar.HyperStack.ST.ST Prims.unit | {
"end_col": 10,
"end_line": 141,
"start_col": 2,
"start_line": 141
} |
Prims.Tot | val hash_vec_repr: #hsz:hash_size_t -> Type0 | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz) | val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = | false | null | false | MTH.hashes #(U32.v hsz) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.New.High.hashes",
"FStar.UInt32.v"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract | false | true | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_repr: #hsz:hash_size_t -> Type0 | [] | MerkleTree.Low.Datastructures.hash_vec_repr | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | Type0 | {
"end_col": 48,
"end_line": 223,
"start_col": 25,
"start_line": 223
} |
Prims.Tot | val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_irepr #_ = Ghost.hide S.empty | val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz)
let hash_vec_irepr #_ = | false | null | false | Ghost.hide S.empty | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"total"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_vec_repr",
"FStar.Seq.Base.empty",
"MerkleTree.New.High.hash",
"FStar.UInt32.v",
"FStar.Ghost.erased"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v =
RV.as_seq h v
noextract
val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v))
let hash_vec_r_sep #_ v p h0 h1 =
RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1
noextract | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz) | [] | MerkleTree.Low.Datastructures.hash_vec_irepr | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | FStar.Ghost.erased MerkleTree.Low.Datastructures.hash_vec_repr | {
"end_col": 42,
"end_line": 249,
"start_col": 24,
"start_line": 249
} |
FStar.HyperStack.ST.ST | val hash_vec_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash_vec #hsz ->
HST.ST unit
(requires (fun h0 -> hash_vec_r_inv h0 v))
(ensures (fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_vec_region_of #hsz v)) h0 h1)) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_r_free #_ hsz v =
RV.free v | val hash_vec_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash_vec #hsz ->
HST.ST unit
(requires (fun h0 -> hash_vec_r_inv h0 v))
(ensures (fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_vec_region_of #hsz v)) h0 h1))
let hash_vec_r_free #_ hsz v = | true | null | false | RV.free v | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [] | [
"FStar.Ghost.erased",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.eq2",
"FStar.Ghost.reveal",
"MerkleTree.Low.Datastructures.hash_vec",
"LowStar.RVector.free",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hreg",
"Prims.unit"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v =
RV.as_seq h v
noextract
val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v))
let hash_vec_r_sep #_ v p h0 h1 =
RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1
noextract
val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz)
let hash_vec_irepr #_ = Ghost.hide S.empty
noextract
val hash_vec_r_alloc_p: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_alloc_p #_ v = V.size_of v = 0ul
#push-options "--initial_fuel 1 --max_fuel 1"
val hash_vec_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash_vec #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_vec_r_alloc_p v /\
hash_vec_r_inv h1 v /\
hash_vec_region_of v = r /\
hash_vec_r_repr h1 v == Ghost.reveal hash_vec_irepr /\
B.fresh_loc (V.loc_vector v) h0 h1))
let hash_vec_r_alloc #_ hsz r =
let nrid = HST.new_region r in
// Note: here we are not creating a generic parameterized regional, we are
// creating a specialized regional vector of hashes, so we don't need to go
// through a run-time indirection to figure out what the dummy default element
// is; we know it's the one for hashes
V.alloc_reserve 1ul (hash_dummy #hsz) r
#pop-options
val hash_vec_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash_vec #hsz ->
HST.ST unit
(requires (fun h0 -> hash_vec_r_inv h0 v))
(ensures (fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_vec_region_of #hsz v)) h0 h1)) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash_vec #hsz ->
HST.ST unit
(requires (fun h0 -> hash_vec_r_inv h0 v))
(ensures (fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_vec_region_of #hsz v)) h0 h1)) | [] | MerkleTree.Low.Datastructures.hash_vec_r_free | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hsz: MerkleTree.Low.Datastructures.hash_size_t{hsz == FStar.Ghost.reveal hsz'} ->
v: MerkleTree.Low.Datastructures.hash_vec
-> FStar.HyperStack.ST.ST Prims.unit | {
"end_col": 11,
"end_line": 289,
"start_col": 2,
"start_line": 289
} |
FStar.HyperStack.ST.ST | val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1)) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_r_alloc #_ s r =
B.malloc r (u8 0) s | val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r = | true | null | false | B.malloc r (u8 0) s | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [] | [
"FStar.Ghost.erased",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.eq2",
"FStar.Ghost.reveal",
"FStar.HyperStack.ST.erid",
"LowStar.Buffer.malloc",
"Lib.IntTypes.uint8",
"Lib.IntTypes.u8",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.freeable",
"MerkleTree.Low.Datastructures.hash"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1)) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1)) | [] | MerkleTree.Low.Datastructures.hash_r_alloc | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hsz: MerkleTree.Low.Datastructures.hash_size_t{hsz == FStar.Ghost.reveal hsz'} ->
r: FStar.HyperStack.ST.erid
-> FStar.HyperStack.ST.ST MerkleTree.Low.Datastructures.hash | {
"end_col": 21,
"end_line": 130,
"start_col": 2,
"start_line": 130
} |
FStar.Pervasives.Lemma | val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1 | val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 = | false | null | true | assert (loc_includes (loc_all_regions_from false (hash_region_of v)) (loc_buffer v));
B.modifies_buffer_elim v p h0 h1 | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"lemma"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash",
"LowStar.Monotonic.Buffer.loc",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.modifies_buffer_elim",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"Prims.unit",
"Prims._assert",
"LowStar.Monotonic.Buffer.loc_includes",
"LowStar.Monotonic.Buffer.loc_all_regions_from",
"MerkleTree.Low.Datastructures.hash_region_of",
"LowStar.Monotonic.Buffer.loc_buffer"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v) | [] | MerkleTree.Low.Datastructures.hash_r_sep | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
v: MerkleTree.Low.Datastructures.hash ->
p: LowStar.Monotonic.Buffer.loc ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
MerkleTree.Low.Datastructures.hash_r_inv h0 v /\
LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_all_regions_from false
(MerkleTree.Low.Datastructures.hash_region_of v))
p /\ LowStar.Monotonic.Buffer.modifies p h0 h1)
(ensures
MerkleTree.Low.Datastructures.hash_r_inv h1 v /\
MerkleTree.Low.Datastructures.hash_r_repr h0 v ==
MerkleTree.Low.Datastructures.hash_r_repr h1 v) | {
"end_col": 34,
"end_line": 101,
"start_col": 2,
"start_line": 99
} |
FStar.Pervasives.Lemma | val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v)) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_r_sep #_ v p h0 h1 =
RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1 | val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v))
let hash_vec_r_sep #_ v p h0 h1 = | false | null | true | RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1 | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"lemma"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash_vec",
"LowStar.Monotonic.Buffer.loc",
"FStar.Monotonic.HyperStack.mem",
"LowStar.RVector.as_seq_preserved",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hreg",
"Prims.unit",
"LowStar.RVector.rv_inv_preserved"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v =
RV.as_seq h v
noextract
val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v)) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v)) | [] | MerkleTree.Low.Datastructures.hash_vec_r_sep | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
v: MerkleTree.Low.Datastructures.hash_vec ->
p: LowStar.Monotonic.Buffer.loc ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
MerkleTree.Low.Datastructures.hash_vec_r_inv h0 v /\
LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_all_regions_from false
(MerkleTree.Low.Datastructures.hash_vec_region_of v))
p /\ LowStar.Monotonic.Buffer.modifies p h0 h1)
(ensures
MerkleTree.Low.Datastructures.hash_vec_r_inv h1 v /\
MerkleTree.Low.Datastructures.hash_vec_r_repr h0 v ==
MerkleTree.Low.Datastructures.hash_vec_r_repr h1 v) | {
"end_col": 31,
"end_line": 245,
"start_col": 2,
"start_line": 244
} |
FStar.HyperStack.ST.ST | val hash_vec_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash_vec #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_vec_r_alloc_p v /\
hash_vec_r_inv h1 v /\
hash_vec_region_of v = r /\
hash_vec_r_repr h1 v == Ghost.reveal hash_vec_irepr /\
B.fresh_loc (V.loc_vector v) h0 h1)) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vec_r_alloc #_ hsz r =
let nrid = HST.new_region r in
// Note: here we are not creating a generic parameterized regional, we are
// creating a specialized regional vector of hashes, so we don't need to go
// through a run-time indirection to figure out what the dummy default element
// is; we know it's the one for hashes
V.alloc_reserve 1ul (hash_dummy #hsz) r | val hash_vec_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash_vec #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_vec_r_alloc_p v /\
hash_vec_r_inv h1 v /\
hash_vec_region_of v = r /\
hash_vec_r_repr h1 v == Ghost.reveal hash_vec_irepr /\
B.fresh_loc (V.loc_vector v) h0 h1))
let hash_vec_r_alloc #_ hsz r = | true | null | false | let nrid = HST.new_region r in
V.alloc_reserve 1ul (hash_dummy #hsz) r | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [] | [
"FStar.Ghost.erased",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.eq2",
"FStar.Ghost.reveal",
"FStar.HyperStack.ST.erid",
"LowStar.Vector.alloc_reserve",
"MerkleTree.Low.Datastructures.hash",
"FStar.UInt32.__uint_to_t",
"MerkleTree.Low.Datastructures.hash_dummy",
"FStar.Ghost.hide",
"LowStar.Vector.vector",
"FStar.Monotonic.HyperHeap.rid",
"FStar.HyperStack.ST.new_region",
"MerkleTree.Low.Datastructures.hash_vec"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v =
RV.as_seq h v
noextract
val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v))
let hash_vec_r_sep #_ v p h0 h1 =
RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1
noextract
val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz)
let hash_vec_irepr #_ = Ghost.hide S.empty
noextract
val hash_vec_r_alloc_p: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_alloc_p #_ v = V.size_of v = 0ul
#push-options "--initial_fuel 1 --max_fuel 1"
val hash_vec_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash_vec #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_vec_r_alloc_p v /\
hash_vec_r_inv h1 v /\
hash_vec_region_of v = r /\
hash_vec_r_repr h1 v == Ghost.reveal hash_vec_irepr /\ | false | false | MerkleTree.Low.Datastructures.fst | {
"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": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vec_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash_vec #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_vec_r_alloc_p v /\
hash_vec_r_inv h1 v /\
hash_vec_region_of v = r /\
hash_vec_r_repr h1 v == Ghost.reveal hash_vec_irepr /\
B.fresh_loc (V.loc_vector v) h0 h1)) | [] | MerkleTree.Low.Datastructures.hash_vec_r_alloc | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hsz: MerkleTree.Low.Datastructures.hash_size_t{hsz == FStar.Ghost.reveal hsz'} ->
r: FStar.HyperStack.ST.erid
-> FStar.HyperStack.ST.ST MerkleTree.Low.Datastructures.hash_vec | {
"end_col": 41,
"end_line": 277,
"start_col": 31,
"start_line": 271
} |
FStar.Pervasives.Lemma | val hash_vv_rv_inv_disjoint:
#hsz:hash_size_t ->
h:HS.mem -> hvv:hash_vv hsz ->
i:uint32_t -> j:uint32_t -> drid:HH.rid ->
Lemma (requires (RV.rv_inv h hvv /\
i < V.size_of hvv /\
j < V.size_of (V.get h hvv i) /\
HH.disjoint (Rgl?.region_of (hvvreg hsz) hvv) drid))
(ensures (HH.disjoint (Rgl?.region_of (hreg hsz) (V.get h (V.get h hvv i) j)) drid)) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_vv_rv_inv_disjoint #hsz h hvv i j drid =
assert (HH.disjoint (Rgl?.region_of (hvreg hsz) (V.get h hvv i)) drid);
assert (RV.rv_inv h (V.get h hvv i));
assert (HH.disjoint (Rgl?.region_of (hreg hsz) (V.get h (V.get h hvv i) j)) drid) | val hash_vv_rv_inv_disjoint:
#hsz:hash_size_t ->
h:HS.mem -> hvv:hash_vv hsz ->
i:uint32_t -> j:uint32_t -> drid:HH.rid ->
Lemma (requires (RV.rv_inv h hvv /\
i < V.size_of hvv /\
j < V.size_of (V.get h hvv i) /\
HH.disjoint (Rgl?.region_of (hvvreg hsz) hvv) drid))
(ensures (HH.disjoint (Rgl?.region_of (hreg hsz) (V.get h (V.get h hvv i) j)) drid))
let hash_vv_rv_inv_disjoint #hsz h hvv i j drid = | false | null | true | assert (HH.disjoint (Rgl?.region_of (hvreg hsz) (V.get h hvv i)) drid);
assert (RV.rv_inv h (V.get h hvv i));
assert (HH.disjoint (Rgl?.region_of (hreg hsz) (V.get h (V.get h hvv i) j)) drid) | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [
"lemma"
] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.Low.Datastructures.hash_vv",
"EverCrypt.Helpers.uint32_t",
"FStar.Monotonic.HyperHeap.rid",
"Prims._assert",
"Prims.b2t",
"FStar.Monotonic.HyperHeap.disjoint",
"LowStar.Regional.__proj__Rgl__item__region_of",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hreg",
"LowStar.Vector.get",
"MerkleTree.Low.Datastructures.hash_vec",
"Prims.unit",
"LowStar.RVector.rv_inv",
"MerkleTree.Low.Datastructures.hvreg"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s
/// JP: so much stuff happening here. First, single-constructor, single-argument
/// elimination takes places and Cpy becomes completely eliminated, in favor of
/// just being a type alias for the underlying function. So now, we have a
/// function that returns a function pointer.
///
/// Next, one might think that the hsz argument is going to be eliminated. It's
/// not, because there's a hidden implicit argument to Cpy which is (hreg hsz),
/// meaning that hsz is used at run-time even though Cpy is only using this
/// argument ghostly. This would be have to be fixed.
///
/// Finally, if the inline_for_extraction is removed, there seems to be a
/// karamel bug that inserts a void*0. To be fixed.
inline_for_extraction
val hcpy: hsz:hash_size_t -> copyable #hash_size_t (hash #hsz) (hreg hsz)
let hcpy hsz =
Cpy (hash_copy #hsz)
type hash_vec (#hsz:hash_size_t) = RV.rvector (hreg hsz)
/// 2. `rvector hash` is regional
type rhst (hsz:hash_size_t) = regional hash_size_t (hash #hsz)
private
noextract
val hash_vec_region_of: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot HH.rid
let hash_vec_region_of #_ v = V.frameOf v
private inline_for_extraction
val hash_vec_dummy: (#hsz:Ghost.erased hash_size_t) -> hash_vec #hsz
let hash_vec_dummy #_ = V.alloc_empty (hash #_)
noextract
val hash_vec_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_inv #hsz h v = RV.rv_inv h v
noextract
val hash_vec_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz ->
Lemma (requires (hash_vec_r_inv h v))
(ensures (MHS.live_region h (hash_vec_region_of v)))
let hash_vec_r_inv_reg #_ h v = ()
private
noextract
val hash_vec_repr: #hsz:hash_size_t -> Type0
let hash_vec_repr #hsz = MTH.hashes #(U32.v hsz)
noextract
val hash_vec_r_repr:
#hsz:hash_size_t ->
h:HS.mem -> v:hash_vec #hsz {hash_vec_r_inv h v} -> GTot (hash_vec_repr #hsz)
let hash_vec_r_repr #_ h v =
RV.as_seq h v
noextract
val hash_vec_r_sep:
#hsz:hash_size_t ->
v:hash_vec #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires (hash_vec_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false (hash_vec_region_of v))
p /\
modifies p h0 h1))
(ensures (hash_vec_r_inv h1 v /\
hash_vec_r_repr h0 v == hash_vec_r_repr h1 v))
let hash_vec_r_sep #_ v p h0 h1 =
RV.rv_inv_preserved v p h0 h1;
RV.as_seq_preserved v p h0 h1
noextract
val hash_vec_irepr: #hsz:hash_size_t -> Ghost.erased (hash_vec_repr #hsz)
let hash_vec_irepr #_ = Ghost.hide S.empty
noextract
val hash_vec_r_alloc_p: #hsz:hash_size_t -> v:hash_vec #hsz -> GTot Type0
let hash_vec_r_alloc_p #_ v = V.size_of v = 0ul
#push-options "--initial_fuel 1 --max_fuel 1"
val hash_vec_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash_vec #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_vec_r_alloc_p v /\
hash_vec_r_inv h1 v /\
hash_vec_region_of v = r /\
hash_vec_r_repr h1 v == Ghost.reveal hash_vec_irepr /\
B.fresh_loc (V.loc_vector v) h0 h1))
let hash_vec_r_alloc #_ hsz r =
let nrid = HST.new_region r in
// Note: here we are not creating a generic parameterized regional, we are
// creating a specialized regional vector of hashes, so we don't need to go
// through a run-time indirection to figure out what the dummy default element
// is; we know it's the one for hashes
V.alloc_reserve 1ul (hash_dummy #hsz) r
#pop-options
val hash_vec_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash_vec #hsz ->
HST.ST unit
(requires (fun h0 -> hash_vec_r_inv h0 v))
(ensures (fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_vec_region_of #hsz v)) h0 h1))
let hash_vec_r_free #_ hsz v =
RV.free v
/// This is nice because the only piece of state that we are keeping is one
/// word, the hash size, since we are implementing a specialized instance of
/// RVector over hashes of a known length. We could also, for genericity, make
/// this a mere application of RVector over hreg, which would be less
/// implementation effort, at the expense of a bigger run-time cost since there
/// would be extra space in the struct (which is passed by value!) and also a
/// run-time indirection to do the lookup of the type class instance for the
/// elements of the rvector.
noextract inline_for_extraction
val hvreg (hsz:hash_size_t): regional hash_size_t (hash_vec #hsz)
let hvreg hsz =
Rgl hsz
(hash_vec_region_of #hsz)
V.loc_vector
(hash_vec_dummy #hsz)
(hash_vec_r_inv #hsz)
(hash_vec_r_inv_reg #hsz)
(hash_vec_repr #hsz)
(hash_vec_r_repr #hsz)
(hash_vec_r_sep #hsz)
(hash_vec_irepr #hsz)
(hash_vec_r_alloc_p #hsz)
(hash_vec_r_alloc #hsz)
(hash_vec_r_free #hsz)
/// 3. A vector of hash vectors is also regional
type hash_vv (hsz:hash_size_t) = RV.rvector (hvreg hsz)
noextract inline_for_extraction
val hvvreg (hsz:hash_size_t): regional (regional hash_size_t (hash_vec #hsz)) (hash_vv hsz)
let hvvreg hsz = RVI.vector_regional (hvreg hsz)
val hash_vec_rv_inv_r_inv:
#hsz:hash_size_t ->
h:HS.mem -> hv:hash_vec #hsz -> i:uint32_t{i < V.size_of hv} ->
Lemma (requires RV.rv_inv h hv)
(ensures Rgl?.r_inv (hreg hsz) h (V.get h hv i))
let hash_vec_rv_inv_r_inv #_ h hv i = ()
val hash_vv_rv_inv_r_inv:
#hsz:hash_size_t ->
h:HS.mem -> hvv:hash_vv hsz ->
i:uint32_t -> j:uint32_t ->
Lemma (requires RV.rv_inv h hvv /\
i < V.size_of hvv /\
j < V.size_of (V.get h hvv i))
(ensures Rgl?.r_inv (hvreg hsz) h (V.get h hvv i) /\
Rgl?.r_inv (hreg hsz) h (V.get h (V.get h hvv i) j))
let hash_vv_rv_inv_r_inv #_ h hvv i j = ()
val hash_vv_rv_inv_disjoint:
#hsz:hash_size_t ->
h:HS.mem -> hvv:hash_vv hsz ->
i:uint32_t -> j:uint32_t -> drid:HH.rid ->
Lemma (requires (RV.rv_inv h hvv /\
i < V.size_of hvv /\
j < V.size_of (V.get h hvv i) /\
HH.disjoint (Rgl?.region_of (hvvreg hsz) hvv) drid))
(ensures (HH.disjoint (Rgl?.region_of (hreg hsz) (V.get h (V.get h hvv i) j)) drid)) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_vv_rv_inv_disjoint:
#hsz:hash_size_t ->
h:HS.mem -> hvv:hash_vv hsz ->
i:uint32_t -> j:uint32_t -> drid:HH.rid ->
Lemma (requires (RV.rv_inv h hvv /\
i < V.size_of hvv /\
j < V.size_of (V.get h hvv i) /\
HH.disjoint (Rgl?.region_of (hvvreg hsz) hvv) drid))
(ensures (HH.disjoint (Rgl?.region_of (hreg hsz) (V.get h (V.get h hvv i) j)) drid)) | [] | MerkleTree.Low.Datastructures.hash_vv_rv_inv_disjoint | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
h: FStar.Monotonic.HyperStack.mem ->
hvv: MerkleTree.Low.Datastructures.hash_vv hsz ->
i: EverCrypt.Helpers.uint32_t ->
j: EverCrypt.Helpers.uint32_t ->
drid: FStar.Monotonic.HyperHeap.rid
-> FStar.Pervasives.Lemma
(requires
LowStar.RVector.rv_inv h hvv /\ i < LowStar.Vector.size_of hvv /\
j < LowStar.Vector.size_of (LowStar.Vector.get h hvv i) /\
FStar.Monotonic.HyperHeap.disjoint (Rgl?.region_of (MerkleTree.Low.Datastructures.hvvreg hsz
)
hvv)
drid)
(ensures
FStar.Monotonic.HyperHeap.disjoint (Rgl?.region_of (MerkleTree.Low.Datastructures.hreg hsz)
(LowStar.Vector.get h (LowStar.Vector.get h hvv i) j))
drid) | {
"end_col": 83,
"end_line": 354,
"start_col": 2,
"start_line": 352
} |
FStar.HyperStack.ST.ST | val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src) | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"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.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_copy #_ s src dst =
B.blit src 0ul dst 0ul s | val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src)
let hash_copy #_ s src dst = | true | null | false | B.blit src 0ul dst 0ul s | {
"checked_file": "MerkleTree.Low.Datastructures.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.New.High.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Datastructures.fst"
} | [] | [
"FStar.Ghost.erased",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.eq2",
"FStar.Ghost.reveal",
"MerkleTree.Low.Datastructures.hash",
"LowStar.Monotonic.Buffer.blit",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"Prims.unit"
] | [] | module MerkleTree.Low.Datastructures
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module EHS = EverCrypt.Hash
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
open EverCrypt.Helpers
open Lib.IntTypes
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
type hash_size_t = n:uint32_t{n > 0ul}
type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b }
// We cannot use `Low.RVector.Instances`, where we have some general
// typeclass instances of `regional`, e.g., if `rg:regional a` then
// `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently
// cannot deal with this and gives a number of errors.
// So we temporarily instantiate some `regional`s manually below, which is
// extractable to C by KaRaMeL.
/// Some instantiations of `regional` used in Merkle tree
/// 1. `hash` is regional
private
noextract
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
private inline_for_extraction
val hash_dummy: #hsz:Ghost.erased hash_size_t -> Tot (hash #hsz)
let hash_dummy #_ = B.null
private
noextract
val hash_r_inv: #hsz:hash_size_t -> h:HS.mem -> v:hash #hsz -> GTot Type0
let hash_r_inv #hsz h v =
B.live h v /\ B.freeable v /\
B.len v = hsz
private
noextract
val hash_r_inv_reg:
#hsz:hash_size_t ->
h:HS.mem -> v:hash ->
Lemma (requires hash_r_inv h v)
(ensures MHS.live_region h (hash_region_of #hsz v))
let hash_r_inv_reg #_ h v = ()
private
noextract
val hash_repr (#hsz:hash_size_t): Type0
let hash_repr #hsz = MTH.hash #(U32.v hsz)
private
noextract
val hash_r_repr: #hsz:hash_size_t -> h:HS.mem -> v:hash{hash_r_inv #hsz h v} -> GTot (hash_repr #hsz)
let hash_r_repr #_ h v = B.as_seq h v
private
noextract
val hash_r_sep:
#hsz:hash_size_t ->
v:hash #hsz -> p:loc -> h0:HS.mem -> h1:HS.mem ->
Lemma (requires
hash_r_inv h0 v /\
loc_disjoint
(loc_all_regions_from false
(hash_region_of v)) p /\
modifies p h0 h1)
(ensures
hash_r_inv h1 v /\
hash_r_repr h0 v == hash_r_repr h1 v)
let hash_r_sep #_ v p h0 h1 =
assert (loc_includes (loc_all_regions_from false (hash_region_of v))
(loc_buffer v));
B.modifies_buffer_elim v p h0 h1
private
noextract
val hash_irepr: #hsz:hash_size_t -> Ghost.erased (hash_repr #hsz)
let hash_irepr #hsz =
Ghost.hide (S.create (U32.v hsz) (u8 0))
private
noextract
val hash_r_alloc_p: #hsz:hash_size_t -> v:hash #hsz -> GTot Type0
let hash_r_alloc_p #_ v = True
val hash_r_alloc:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
r:HST.erid ->
HST.ST (hash #hsz)
(requires (fun h0 -> true))
(ensures (fun h0 v h1 ->
Set.subset (Map.domain (MHS.get_hmap h0))
(Map.domain (MHS.get_hmap h1)) /\
modifies loc_none h0 h1 /\
hash_r_alloc_p #hsz v /\
hash_r_inv h1 v /\
hash_region_of v = r /\
hash_r_repr h1 v == Ghost.reveal hash_irepr /\
B.fresh_loc (B.loc_buffer v) h0 h1))
let hash_r_alloc #_ s r =
B.malloc r (u8 0) s
val hash_r_free:
#hsz':Ghost.erased hash_size_t ->
hsz:hash_size_t { hsz == Ghost.reveal hsz' } ->
v:hash #hsz' ->
HST.ST unit
(requires fun h0 -> hash_r_inv h0 v)
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of v)) h0 h1)
let hash_r_free #_ _ v =
B.free v
noextract inline_for_extraction
val hreg (hsz:hash_size_t): regional (hash_size_t) (hash #hsz)
let hreg hsz =
Rgl #(hash_size_t) #(hash #hsz) hsz
(hash_region_of #hsz)
(B.loc_buffer)
(hash_dummy #hsz)
(hash_r_inv #hsz)
(hash_r_inv_reg #hsz)
(hash_repr #hsz)
(hash_r_repr #hsz)
(hash_r_sep #hsz)
(hash_irepr #hsz)
(hash_r_alloc_p #hsz)
(hash_r_alloc #hsz)
(hash_r_free #hsz)
private
val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src) | false | false | MerkleTree.Low.Datastructures.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_copy:
#s':Ghost.erased hash_size_t ->
s:hash_size_t { s == Ghost.reveal s' } ->
src:hash #s -> dst:hash #s ->
HST.ST unit
(requires fun h0 ->
hash_r_inv h0 src /\ hash_r_inv h0 dst /\
HH.disjoint (hash_region_of src) (hash_region_of dst))
(ensures fun h0 _ h1 ->
modifies (loc_all_regions_from false (hash_region_of dst)) h0 h1 /\
hash_r_inv h1 dst /\
hash_r_repr h1 dst == hash_r_repr h0 src) | [] | MerkleTree.Low.Datastructures.hash_copy | {
"file_name": "src/MerkleTree.Low.Datastructures.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
s: MerkleTree.Low.Datastructures.hash_size_t{s == FStar.Ghost.reveal s'} ->
src: MerkleTree.Low.Datastructures.hash ->
dst: MerkleTree.Low.Datastructures.hash
-> FStar.HyperStack.ST.ST Prims.unit | {
"end_col": 26,
"end_line": 174,
"start_col": 2,
"start_line": 174
} |
Prims.Tot | val degree (p:poly) : int | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let degree p = D.degree p | val degree (p:poly) : int
let degree p = | false | null | false | D.degree p | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Defs_s.degree",
"Prims.int"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val degree (p:poly) : int | [] | Vale.Math.Poly2_s.degree | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Vale.Math.Poly2_s.poly -> Prims.int | {
"end_col": 25,
"end_line": 6,
"start_col": 15,
"start_line": 6
} |
Prims.Tot | val reverse (p:poly) (n:nat) : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let reverse p n = D.reverse p n | val reverse (p:poly) (n:nat) : poly
let reverse p n = | false | null | false | D.reverse p n | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Prims.nat",
"Vale.Math.Poly2.Defs_s.reverse"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val reverse (p:poly) (n:nat) : poly | [] | Vale.Math.Poly2_s.reverse | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Vale.Math.Poly2_s.poly -> n: Prims.nat -> Vale.Math.Poly2_s.poly | {
"end_col": 31,
"end_line": 11,
"start_col": 18,
"start_line": 11
} |
Prims.Tot | val monomial (n:nat) : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let monomial n = D.monomial n | val monomial (n:nat) : poly
let monomial n = | false | null | false | D.monomial n | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Prims.nat",
"Vale.Math.Poly2.Defs_s.monomial",
"Vale.Math.Poly2_s.poly"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val monomial (n:nat) : poly | [] | Vale.Math.Poly2_s.monomial | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Prims.nat -> Vale.Math.Poly2_s.poly | {
"end_col": 29,
"end_line": 9,
"start_col": 17,
"start_line": 9
} |
Prims.Tot | val shift (p:poly) (n:int) : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shift p n = D.shift p n | val shift (p:poly) (n:int) : poly
let shift p n = | false | null | false | D.shift p n | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Prims.int",
"Vale.Math.Poly2.Defs_s.shift"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val shift (p:poly) (n:int) : poly | [] | Vale.Math.Poly2_s.shift | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Vale.Math.Poly2_s.poly -> n: Prims.int -> Vale.Math.Poly2_s.poly | {
"end_col": 27,
"end_line": 10,
"start_col": 16,
"start_line": 10
} |
Prims.Tot | val poly_index (p:poly) (n:int) : bool | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let poly_index p n = D.poly_index p n | val poly_index (p:poly) (n:int) : bool
let poly_index p n = | false | null | false | D.poly_index p n | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Prims.int",
"Vale.Math.Poly2.Defs_s.poly_index",
"Prims.bool"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n
let shift p n = D.shift p n | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val poly_index (p:poly) (n:int) : bool | [] | Vale.Math.Poly2_s.poly_index | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Vale.Math.Poly2_s.poly -> n: Prims.int -> Prims.bool | {
"end_col": 37,
"end_line": 12,
"start_col": 21,
"start_line": 12
} |
Prims.Tot | val add (a b:poly) : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add a b = D.add a b | val add (a b:poly) : poly
let add a b = | false | null | false | D.add a b | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Defs_s.add"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n
let shift p n = D.shift p n
let reverse p n = D.reverse p n
let poly_index p n = D.poly_index p n
let to_seq s n = D.to_seq s n
let of_seq s = D.of_seq s | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add (a b:poly) : poly | [] | Vale.Math.Poly2_s.add | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Vale.Math.Poly2_s.poly -> b: Vale.Math.Poly2_s.poly -> Vale.Math.Poly2_s.poly | {
"end_col": 23,
"end_line": 16,
"start_col": 14,
"start_line": 16
} |
Prims.Tot | val mul (a b:poly) : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul a b = D.mul a b | val mul (a b:poly) : poly
let mul a b = | false | null | false | D.mul a b | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Defs_s.mul"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n
let shift p n = D.shift p n
let reverse p n = D.reverse p n
let poly_index p n = D.poly_index p n
let to_seq s n = D.to_seq s n
let of_seq s = D.of_seq s
let of_fun len f = D.of_fun len f | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul (a b:poly) : poly | [] | Vale.Math.Poly2_s.mul | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Vale.Math.Poly2_s.poly -> b: Vale.Math.Poly2_s.poly -> Vale.Math.Poly2_s.poly | {
"end_col": 23,
"end_line": 17,
"start_col": 14,
"start_line": 17
} |
Prims.Tot | val poly : eqtype | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let poly = D.poly | val poly : eqtype
let poly = | false | null | false | D.poly | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2.Defs_s.poly"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val poly : eqtype | [] | Vale.Math.Poly2_s.poly | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.eqtype | {
"end_col": 17,
"end_line": 5,
"start_col": 11,
"start_line": 5
} |
Prims.Tot | val one : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let one = D.one | val one : poly
let one = | false | null | false | D.one | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2.Defs_s.one"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val one : poly | [] | Vale.Math.Poly2_s.one | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.Math.Poly2_s.poly | {
"end_col": 15,
"end_line": 8,
"start_col": 10,
"start_line": 8
} |
Prims.Tot | val zero : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let zero = D.zero | val zero : poly
let zero = | false | null | false | D.zero | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2.Defs_s.zero"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val zero : poly | [] | Vale.Math.Poly2_s.zero | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.Math.Poly2_s.poly | {
"end_col": 17,
"end_line": 7,
"start_col": 11,
"start_line": 7
} |
Prims.Tot | val div (a b:poly) : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let div a b = if degree b >= 0 then D.div a b else undefined_div_by_zero a | val div (a b:poly) : poly
let div a b = | false | null | false | if degree b >= 0 then D.div a b else undefined_div_by_zero a | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Prims.op_GreaterThanOrEqual",
"Vale.Math.Poly2_s.degree",
"Vale.Math.Poly2.Defs_s.div",
"Prims.bool",
"Vale.Math.Poly2_s.undefined_div_by_zero"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n
let shift p n = D.shift p n
let reverse p n = D.reverse p n
let poly_index p n = D.poly_index p n
let to_seq s n = D.to_seq s n
let of_seq s = D.of_seq s
let of_fun len f = D.of_fun len f
let add a b = D.add a b
let mul a b = D.mul a b
assume val undefined_div_by_zero (a:poly) : poly
assume val undefined_mod_by_zero (a:poly) : poly | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val div (a b:poly) : poly | [] | Vale.Math.Poly2_s.div | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Vale.Math.Poly2_s.poly -> b: Vale.Math.Poly2_s.poly -> Vale.Math.Poly2_s.poly | {
"end_col": 74,
"end_line": 22,
"start_col": 14,
"start_line": 22
} |
Prims.Tot | val mod (a b:poly) : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod a b = if degree b >= 0 then D.mod a b else undefined_mod_by_zero a | val mod (a b:poly) : poly
let mod a b = | false | null | false | if degree b >= 0 then D.mod a b else undefined_mod_by_zero a | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Prims.op_GreaterThanOrEqual",
"Vale.Math.Poly2_s.degree",
"Vale.Math.Poly2.Defs_s.mod",
"Prims.bool",
"Vale.Math.Poly2_s.undefined_mod_by_zero"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n
let shift p n = D.shift p n
let reverse p n = D.reverse p n
let poly_index p n = D.poly_index p n
let to_seq s n = D.to_seq s n
let of_seq s = D.of_seq s
let of_fun len f = D.of_fun len f
let add a b = D.add a b
let mul a b = D.mul a b
assume val undefined_div_by_zero (a:poly) : poly
assume val undefined_mod_by_zero (a:poly) : poly | false | true | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod (a b:poly) : poly | [] | Vale.Math.Poly2_s.mod | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Vale.Math.Poly2_s.poly -> b: Vale.Math.Poly2_s.poly -> Vale.Math.Poly2_s.poly | {
"end_col": 74,
"end_line": 23,
"start_col": 14,
"start_line": 23
} |
Prims.Pure | val to_seq (p:poly) (n:nat) : Pure (seq bool)
(requires True)
(ensures fun s ->
length s == n /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
) | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let to_seq s n = D.to_seq s n | val to_seq (p:poly) (n:nat) : Pure (seq bool)
(requires True)
(ensures fun s ->
length s == n /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
)
let to_seq s n = | false | null | false | D.to_seq s n | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [] | [
"Vale.Math.Poly2_s.poly",
"Prims.nat",
"Vale.Math.Poly2.Defs_s.to_seq",
"FStar.Seq.Base.seq",
"Prims.bool"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n
let shift p n = D.shift p n
let reverse p n = D.reverse p n | false | false | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val to_seq (p:poly) (n:nat) : Pure (seq bool)
(requires True)
(ensures fun s ->
length s == n /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
) | [] | Vale.Math.Poly2_s.to_seq | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Vale.Math.Poly2_s.poly -> n: Prims.nat -> Prims.Pure (FStar.Seq.Base.seq Prims.bool) | {
"end_col": 29,
"end_line": 13,
"start_col": 17,
"start_line": 13
} |
Prims.Pure | val of_seq (s:seq bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < length s /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
) | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let of_seq s = D.of_seq s | val of_seq (s:seq bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < length s /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
)
let of_seq s = | false | null | false | D.of_seq s | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [] | [
"FStar.Seq.Base.seq",
"Prims.bool",
"Vale.Math.Poly2.Defs_s.of_seq",
"Vale.Math.Poly2_s.poly"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n
let shift p n = D.shift p n
let reverse p n = D.reverse p n
let poly_index p n = D.poly_index p n | false | false | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val of_seq (s:seq bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < length s /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
) | [] | Vale.Math.Poly2_s.of_seq | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq Prims.bool -> Prims.Pure Vale.Math.Poly2_s.poly | {
"end_col": 25,
"end_line": 14,
"start_col": 15,
"start_line": 14
} |
Prims.Pure | val of_fun (len:nat) (f:nat -> bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < len /\
(forall (i:nat).{:pattern p.[i] \/ (f i)} i < len ==> p.[i] == f i) /\
(forall (i:int).{:pattern p.[i]} p.[i] ==> 0 <= i /\ i < len)
) | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let of_fun len f = D.of_fun len f | val of_fun (len:nat) (f:nat -> bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < len /\
(forall (i:nat).{:pattern p.[i] \/ (f i)} i < len ==> p.[i] == f i) /\
(forall (i:int).{:pattern p.[i]} p.[i] ==> 0 <= i /\ i < len)
)
let of_fun len f = | false | null | false | D.of_fun len f | {
"checked_file": "Vale.Math.Poly2_s.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2_s.fst"
} | [] | [
"Prims.nat",
"Prims.bool",
"Vale.Math.Poly2.Defs_s.of_fun",
"Vale.Math.Poly2_s.poly"
] | [] | module Vale.Math.Poly2_s
open FStar.Mul
open FStar.Seq
let poly = D.poly
let degree p = D.degree p
let zero = D.zero
let one = D.one
let monomial n = D.monomial n
let shift p n = D.shift p n
let reverse p n = D.reverse p n
let poly_index p n = D.poly_index p n
let to_seq s n = D.to_seq s n | false | false | Vale.Math.Poly2_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val of_fun (len:nat) (f:nat -> bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < len /\
(forall (i:nat).{:pattern p.[i] \/ (f i)} i < len ==> p.[i] == f i) /\
(forall (i:int).{:pattern p.[i]} p.[i] ==> 0 <= i /\ i < len)
) | [] | Vale.Math.Poly2_s.of_fun | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Prims.nat -> f: (_: Prims.nat -> Prims.bool) -> Prims.Pure Vale.Math.Poly2_s.poly | {
"end_col": 33,
"end_line": 15,
"start_col": 19,
"start_line": 15
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let n = 64 | let n = | false | null | false | 64 | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [
"total"
] | [] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) | false | true | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val n : Prims.int | [] | FStar.UInt64.n | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.int | {
"end_col": 17,
"end_line": 20,
"start_col": 15,
"start_line": 20
} |
|
Prims.Tot | val eq (a b: t) : Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) | val eq (a b: t) : Tot bool
let eq (a b: t) : Tot bool = | false | null | false | eq #n (v a) (v b) | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [
"total"
] | [
"FStar.UInt64.t",
"FStar.UInt.eq",
"FStar.UInt64.n",
"FStar.UInt64.v",
"Prims.bool"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality | false | true | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val eq (a b: t) : Tot bool | [] | FStar.UInt64.eq | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | {
"end_col": 49,
"end_line": 223,
"start_col": 32,
"start_line": 223
} |
Prims.Tot | val gt (a b: t) : Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) | val gt (a b: t) : Tot bool
let gt (a b: t) : Tot bool = | false | null | false | gt #n (v a) (v b) | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [
"total"
] | [
"FStar.UInt64.t",
"FStar.UInt.gt",
"FStar.UInt64.n",
"FStar.UInt64.v",
"Prims.bool"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) | false | true | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gt (a b: t) : Tot bool | [] | FStar.UInt64.gt | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | {
"end_col": 49,
"end_line": 226,
"start_col": 32,
"start_line": 226
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Plus_Percent_Hat = add_mod | let op_Plus_Percent_Hat = | false | null | false | add_mod | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [] | [
"FStar.UInt64.add_mod"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add | false | false | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Plus_Percent_Hat : a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | [] | FStar.UInt64.op_Plus_Percent_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 40,
"end_line": 317,
"start_col": 33,
"start_line": 317
} |
|
Prims.Tot | val gte (a b: t) : Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) | val gte (a b: t) : Tot bool
let gte (a b: t) : Tot bool = | false | null | false | gte #n (v a) (v b) | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [
"total"
] | [
"FStar.UInt64.t",
"FStar.UInt.gte",
"FStar.UInt64.n",
"FStar.UInt64.v",
"Prims.bool"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) | false | true | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gte (a b: t) : Tot bool | [] | FStar.UInt64.gte | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | {
"end_col": 51,
"end_line": 229,
"start_col": 33,
"start_line": 229
} |
Prims.Tot | val lt (a b: t) : Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) | val lt (a b: t) : Tot bool
let lt (a b: t) : Tot bool = | false | null | false | lt #n (v a) (v b) | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [
"total"
] | [
"FStar.UInt64.t",
"FStar.UInt.lt",
"FStar.UInt64.n",
"FStar.UInt64.v",
"Prims.bool"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) | false | true | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lt (a b: t) : Tot bool | [] | FStar.UInt64.lt | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | {
"end_col": 49,
"end_line": 232,
"start_col": 32,
"start_line": 232
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Subtraction_Question_Hat = sub_underspec | let op_Subtraction_Question_Hat = | false | null | false | sub_underspec | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [] | [
"FStar.UInt64.sub_underspec"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Plus_Question_Hat = add_underspec
unfold let op_Plus_Percent_Hat = add_mod | false | false | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction_Question_Hat : a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | [] | FStar.UInt64.op_Subtraction_Question_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 54,
"end_line": 319,
"start_col": 41,
"start_line": 319
} |
|
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Star_Question_Hat = mul_underspec | let op_Star_Question_Hat = | false | null | false | mul_underspec | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [] | [
"FStar.UInt64.mul_underspec"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Plus_Question_Hat = add_underspec
unfold let op_Plus_Percent_Hat = add_mod
unfold let op_Subtraction_Hat = sub
unfold let op_Subtraction_Question_Hat = sub_underspec
unfold let op_Subtraction_Percent_Hat = sub_mod | false | false | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Star_Question_Hat : a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | [] | FStar.UInt64.op_Star_Question_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 47,
"end_line": 322,
"start_col": 34,
"start_line": 322
} |
|
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Hat_Hat = logxor | let op_Hat_Hat = | false | null | false | logxor | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [] | [
"FStar.UInt64.logxor"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Plus_Question_Hat = add_underspec
unfold let op_Plus_Percent_Hat = add_mod
unfold let op_Subtraction_Hat = sub
unfold let op_Subtraction_Question_Hat = sub_underspec
unfold let op_Subtraction_Percent_Hat = sub_mod
unfold let op_Star_Hat = mul
unfold let op_Star_Question_Hat = mul_underspec
unfold let op_Star_Percent_Hat = mul_mod
unfold let op_Slash_Hat = div | false | false | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Hat_Hat : x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | [] | FStar.UInt64.op_Hat_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 30,
"end_line": 326,
"start_col": 24,
"start_line": 326
} |
|
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Subtraction_Hat = sub | let op_Subtraction_Hat = | false | null | false | sub | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [] | [
"FStar.UInt64.sub"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Plus_Question_Hat = add_underspec | false | false | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction_Hat : a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | [] | FStar.UInt64.op_Subtraction_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 35,
"end_line": 318,
"start_col": 32,
"start_line": 318
} |
|
Prims.Tot | val lte (a b: t) : Tot bool | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) | val lte (a b: t) : Tot bool
let lte (a b: t) : Tot bool = | false | null | false | lte #n (v a) (v b) | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [
"total"
] | [
"FStar.UInt64.t",
"FStar.UInt.lte",
"FStar.UInt64.n",
"FStar.UInt64.v",
"Prims.bool"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) | false | true | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lte (a b: t) : Tot bool | [] | FStar.UInt64.lte | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | {
"end_col": 51,
"end_line": 235,
"start_col": 33,
"start_line": 235
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Subtraction_Percent_Hat = sub_mod | let op_Subtraction_Percent_Hat = | false | null | false | sub_mod | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [] | [
"FStar.UInt64.sub_mod"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Plus_Question_Hat = add_underspec
unfold let op_Plus_Percent_Hat = add_mod
unfold let op_Subtraction_Hat = sub | false | false | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction_Percent_Hat : a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | [] | FStar.UInt64.op_Subtraction_Percent_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 47,
"end_line": 320,
"start_col": 40,
"start_line": 320
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Greater_Hat = gt | let op_Greater_Hat = | false | null | false | gt | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [
"total"
] | [
"FStar.UInt64.gt"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Plus_Question_Hat = add_underspec
unfold let op_Plus_Percent_Hat = add_mod
unfold let op_Subtraction_Hat = sub
unfold let op_Subtraction_Question_Hat = sub_underspec
unfold let op_Subtraction_Percent_Hat = sub_mod
unfold let op_Star_Hat = mul
unfold let op_Star_Question_Hat = mul_underspec
unfold let op_Star_Percent_Hat = mul_mod
unfold let op_Slash_Hat = div
unfold let op_Percent_Hat = rem
unfold let op_Hat_Hat = logxor
unfold let op_Amp_Hat = logand
unfold let op_Bar_Hat = logor
unfold let op_Less_Less_Hat = shift_left
unfold let op_Greater_Greater_Hat = shift_right | false | true | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Hat : a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | [] | FStar.UInt64.op_Greater_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | {
"end_col": 30,
"end_line": 332,
"start_col": 28,
"start_line": 332
} |
|
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Bar_Hat = logor | let op_Bar_Hat = | false | null | false | logor | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [] | [
"FStar.UInt64.logor"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Plus_Question_Hat = add_underspec
unfold let op_Plus_Percent_Hat = add_mod
unfold let op_Subtraction_Hat = sub
unfold let op_Subtraction_Question_Hat = sub_underspec
unfold let op_Subtraction_Percent_Hat = sub_mod
unfold let op_Star_Hat = mul
unfold let op_Star_Question_Hat = mul_underspec
unfold let op_Star_Percent_Hat = mul_mod
unfold let op_Slash_Hat = div
unfold let op_Percent_Hat = rem
unfold let op_Hat_Hat = logxor | false | false | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Bar_Hat : x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | [] | FStar.UInt64.op_Bar_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 29,
"end_line": 328,
"start_col": 24,
"start_line": 328
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Less_Hat = lt | let op_Less_Hat = | false | null | false | lt | {
"checked_file": "FStar.UInt64.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.UInt64.fsti"
} | [
"total"
] | [
"FStar.UInt64.lt"
] | [] | (*
Copyright 2008-2019 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.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 64
/// For FStar.UIntN.fstp: anything that you fix/update here should be
/// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of
/// this module.
///
/// Except, as compared to [FStar.IntN.fstp], here:
/// - every occurrence of [int_t] has been replaced with [uint_t]
/// - every occurrence of [@%] has been replaced with [%].
/// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers
/// This module provides an abstract type for machine integers of a
/// given signedness and width. The interface is designed to be safe
/// with respect to arithmetic underflow and overflow.
/// Note, we have attempted several times to re-design this module to
/// make it more amenable to normalization and to impose less overhead
/// on the SMT solver when reasoning about machine integer
/// arithmetic. The following github issue reports on the current
/// status of that work.
///
/// https://github.com/FStarLang/FStar/issues/1757
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(** Abstract type of machine integers, with an underlying
representation using a bounded mathematical integer *)
new val t : eqtype
(** A coercion that projects a bounded mathematical integer from a
machine integer *)
val v (x:t) : Tot (uint_t n)
(** A coercion that injects a bounded mathematical integers into a
machine integer *)
val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x))
(** Injection/projection inverse *)
val uv_inv (x : t) : Lemma
(ensures (uint_to_t (v x) == x))
[SMTPat (v x)]
(** Projection/injection inverse *)
val vu_inv (x : uint_t n) : Lemma
(ensures (v (uint_to_t x) == x))
[SMTPat (uint_to_t x)]
(** An alternate form of the injectivity of the [v] projection *)
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
(** Constants 0 and 1 *)
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
(**** Addition primitives *)
(** Bounds-respecting addition
The precondition enforces that the sum does not overflow,
expressing the bound as an addition on mathematical integers *)
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(** Underspecified, possibly overflowing addition:
The postcondition only enures that the result is the sum of the
arguments in case there is no overflow *)
val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c))
(** Addition modulo [2^n]
Machine integers can always be added, but the postcondition is now
in terms of addition modulo [2^n] on mathematical integers *)
val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
(**** Subtraction primitives *)
(** Bounds-respecting subtraction
The precondition enforces that the difference does not underflow,
expressing the bound as a difference on mathematical integers *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(** Underspecified, possibly overflowing subtraction:
The postcondition only enures that the result is the difference of
the arguments in case there is no underflow *)
val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c))
(** Subtraction modulo [2^n]
Machine integers can always be subtractd, but the postcondition is
now in terms of subtraction modulo [2^n] on mathematical integers *)
val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
(**** Multiplication primitives *)
(** Bounds-respecting multiplication
The precondition enforces that the product does not overflow,
expressing the bound as a product on mathematical integers *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(** Underspecified, possibly overflowing product
The postcondition only enures that the result is the product of
the arguments in case there is no overflow *)
val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c))
(** Multiplication modulo [2^n]
Machine integers can always be multiplied, but the postcondition
is now in terms of product modulo [2^n] on mathematical integers *)
val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
(**** Division primitives *)
(** Euclidean division of [a] and [b], with [b] non-zero *)
val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
(**** Modulo primitives *)
(** Euclidean remainder
The result is the modulus of [a] with respect to a non-zero [b] *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
(**** Bitwise operators *)
/// Also see FStar.BV
(** Bitwise logical conjunction *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
(** Bitwise logical exclusive-or *)
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
(** Bitwise logical disjunction *)
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
(** Bitwise logical negation *)
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(**** Shift operators *)
(** Shift right with zero fill, shifting at most the integer width *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
(** Shift left with zero fill, shifting at most the integer width *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
(**** Comparison operators *)
(** Equality
Note, it is safe to also use the polymorphic decidable equality
operator [=] *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
(** Greater than *)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
(** Greater than or equal *)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
(** Less than *)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
(** Less than or equal *)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(** Unary negation *)
inline_for_extraction
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
(** The maximum value for this type *)
inline_for_extraction
let n_minus_one = UInt32.uint_to_t (n - 1)
#set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1"
(** A constant-time way to compute the equality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b
Note, the branching on [a=b] is just for proof-purposes.
*)
[@ CNoInline ]
let eq_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
(v a <> v b ==> v c = 0)))
= let x = logxor a b in
let minus_x = minus x in
let x_or_minus_x = logor x minus_x in
let xnx = shift_right x_or_minus_x n_minus_one in
let c = sub_mod xnx (uint_to_t 1) in
if a = b then
begin
logxor_self (v a);
lognot_lemma_1 #n;
logor_lemma_1 (v x);
assert (v x = 0 /\ v minus_x = 0 /\
v x_or_minus_x = 0 /\ v xnx = 0);
assert (v c = ones n)
end
else
begin
logxor_neq_nonzero (v a) (v b);
lemma_msb_pow2 #n (v (lognot x));
lemma_msb_pow2 #n (v minus_x);
lemma_minus_zero #n (v x);
assert (v c = FStar.UInt.zero n)
end;
c
private
val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
(** A constant-time way to compute the [>=] inequality of
two machine integers.
With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a
*)
[@ CNoInline ]
let gte_mask (a:t) (b:t)
: Pure t
(requires True)
(ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
(v a < v b ==> v c = 0)))
= let x = a in
let y = b in
let x_xor_y = logxor x y in
let x_sub_y = sub_mod x y in
let x_sub_y_xor_y = logxor x_sub_y y in
let q = logor x_xor_y x_sub_y_xor_y in
let x_xor_q = logxor x q in
let x_xor_q_ = shift_right x_xor_q n_minus_one in
let c = sub_mod x_xor_q_ (uint_to_t 1) in
lemma_sub_msbs x y;
lemma_msb_gte (v x) (v y);
lemma_msb_gte (v y) (v x);
c
#reset-options
(*** Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Plus_Question_Hat = add_underspec
unfold let op_Plus_Percent_Hat = add_mod
unfold let op_Subtraction_Hat = sub
unfold let op_Subtraction_Question_Hat = sub_underspec
unfold let op_Subtraction_Percent_Hat = sub_mod
unfold let op_Star_Hat = mul
unfold let op_Star_Question_Hat = mul_underspec
unfold let op_Star_Percent_Hat = mul_mod
unfold let op_Slash_Hat = div
unfold let op_Percent_Hat = rem
unfold let op_Hat_Hat = logxor
unfold let op_Amp_Hat = logand
unfold let op_Bar_Hat = logor
unfold let op_Less_Less_Hat = shift_left
unfold let op_Greater_Greater_Hat = shift_right
unfold let op_Equals_Hat = eq
unfold let op_Greater_Hat = gt | false | true | FStar.UInt64.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Hat : a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | [] | FStar.UInt64.op_Less_Hat | {
"file_name": "ulib/FStar.UInt64.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.bool | {
"end_col": 27,
"end_line": 334,
"start_col": 25,
"start_line": 334
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.