file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hacl.HMAC.fst | Hacl.HMAC.xor_bytes_inplace | val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b)) | val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b)) | let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. ) | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 40,
"start_col": 0,
"start_line": 39
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b)) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: LowStar.Buffer.buffer Lib.IntTypes.uint8 ->
b: LowStar.Buffer.buffer Lib.IntTypes.uint8 ->
len:
FStar.UInt32.t
{ Lib.IntTypes.v len = LowStar.Monotonic.Buffer.length a /\
Lib.IntTypes.v len = LowStar.Monotonic.Buffer.length b }
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"C.Loops.in_place_map2",
"Lib.IntTypes.op_Hat_Dot",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit"
] | [] | false | true | false | false | false | let xor_bytes_inplace a b len =
| C.Loops.in_place_map2 a b len ( ^. ) | false |
Hacl.HMAC.fst | Hacl.HMAC.split_nb_rem_extend_one_block | val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1) | val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1) | let split_nb_rem_extend_one_block l d =
FStar.Math.Lemmas.add_div_mod_1 d l | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 259,
"start_col": 0,
"start_line": 258
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len }
noextract inline_for_extraction
let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len))
inline_for_extraction noextract
val part2_update_nonempty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len > 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
open FStar.Mul
val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.pos -> d: Prims.pos
-> FStar.Pervasives.Lemma
(ensures
(let _ = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ nb rem = _ in
let _ = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ nb' rem' = _ in
rem == rem' /\ nb == nb' + 1)
<:
Type0)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"FStar.Math.Lemmas.add_div_mod_1",
"Prims.unit"
] | [] | true | false | true | false | false | let split_nb_rem_extend_one_block l d =
| FStar.Math.Lemmas.add_div_mod_1 d l | false |
Hacl.HMAC.fst | Hacl.HMAC.helper_smtpat | val helper_smtpat (a: fixed_len_alg) (len: uint32_t{(v len) `less_than_max_input_length` a})
: x: uint32_t{x `FStar.UInt32.lte` (D.block_len a)} | val helper_smtpat (a: fixed_len_alg) (len: uint32_t{(v len) `less_than_max_input_length` a})
: x: uint32_t{x `FStar.UInt32.lte` (D.block_len a)} | let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 62,
"start_col": 0,
"start_line": 60
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly. | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.fixed_len_alg ->
len:
EverCrypt.Helpers.uint32_t
{Spec.Hash.Definitions.less_than_max_input_length (Lib.IntTypes.v len) a}
-> x: EverCrypt.Helpers.uint32_t{FStar.UInt32.lte x (Hacl.Hash.Definitions.block_len a)} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.fixed_len_alg",
"EverCrypt.Helpers.uint32_t",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.lte",
"Hacl.Hash.Definitions.block_len",
"Prims.bool",
"Hacl.Hash.Definitions.hash_len"
] | [] | false | false | false | false | false | let helper_smtpat (a: fixed_len_alg) (len: uint32_t{(v len) `less_than_max_input_length` a})
: x: uint32_t{x `FStar.UInt32.lte` (D.block_len a)} =
| if len `FStar.UInt32.lte` (D.block_len a) then len else D.hash_len a | false |
LowParse.Spec.SeqBytes.Base.fst | LowParse.Spec.SeqBytes.Base.serialize_seq_flbytes_correct | val serialize_seq_flbytes_correct (sz: nat)
: Lemma (serializer_correct (parse_seq_flbytes sz) (serialize_seq_flbytes' sz)) | val serialize_seq_flbytes_correct (sz: nat)
: Lemma (serializer_correct (parse_seq_flbytes sz) (serialize_seq_flbytes' sz)) | let serialize_seq_flbytes_correct
(sz: nat)
: Lemma
(serializer_correct (parse_seq_flbytes sz) (serialize_seq_flbytes' sz))
= let prf
(input: Seq.lseq byte sz)
: Lemma
(
let ser = serialize_seq_flbytes' sz input in
Seq.length ser == sz /\
parse (parse_seq_flbytes sz) ser == Some (input, sz)
)
= ()
in
Classical.forall_intro prf | {
"file_name": "src/lowparse/LowParse.Spec.SeqBytes.Base.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 28,
"end_line": 41,
"start_col": 0,
"start_line": 27
} | module LowParse.Spec.SeqBytes.Base
include LowParse.Spec.FLData
let parse_seq_flbytes_gen
(sz: nat)
(s: bytes { Seq.length s == sz } )
: Tot (Seq.lseq byte sz)
= s
let tot_parse_seq_flbytes
(sz: nat)
: Tot (tot_parser (total_constant_size_parser_kind sz) (Seq.lseq byte sz))
= tot_make_total_constant_size_parser sz (Seq.lseq byte sz) (parse_seq_flbytes_gen sz)
let parse_seq_flbytes
(sz: nat)
: Tot (parser (total_constant_size_parser_kind sz) (Seq.lseq byte sz))
= tot_parse_seq_flbytes sz
let serialize_seq_flbytes'
(sz: nat)
: Tot (bare_serializer (Seq.lseq byte sz))
= fun (x: Seq.lseq byte sz) -> (
x
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.FLData.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.SeqBytes.Base.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.SeqBytes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.serializer_correct (LowParse.Spec.SeqBytes.Base.parse_seq_flbytes sz)
(LowParse.Spec.SeqBytes.Base.serialize_seq_flbytes' sz)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"FStar.Classical.forall_intro",
"FStar.Seq.Properties.lseq",
"LowParse.Bytes.byte",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.length",
"LowParse.Spec.SeqBytes.Base.serialize_seq_flbytes'",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.SeqBytes.Base.parse_seq_flbytes",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.serializer_correct",
"LowParse.Spec.Base.total_constant_size_parser_kind"
] | [] | false | false | true | false | false | let serialize_seq_flbytes_correct (sz: nat)
: Lemma (serializer_correct (parse_seq_flbytes sz) (serialize_seq_flbytes' sz)) =
| let prf (input: Seq.lseq byte sz)
: Lemma
(let ser = serialize_seq_flbytes' sz input in
Seq.length ser == sz /\ parse (parse_seq_flbytes sz) ser == Some (input, sz)) =
()
in
Classical.forall_intro prf | false |
Hacl.HMAC.fst | Hacl.HMAC.block_len_as_len | val block_len_as_len (a: fixed_len_alg{not (is_keccak a)})
: Tot (l: len_t a {len_v a l = block_length a}) | val block_len_as_len (a: fixed_len_alg{not (is_keccak a)})
: Tot (l: len_t a {len_v a l = block_length a}) | let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a)) | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 89,
"end_line": 103,
"start_col": 0,
"start_line": 96
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.fixed_len_alg{Prims.op_Negation (Spec.Hash.Definitions.is_keccak a)}
-> l:
Spec.Hash.Definitions.len_t a
{Spec.Hash.Definitions.len_v a l = Spec.Hash.Definitions.block_length a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.fixed_len_alg",
"Prims.b2t",
"Prims.op_Negation",
"Spec.Hash.Definitions.is_keccak",
"FStar.Int.Cast.uint32_to_uint64",
"Hacl.Hash.Definitions.block_len",
"FStar.Int.Cast.Full.uint64_to_uint128",
"Spec.Hash.Definitions.len_t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"Spec.Hash.Definitions.len_v",
"Spec.Hash.Definitions.block_length",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.pow2"
] | [] | false | false | false | false | false | let block_len_as_len (a: fixed_len_alg{not (is_keccak a)})
: Tot (l: len_t a {len_v a l = block_length a}) =
| let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a)) | false |
Hacl.HMAC.fst | Hacl.HMAC.compute_sha1 | val compute_sha1: compute_st SHA1 | val compute_sha1: compute_st SHA1 | let compute_sha1: compute_st SHA1 =
let open Hacl.Hash.SHA1 in
mk_compute (D.mk_impl SHA1 ()) hash_oneshot alloca init
update_multi update_last finish | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 44,
"end_line": 435,
"start_col": 0,
"start_line": 432
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len }
noextract inline_for_extraction
let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len))
inline_for_extraction noextract
val part2_update_nonempty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len > 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
open FStar.Mul
val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1)
let split_nb_rem_extend_one_block l d =
FStar.Math.Lemmas.add_div_mod_1 d l
#push-options "--z3rlimit 400"
let part2_update_nonempty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
let block_len = D.block_len a in
let n_blocks, rem_len = Lib.UpdateMulti.split_at_last_st block_len len in
let full_blocks_len = n_blocks `FStar.UInt32.mul` block_len in
let full_blocks = B.sub data 0ul full_blocks_len in
let rem = B.sub data full_blocks_len rem_len in
(**) assert (S.length key_data_v0 == v len + block_length a);
(**) split_nb_rem_extend_one_block (block_length a) (v len);
(**) assert (let bs, l = split_blocks a key_data_v0 in
bs `S.equal` (key_v0 `S.append` B.as_seq h0 full_blocks) /\
l `S.equal` B.as_seq h0 rem);
[@inline_let]
let ev = if is_blake a then zero_to_len a else () in
(**) assert (D.ev_v ev == init_extra_state a);
(**) assert (B.length key == block_length a * 1);
update_multi s ev key 1ul;
(**) let h1 = ST.get () in
(**) assert (D.as_seq h1 s ==
(**) Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) key_v0));
[@inline_let]
let ev1 = uint32_to_ev a block_len in
update_multi s ev1 full_blocks n_blocks;
(**) let h2 = ST.get () in
(**) let aux () : Lemma (D.as_seq h2 s == Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) (S.append key_v0 (B.as_seq h0 full_blocks))))
(**) = if is_blake a then
(**) update_multi_associative_blake a (D.as_seq h0 s) (init_extra_state a) (v block_len) key_v0 (B.as_seq h0 full_blocks)
(**) else
(**) update_multi_associative a (D.as_seq h0 s) key_v0 (B.as_seq h0 full_blocks)
(**) in
(**) aux ();
[@inline_let]
let prev_len: prev_len:D.prev_len_t a
{ if is_keccak a then True else len_v a prev_len % block_length a = 0 }
=
if is_keccak a then () else
len_add32 a (block_len_as_len a) full_blocks_len
in
update_last s prev_len rem rem_len
#pop-options
inline_for_extraction noextract
let part2 a m init update_multi update_last finish s dst key data len =
(**) key_and_data_fits a;
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) let h1 = ST.get () in
(**) assert(B.(modifies (loc_buffer s) h0 h1));
(**) let init_v : Ghost.erased (init_t a) = Spec.Agile.Hash.init a in
(**) assert (D.as_seq h1 s == Ghost.reveal init_v);
if len = 0ul then (
part2_update_empty a m init update_multi update_last s key data len
) else (
part2_update_nonempty a m init update_multi update_last s key data len
);
(**) let h3 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h1 (loc_union (loc_buffer s) (loc_buffer dst)) h3);
finish s dst;
(**) let h4 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h3 (loc_union (loc_buffer s) (loc_buffer dst)) h4);
(**) assert (B.as_seq h4 dst == hash_incremental a key_data_v0 ());
calc (Seq.equal) {
B.as_seq h4 dst;
(Seq.equal) { }
hash_incremental a key_data_v0 ();
(Seq.equal) { hash_is_hash_incremental' a key_data_v0 () }
hash' a key_data_v0 ();
(Seq.equal) { }
hash a key_data_v0;
}
/// This implementation is optimized. First, it reuses an existing hash state
/// ``s`` rather than allocating a new one. Second, it writes out the result of
/// the hash directly in its parameter ``key`` rather than taking a destination
/// output buffer.
inline_for_extraction noextract
val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
let part1 a m init update_multi update_last finish s key data len =
let dst = B.sub key 0ul (D.hash_len a) in
part2 a m init update_multi update_last finish s dst key data len
let block_len_positive (a: hash_alg): Lemma (D.block_len a `FStar.UInt32.gt` 0ul) = ()
let hash_lt_block (a: fixed_len_alg): Lemma (hash_length a < block_length a) = ()
#set-options "--z3rlimit 200"
let mk_compute i hash alloca init update_multi update_last finish dst key key_len data data_len =
[@inline_let] let a = D.get_alg i in
[@inline_let] let m = D.get_spec i in
block_len_positive a;
hash_lt_block a;
(**) let h0 = ST.get() in
push_frame ();
(**) let h1 = ST.get () in
let l = D.block_len a in
let key_block = B.alloca (u8 0x00) l in
mk_wrap_key a hash key_block key key_len;
(**) let h2 = ST.get () in
(**) assert (B.as_seq h2 key_block `Seq.equal` wrap a (B.as_seq h0 key));
let ipad = B.alloca (u8 0x36) l in
xor_bytes_inplace ipad key_block l;
(**) let h3 = ST.get () in
(**) assert (B.as_seq h3 ipad `Seq.equal` S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
let opad = B.alloca (u8 0x5c) l in
xor_bytes_inplace opad key_block l;
(**) let h4 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad
(**) `loc_union` loc_buffer opad) h1 h4);
(**) S.lemma_eq_intro (B.as_seq h4 ipad) (S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 opad) (S.(xor (u8 0x5c) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 data) (B.as_seq h0 data);
let s = alloca () in
part1 a m init update_multi update_last finish s ipad data data_len;
(**) key_and_data_fits a;
(**) let h5 = ST.get () in
(**) S.lemma_eq_intro (S.slice (B.as_seq h5 ipad) 0 (hash_length a))
(**) (Spec.Agile.Hash.hash a S.(append (xor (u8 0x36) (wrap a (B.as_seq h0 key)))
(**) (B.as_seq h0 data)));
let hash1 = B.sub ipad 0ul (D.hash_len a) in
init s;
part2 a m init update_multi update_last finish s dst opad hash1 (D.hash_len a);
(**) let h6 = ST.get () in
(**) assert (B.as_seq h6 dst `S.equal` hmac a (B.as_seq h0 key) (B.as_seq h0 data));
pop_frame ();
(**) let h7 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad `loc_union`
(**) loc_buffer opad `loc_union` loc_buffer s) h1 h2);
(**) LowStar.Monotonic.Buffer.modifies_fresh_frame_popped h0 h1 (B.loc_buffer dst) h6 h7 | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.HMAC.compute_st Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Hacl.HMAC.mk_compute",
"Hacl.Hash.Definitions.mk_impl",
"Spec.Hash.Definitions.SHA1",
"Hacl.Hash.SHA1.hash_oneshot",
"Hacl.Hash.Core.SHA1.alloca",
"Hacl.Hash.Core.SHA1.init",
"Hacl.Hash.SHA1.update_multi",
"Hacl.Hash.SHA1.update_last",
"Hacl.Hash.Core.SHA1.finish",
"Hacl.HMAC.compute_st"
] | [] | false | false | false | true | false | let compute_sha1:compute_st SHA1 =
| let open Hacl.Hash.SHA1 in
mk_compute (D.mk_impl SHA1 ()) hash_oneshot alloca init update_multi update_last finish | false |
Hacl.HMAC.fst | Hacl.HMAC.compute_sha2_512 | val compute_sha2_512: compute_st SHA2_512 | val compute_sha2_512: compute_st SHA2_512 | let compute_sha2_512: compute_st SHA2_512 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_512 ()) hash_512 alloca_512 init_512
update_multi_512 update_last_512 finish_512 | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 56,
"end_line": 453,
"start_col": 0,
"start_line": 449
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len }
noextract inline_for_extraction
let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len))
inline_for_extraction noextract
val part2_update_nonempty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len > 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
open FStar.Mul
val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1)
let split_nb_rem_extend_one_block l d =
FStar.Math.Lemmas.add_div_mod_1 d l
#push-options "--z3rlimit 400"
let part2_update_nonempty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
let block_len = D.block_len a in
let n_blocks, rem_len = Lib.UpdateMulti.split_at_last_st block_len len in
let full_blocks_len = n_blocks `FStar.UInt32.mul` block_len in
let full_blocks = B.sub data 0ul full_blocks_len in
let rem = B.sub data full_blocks_len rem_len in
(**) assert (S.length key_data_v0 == v len + block_length a);
(**) split_nb_rem_extend_one_block (block_length a) (v len);
(**) assert (let bs, l = split_blocks a key_data_v0 in
bs `S.equal` (key_v0 `S.append` B.as_seq h0 full_blocks) /\
l `S.equal` B.as_seq h0 rem);
[@inline_let]
let ev = if is_blake a then zero_to_len a else () in
(**) assert (D.ev_v ev == init_extra_state a);
(**) assert (B.length key == block_length a * 1);
update_multi s ev key 1ul;
(**) let h1 = ST.get () in
(**) assert (D.as_seq h1 s ==
(**) Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) key_v0));
[@inline_let]
let ev1 = uint32_to_ev a block_len in
update_multi s ev1 full_blocks n_blocks;
(**) let h2 = ST.get () in
(**) let aux () : Lemma (D.as_seq h2 s == Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) (S.append key_v0 (B.as_seq h0 full_blocks))))
(**) = if is_blake a then
(**) update_multi_associative_blake a (D.as_seq h0 s) (init_extra_state a) (v block_len) key_v0 (B.as_seq h0 full_blocks)
(**) else
(**) update_multi_associative a (D.as_seq h0 s) key_v0 (B.as_seq h0 full_blocks)
(**) in
(**) aux ();
[@inline_let]
let prev_len: prev_len:D.prev_len_t a
{ if is_keccak a then True else len_v a prev_len % block_length a = 0 }
=
if is_keccak a then () else
len_add32 a (block_len_as_len a) full_blocks_len
in
update_last s prev_len rem rem_len
#pop-options
inline_for_extraction noextract
let part2 a m init update_multi update_last finish s dst key data len =
(**) key_and_data_fits a;
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) let h1 = ST.get () in
(**) assert(B.(modifies (loc_buffer s) h0 h1));
(**) let init_v : Ghost.erased (init_t a) = Spec.Agile.Hash.init a in
(**) assert (D.as_seq h1 s == Ghost.reveal init_v);
if len = 0ul then (
part2_update_empty a m init update_multi update_last s key data len
) else (
part2_update_nonempty a m init update_multi update_last s key data len
);
(**) let h3 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h1 (loc_union (loc_buffer s) (loc_buffer dst)) h3);
finish s dst;
(**) let h4 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h3 (loc_union (loc_buffer s) (loc_buffer dst)) h4);
(**) assert (B.as_seq h4 dst == hash_incremental a key_data_v0 ());
calc (Seq.equal) {
B.as_seq h4 dst;
(Seq.equal) { }
hash_incremental a key_data_v0 ();
(Seq.equal) { hash_is_hash_incremental' a key_data_v0 () }
hash' a key_data_v0 ();
(Seq.equal) { }
hash a key_data_v0;
}
/// This implementation is optimized. First, it reuses an existing hash state
/// ``s`` rather than allocating a new one. Second, it writes out the result of
/// the hash directly in its parameter ``key`` rather than taking a destination
/// output buffer.
inline_for_extraction noextract
val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
let part1 a m init update_multi update_last finish s key data len =
let dst = B.sub key 0ul (D.hash_len a) in
part2 a m init update_multi update_last finish s dst key data len
let block_len_positive (a: hash_alg): Lemma (D.block_len a `FStar.UInt32.gt` 0ul) = ()
let hash_lt_block (a: fixed_len_alg): Lemma (hash_length a < block_length a) = ()
#set-options "--z3rlimit 200"
let mk_compute i hash alloca init update_multi update_last finish dst key key_len data data_len =
[@inline_let] let a = D.get_alg i in
[@inline_let] let m = D.get_spec i in
block_len_positive a;
hash_lt_block a;
(**) let h0 = ST.get() in
push_frame ();
(**) let h1 = ST.get () in
let l = D.block_len a in
let key_block = B.alloca (u8 0x00) l in
mk_wrap_key a hash key_block key key_len;
(**) let h2 = ST.get () in
(**) assert (B.as_seq h2 key_block `Seq.equal` wrap a (B.as_seq h0 key));
let ipad = B.alloca (u8 0x36) l in
xor_bytes_inplace ipad key_block l;
(**) let h3 = ST.get () in
(**) assert (B.as_seq h3 ipad `Seq.equal` S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
let opad = B.alloca (u8 0x5c) l in
xor_bytes_inplace opad key_block l;
(**) let h4 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad
(**) `loc_union` loc_buffer opad) h1 h4);
(**) S.lemma_eq_intro (B.as_seq h4 ipad) (S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 opad) (S.(xor (u8 0x5c) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 data) (B.as_seq h0 data);
let s = alloca () in
part1 a m init update_multi update_last finish s ipad data data_len;
(**) key_and_data_fits a;
(**) let h5 = ST.get () in
(**) S.lemma_eq_intro (S.slice (B.as_seq h5 ipad) 0 (hash_length a))
(**) (Spec.Agile.Hash.hash a S.(append (xor (u8 0x36) (wrap a (B.as_seq h0 key)))
(**) (B.as_seq h0 data)));
let hash1 = B.sub ipad 0ul (D.hash_len a) in
init s;
part2 a m init update_multi update_last finish s dst opad hash1 (D.hash_len a);
(**) let h6 = ST.get () in
(**) assert (B.as_seq h6 dst `S.equal` hmac a (B.as_seq h0 key) (B.as_seq h0 data));
pop_frame ();
(**) let h7 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad `loc_union`
(**) loc_buffer opad `loc_union` loc_buffer s) h1 h2);
(**) LowStar.Monotonic.Buffer.modifies_fresh_frame_popped h0 h1 (B.loc_buffer dst) h6 h7
let compute_sha1: compute_st SHA1 =
let open Hacl.Hash.SHA1 in
mk_compute (D.mk_impl SHA1 ()) hash_oneshot alloca init
update_multi update_last finish
let compute_sha2_256: compute_st SHA2_256 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_256 ()) hash_256 alloca_256 init_256
update_multi_256 update_last_256 finish_256
let compute_sha2_384: compute_st SHA2_384 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_384 ()) hash_384 alloca_384 init_384
update_multi_384 update_last_384 finish_384 | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.HMAC.compute_st Spec.Hash.Definitions.SHA2_512 | Prims.Tot | [
"total"
] | [] | [
"Hacl.HMAC.mk_compute",
"Hacl.Hash.Definitions.mk_impl",
"Spec.Hash.Definitions.SHA2_512",
"Hacl.Streaming.SHA2.hash_512",
"Hacl.Hash.SHA2.alloca_512",
"Hacl.Hash.SHA2.init_512",
"Hacl.Hash.SHA2.update_multi_512",
"Hacl.Hash.SHA2.update_last_512",
"Hacl.Hash.SHA2.finish_512",
"Hacl.HMAC.compute_st"
] | [] | false | false | false | true | false | let compute_sha2_512:compute_st SHA2_512 =
| let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_512 ())
hash_512
alloca_512
init_512
update_multi_512
update_last_512
finish_512 | false |
Hacl.HMAC.fst | Hacl.HMAC.compute_blake2s_32 | val compute_blake2s_32: compute_st Blake2S | val compute_blake2s_32: compute_st Blake2S | let compute_blake2s_32: compute_st Blake2S =
let open Hacl.Hash.Blake2s_32 in
mk_compute (D.mk_impl Blake2S C.M32) hash alloca init update_multi update_last finish | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 87,
"end_line": 457,
"start_col": 0,
"start_line": 455
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len }
noextract inline_for_extraction
let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len))
inline_for_extraction noextract
val part2_update_nonempty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len > 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
open FStar.Mul
val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1)
let split_nb_rem_extend_one_block l d =
FStar.Math.Lemmas.add_div_mod_1 d l
#push-options "--z3rlimit 400"
let part2_update_nonempty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
let block_len = D.block_len a in
let n_blocks, rem_len = Lib.UpdateMulti.split_at_last_st block_len len in
let full_blocks_len = n_blocks `FStar.UInt32.mul` block_len in
let full_blocks = B.sub data 0ul full_blocks_len in
let rem = B.sub data full_blocks_len rem_len in
(**) assert (S.length key_data_v0 == v len + block_length a);
(**) split_nb_rem_extend_one_block (block_length a) (v len);
(**) assert (let bs, l = split_blocks a key_data_v0 in
bs `S.equal` (key_v0 `S.append` B.as_seq h0 full_blocks) /\
l `S.equal` B.as_seq h0 rem);
[@inline_let]
let ev = if is_blake a then zero_to_len a else () in
(**) assert (D.ev_v ev == init_extra_state a);
(**) assert (B.length key == block_length a * 1);
update_multi s ev key 1ul;
(**) let h1 = ST.get () in
(**) assert (D.as_seq h1 s ==
(**) Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) key_v0));
[@inline_let]
let ev1 = uint32_to_ev a block_len in
update_multi s ev1 full_blocks n_blocks;
(**) let h2 = ST.get () in
(**) let aux () : Lemma (D.as_seq h2 s == Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) (S.append key_v0 (B.as_seq h0 full_blocks))))
(**) = if is_blake a then
(**) update_multi_associative_blake a (D.as_seq h0 s) (init_extra_state a) (v block_len) key_v0 (B.as_seq h0 full_blocks)
(**) else
(**) update_multi_associative a (D.as_seq h0 s) key_v0 (B.as_seq h0 full_blocks)
(**) in
(**) aux ();
[@inline_let]
let prev_len: prev_len:D.prev_len_t a
{ if is_keccak a then True else len_v a prev_len % block_length a = 0 }
=
if is_keccak a then () else
len_add32 a (block_len_as_len a) full_blocks_len
in
update_last s prev_len rem rem_len
#pop-options
inline_for_extraction noextract
let part2 a m init update_multi update_last finish s dst key data len =
(**) key_and_data_fits a;
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) let h1 = ST.get () in
(**) assert(B.(modifies (loc_buffer s) h0 h1));
(**) let init_v : Ghost.erased (init_t a) = Spec.Agile.Hash.init a in
(**) assert (D.as_seq h1 s == Ghost.reveal init_v);
if len = 0ul then (
part2_update_empty a m init update_multi update_last s key data len
) else (
part2_update_nonempty a m init update_multi update_last s key data len
);
(**) let h3 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h1 (loc_union (loc_buffer s) (loc_buffer dst)) h3);
finish s dst;
(**) let h4 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h3 (loc_union (loc_buffer s) (loc_buffer dst)) h4);
(**) assert (B.as_seq h4 dst == hash_incremental a key_data_v0 ());
calc (Seq.equal) {
B.as_seq h4 dst;
(Seq.equal) { }
hash_incremental a key_data_v0 ();
(Seq.equal) { hash_is_hash_incremental' a key_data_v0 () }
hash' a key_data_v0 ();
(Seq.equal) { }
hash a key_data_v0;
}
/// This implementation is optimized. First, it reuses an existing hash state
/// ``s`` rather than allocating a new one. Second, it writes out the result of
/// the hash directly in its parameter ``key`` rather than taking a destination
/// output buffer.
inline_for_extraction noextract
val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
let part1 a m init update_multi update_last finish s key data len =
let dst = B.sub key 0ul (D.hash_len a) in
part2 a m init update_multi update_last finish s dst key data len
let block_len_positive (a: hash_alg): Lemma (D.block_len a `FStar.UInt32.gt` 0ul) = ()
let hash_lt_block (a: fixed_len_alg): Lemma (hash_length a < block_length a) = ()
#set-options "--z3rlimit 200"
let mk_compute i hash alloca init update_multi update_last finish dst key key_len data data_len =
[@inline_let] let a = D.get_alg i in
[@inline_let] let m = D.get_spec i in
block_len_positive a;
hash_lt_block a;
(**) let h0 = ST.get() in
push_frame ();
(**) let h1 = ST.get () in
let l = D.block_len a in
let key_block = B.alloca (u8 0x00) l in
mk_wrap_key a hash key_block key key_len;
(**) let h2 = ST.get () in
(**) assert (B.as_seq h2 key_block `Seq.equal` wrap a (B.as_seq h0 key));
let ipad = B.alloca (u8 0x36) l in
xor_bytes_inplace ipad key_block l;
(**) let h3 = ST.get () in
(**) assert (B.as_seq h3 ipad `Seq.equal` S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
let opad = B.alloca (u8 0x5c) l in
xor_bytes_inplace opad key_block l;
(**) let h4 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad
(**) `loc_union` loc_buffer opad) h1 h4);
(**) S.lemma_eq_intro (B.as_seq h4 ipad) (S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 opad) (S.(xor (u8 0x5c) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 data) (B.as_seq h0 data);
let s = alloca () in
part1 a m init update_multi update_last finish s ipad data data_len;
(**) key_and_data_fits a;
(**) let h5 = ST.get () in
(**) S.lemma_eq_intro (S.slice (B.as_seq h5 ipad) 0 (hash_length a))
(**) (Spec.Agile.Hash.hash a S.(append (xor (u8 0x36) (wrap a (B.as_seq h0 key)))
(**) (B.as_seq h0 data)));
let hash1 = B.sub ipad 0ul (D.hash_len a) in
init s;
part2 a m init update_multi update_last finish s dst opad hash1 (D.hash_len a);
(**) let h6 = ST.get () in
(**) assert (B.as_seq h6 dst `S.equal` hmac a (B.as_seq h0 key) (B.as_seq h0 data));
pop_frame ();
(**) let h7 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad `loc_union`
(**) loc_buffer opad `loc_union` loc_buffer s) h1 h2);
(**) LowStar.Monotonic.Buffer.modifies_fresh_frame_popped h0 h1 (B.loc_buffer dst) h6 h7
let compute_sha1: compute_st SHA1 =
let open Hacl.Hash.SHA1 in
mk_compute (D.mk_impl SHA1 ()) hash_oneshot alloca init
update_multi update_last finish
let compute_sha2_256: compute_st SHA2_256 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_256 ()) hash_256 alloca_256 init_256
update_multi_256 update_last_256 finish_256
let compute_sha2_384: compute_st SHA2_384 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_384 ()) hash_384 alloca_384 init_384
update_multi_384 update_last_384 finish_384
let compute_sha2_512: compute_st SHA2_512 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_512 ()) hash_512 alloca_512 init_512
update_multi_512 update_last_512 finish_512 | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.HMAC.compute_st Spec.Hash.Definitions.Blake2S | Prims.Tot | [
"total"
] | [] | [
"Hacl.HMAC.mk_compute",
"Hacl.Hash.Definitions.mk_impl",
"Spec.Hash.Definitions.Blake2S",
"Hacl.Impl.Blake2.Core.M32",
"Hacl.Hash.Blake2s_32.hash",
"Hacl.Hash.Blake2s_32.alloca",
"Hacl.Hash.Blake2s_32.init",
"Hacl.Hash.Blake2s_32.update_multi",
"Hacl.Hash.Blake2s_32.update_last",
"Hacl.Hash.Blake2s_32.finish",
"Hacl.HMAC.compute_st"
] | [] | false | false | false | true | false | let compute_blake2s_32:compute_st Blake2S =
| let open Hacl.Hash.Blake2s_32 in
mk_compute (D.mk_impl Blake2S C.M32) hash alloca init update_multi update_last finish | false |
Steel.MonotonicHigherReference.fst | Steel.MonotonicHigherReference.intro_pure_full | val intro_pure_full (#a #p #f: _) (r: ref a p) (v: a) (h: history a p {history_val h v f})
: SteelT unit (PR.pts_to r h) (fun _ -> pts_to r f v) | val intro_pure_full (#a #p #f: _) (r: ref a p) (v: a) (h: history a p {history_val h v f})
: SteelT unit (PR.pts_to r h) (fun _ -> pts_to r f v) | let intro_pure_full #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelT unit
(PR.pts_to r h)
(fun _ -> pts_to r f v)
= intro_pure #a #p #f r v h;
intro_exists h (pts_to_body r f v) | {
"file_name": "lib/steel/Steel.MonotonicHigherReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 38,
"end_line": 67,
"start_col": 0,
"start_line": 59
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.MonotonicHigherReference
open FStar.Ghost
open FStar.PCM
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.PCMReference
open Steel.FractionalPermission
open Steel.Preorder
module Preorder = FStar.Preorder
module Q = Steel.Preorder
module M = Steel.Memory
module PR = Steel.PCMReference
open FStar.Real
#set-options "--ide_id_info_off"
let ref a p = M.ref (history a p) pcm_history
[@@__reduce__]
let pts_to_body #a #p (r:ref a p) (f:perm) (v:Ghost.erased a) (h:history a p) =
PR.pts_to r h `star`
pure (history_val h v f)
let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:Ghost.erased a) =
h_exists (pts_to_body r f v)
let pts_to_sl r f v = hp_of (pts_to' r f v)
let intro_pure #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelT unit
(PR.pts_to r h)
(fun _ -> pts_to_body r f v h)
= rewrite_slprop (PR.pts_to r h) (pts_to_body _ _ _ _) (fun m ->
emp_unit (M.pts_to r h);
pure_star_interp (M.pts_to r h) (history_val h v f) m) | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.PCMReference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.MonotonicHigherReference.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.PCMReference",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Steel.Preorder",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.PCMReference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: Steel.MonotonicHigherReference.ref a p ->
v: a ->
h: Steel.Preorder.history a p {Steel.Preorder.history_val h (FStar.Ghost.hide v) f}
-> Steel.Effect.SteelT Prims.unit | Steel.Effect.SteelT | [] | [] | [
"FStar.Preorder.preorder",
"Steel.FractionalPermission.perm",
"Steel.MonotonicHigherReference.ref",
"Steel.Preorder.history",
"Steel.Preorder.history_val",
"FStar.Ghost.hide",
"Steel.Effect.Atomic.intro_exists",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.MonotonicHigherReference.pts_to_body",
"Prims.unit",
"Steel.MonotonicHigherReference.intro_pure",
"Steel.PCMReference.pts_to",
"Steel.Preorder.pcm_history",
"Steel.MonotonicHigherReference.pts_to",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let intro_pure_full #a #p #f (r: ref a p) (v: a) (h: history a p {history_val h v f})
: SteelT unit (PR.pts_to r h) (fun _ -> pts_to r f v) =
| intro_pure #a #p #f r v h;
intro_exists h (pts_to_body r f v) | false |
Hacl.HMAC.fst | Hacl.HMAC.zero_to_len | val zero_to_len (a: hash_alg) : (if is_keccak a then unit else (x: len_t a {len_v a x == 0})) | val zero_to_len (a: hash_alg) : (if is_keccak a then unit else (x: len_t a {len_v a x == 0})) | let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> () | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 73,
"end_line": 147,
"start_col": 0,
"start_line": 140
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.hash_alg
-> ((match Spec.Hash.Definitions.is_keccak a with
| true -> Prims.unit
| _ -> x: Spec.Hash.Definitions.len_t a {Spec.Hash.Definitions.len_v a x == 0})
<:
Type0) | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"FStar.UInt64.uint_to_t",
"FStar.Int.Cast.Full.uint64_to_uint128",
"Spec.Hash.Definitions.is_keccak",
"Prims.unit",
"Prims.bool",
"Spec.Hash.Definitions.len_t",
"Prims.eq2",
"Prims.int",
"Spec.Hash.Definitions.len_v"
] | [] | false | false | false | false | false | let zero_to_len (a: hash_alg) : (if is_keccak a then unit else (x: len_t a {len_v a x == 0})) =
| match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512 | Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> () | false |
Hacl.HMAC.fst | Hacl.HMAC.uint32_to_ev | val uint32_to_ev (a: hash_alg) (n: UInt32.t{v n % block_length a == 0})
: ev: D.extra_state a {if is_blake a then D.ev_v #a ev == v n else True} | val uint32_to_ev (a: hash_alg) (n: UInt32.t{v n % block_length a == 0})
: ev: D.extra_state a {if is_blake a then D.ev_v #a ev == v n else True} | let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n) | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 88,
"end_line": 205,
"start_col": 0,
"start_line": 196
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0 | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.hash_alg ->
n: FStar.UInt32.t{Lib.IntTypes.v n % Spec.Hash.Definitions.block_length a == 0}
-> ev:
Hacl.Hash.Definitions.extra_state a
{ (match Spec.Hash.Definitions.is_blake a with
| true -> Hacl.Hash.Definitions.ev_v ev == Lib.IntTypes.v n
| _ -> Prims.l_True)
<:
Type0 } | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.block_length",
"FStar.Int.Cast.uint32_to_uint64",
"FStar.Int.Cast.Full.uint64_to_uint128",
"Hacl.Hash.Definitions.extra_state",
"Spec.Hash.Definitions.is_blake",
"Spec.Hash.Definitions.extra_state",
"Hacl.Hash.Definitions.ev_v",
"Prims.bool",
"Prims.l_True"
] | [] | false | false | false | false | false | let uint32_to_ev (a: hash_alg) (n: UInt32.t{v n % block_length a == 0})
: ev: D.extra_state a {if is_blake a then D.ev_v #a ev == v n else True} =
| match a with
| MD5
| SHA1
| SHA2_224
| SHA2_256
| SHA2_384
| SHA2_512
| SHA3_224
| SHA3_256
| SHA3_384
| SHA3_512
| Shake128
| Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n) | false |
Hacl.HMAC.fst | Hacl.HMAC.compute_sha2_256 | val compute_sha2_256: compute_st SHA2_256 | val compute_sha2_256: compute_st SHA2_256 | let compute_sha2_256: compute_st SHA2_256 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_256 ()) hash_256 alloca_256 init_256
update_multi_256 update_last_256 finish_256 | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 56,
"end_line": 441,
"start_col": 0,
"start_line": 437
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len }
noextract inline_for_extraction
let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len))
inline_for_extraction noextract
val part2_update_nonempty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len > 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
open FStar.Mul
val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1)
let split_nb_rem_extend_one_block l d =
FStar.Math.Lemmas.add_div_mod_1 d l
#push-options "--z3rlimit 400"
let part2_update_nonempty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
let block_len = D.block_len a in
let n_blocks, rem_len = Lib.UpdateMulti.split_at_last_st block_len len in
let full_blocks_len = n_blocks `FStar.UInt32.mul` block_len in
let full_blocks = B.sub data 0ul full_blocks_len in
let rem = B.sub data full_blocks_len rem_len in
(**) assert (S.length key_data_v0 == v len + block_length a);
(**) split_nb_rem_extend_one_block (block_length a) (v len);
(**) assert (let bs, l = split_blocks a key_data_v0 in
bs `S.equal` (key_v0 `S.append` B.as_seq h0 full_blocks) /\
l `S.equal` B.as_seq h0 rem);
[@inline_let]
let ev = if is_blake a then zero_to_len a else () in
(**) assert (D.ev_v ev == init_extra_state a);
(**) assert (B.length key == block_length a * 1);
update_multi s ev key 1ul;
(**) let h1 = ST.get () in
(**) assert (D.as_seq h1 s ==
(**) Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) key_v0));
[@inline_let]
let ev1 = uint32_to_ev a block_len in
update_multi s ev1 full_blocks n_blocks;
(**) let h2 = ST.get () in
(**) let aux () : Lemma (D.as_seq h2 s == Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) (S.append key_v0 (B.as_seq h0 full_blocks))))
(**) = if is_blake a then
(**) update_multi_associative_blake a (D.as_seq h0 s) (init_extra_state a) (v block_len) key_v0 (B.as_seq h0 full_blocks)
(**) else
(**) update_multi_associative a (D.as_seq h0 s) key_v0 (B.as_seq h0 full_blocks)
(**) in
(**) aux ();
[@inline_let]
let prev_len: prev_len:D.prev_len_t a
{ if is_keccak a then True else len_v a prev_len % block_length a = 0 }
=
if is_keccak a then () else
len_add32 a (block_len_as_len a) full_blocks_len
in
update_last s prev_len rem rem_len
#pop-options
inline_for_extraction noextract
let part2 a m init update_multi update_last finish s dst key data len =
(**) key_and_data_fits a;
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) let h1 = ST.get () in
(**) assert(B.(modifies (loc_buffer s) h0 h1));
(**) let init_v : Ghost.erased (init_t a) = Spec.Agile.Hash.init a in
(**) assert (D.as_seq h1 s == Ghost.reveal init_v);
if len = 0ul then (
part2_update_empty a m init update_multi update_last s key data len
) else (
part2_update_nonempty a m init update_multi update_last s key data len
);
(**) let h3 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h1 (loc_union (loc_buffer s) (loc_buffer dst)) h3);
finish s dst;
(**) let h4 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h3 (loc_union (loc_buffer s) (loc_buffer dst)) h4);
(**) assert (B.as_seq h4 dst == hash_incremental a key_data_v0 ());
calc (Seq.equal) {
B.as_seq h4 dst;
(Seq.equal) { }
hash_incremental a key_data_v0 ();
(Seq.equal) { hash_is_hash_incremental' a key_data_v0 () }
hash' a key_data_v0 ();
(Seq.equal) { }
hash a key_data_v0;
}
/// This implementation is optimized. First, it reuses an existing hash state
/// ``s`` rather than allocating a new one. Second, it writes out the result of
/// the hash directly in its parameter ``key`` rather than taking a destination
/// output buffer.
inline_for_extraction noextract
val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
let part1 a m init update_multi update_last finish s key data len =
let dst = B.sub key 0ul (D.hash_len a) in
part2 a m init update_multi update_last finish s dst key data len
let block_len_positive (a: hash_alg): Lemma (D.block_len a `FStar.UInt32.gt` 0ul) = ()
let hash_lt_block (a: fixed_len_alg): Lemma (hash_length a < block_length a) = ()
#set-options "--z3rlimit 200"
let mk_compute i hash alloca init update_multi update_last finish dst key key_len data data_len =
[@inline_let] let a = D.get_alg i in
[@inline_let] let m = D.get_spec i in
block_len_positive a;
hash_lt_block a;
(**) let h0 = ST.get() in
push_frame ();
(**) let h1 = ST.get () in
let l = D.block_len a in
let key_block = B.alloca (u8 0x00) l in
mk_wrap_key a hash key_block key key_len;
(**) let h2 = ST.get () in
(**) assert (B.as_seq h2 key_block `Seq.equal` wrap a (B.as_seq h0 key));
let ipad = B.alloca (u8 0x36) l in
xor_bytes_inplace ipad key_block l;
(**) let h3 = ST.get () in
(**) assert (B.as_seq h3 ipad `Seq.equal` S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
let opad = B.alloca (u8 0x5c) l in
xor_bytes_inplace opad key_block l;
(**) let h4 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad
(**) `loc_union` loc_buffer opad) h1 h4);
(**) S.lemma_eq_intro (B.as_seq h4 ipad) (S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 opad) (S.(xor (u8 0x5c) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 data) (B.as_seq h0 data);
let s = alloca () in
part1 a m init update_multi update_last finish s ipad data data_len;
(**) key_and_data_fits a;
(**) let h5 = ST.get () in
(**) S.lemma_eq_intro (S.slice (B.as_seq h5 ipad) 0 (hash_length a))
(**) (Spec.Agile.Hash.hash a S.(append (xor (u8 0x36) (wrap a (B.as_seq h0 key)))
(**) (B.as_seq h0 data)));
let hash1 = B.sub ipad 0ul (D.hash_len a) in
init s;
part2 a m init update_multi update_last finish s dst opad hash1 (D.hash_len a);
(**) let h6 = ST.get () in
(**) assert (B.as_seq h6 dst `S.equal` hmac a (B.as_seq h0 key) (B.as_seq h0 data));
pop_frame ();
(**) let h7 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad `loc_union`
(**) loc_buffer opad `loc_union` loc_buffer s) h1 h2);
(**) LowStar.Monotonic.Buffer.modifies_fresh_frame_popped h0 h1 (B.loc_buffer dst) h6 h7
let compute_sha1: compute_st SHA1 =
let open Hacl.Hash.SHA1 in
mk_compute (D.mk_impl SHA1 ()) hash_oneshot alloca init
update_multi update_last finish | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.HMAC.compute_st Spec.Hash.Definitions.SHA2_256 | Prims.Tot | [
"total"
] | [] | [
"Hacl.HMAC.mk_compute",
"Hacl.Hash.Definitions.mk_impl",
"Spec.Hash.Definitions.SHA2_256",
"Hacl.Streaming.SHA2.hash_256",
"Hacl.Hash.SHA2.alloca_256",
"Hacl.Hash.SHA2.init_256",
"Hacl.Hash.SHA2.update_multi_256",
"Hacl.Hash.SHA2.update_last_256",
"Hacl.Hash.SHA2.finish_256",
"Hacl.HMAC.compute_st"
] | [] | false | false | false | true | false | let compute_sha2_256:compute_st SHA2_256 =
| let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_256 ())
hash_256
alloca_256
init_256
update_multi_256
update_last_256
finish_256 | false |
Hacl.HMAC.fst | Hacl.HMAC.compute_sha2_384 | val compute_sha2_384: compute_st SHA2_384 | val compute_sha2_384: compute_st SHA2_384 | let compute_sha2_384: compute_st SHA2_384 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_384 ()) hash_384 alloca_384 init_384
update_multi_384 update_last_384 finish_384 | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 56,
"end_line": 447,
"start_col": 0,
"start_line": 443
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len }
noextract inline_for_extraction
let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len))
inline_for_extraction noextract
val part2_update_nonempty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len > 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
open FStar.Mul
val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1)
let split_nb_rem_extend_one_block l d =
FStar.Math.Lemmas.add_div_mod_1 d l
#push-options "--z3rlimit 400"
let part2_update_nonempty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
let block_len = D.block_len a in
let n_blocks, rem_len = Lib.UpdateMulti.split_at_last_st block_len len in
let full_blocks_len = n_blocks `FStar.UInt32.mul` block_len in
let full_blocks = B.sub data 0ul full_blocks_len in
let rem = B.sub data full_blocks_len rem_len in
(**) assert (S.length key_data_v0 == v len + block_length a);
(**) split_nb_rem_extend_one_block (block_length a) (v len);
(**) assert (let bs, l = split_blocks a key_data_v0 in
bs `S.equal` (key_v0 `S.append` B.as_seq h0 full_blocks) /\
l `S.equal` B.as_seq h0 rem);
[@inline_let]
let ev = if is_blake a then zero_to_len a else () in
(**) assert (D.ev_v ev == init_extra_state a);
(**) assert (B.length key == block_length a * 1);
update_multi s ev key 1ul;
(**) let h1 = ST.get () in
(**) assert (D.as_seq h1 s ==
(**) Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) key_v0));
[@inline_let]
let ev1 = uint32_to_ev a block_len in
update_multi s ev1 full_blocks n_blocks;
(**) let h2 = ST.get () in
(**) let aux () : Lemma (D.as_seq h2 s == Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) (S.append key_v0 (B.as_seq h0 full_blocks))))
(**) = if is_blake a then
(**) update_multi_associative_blake a (D.as_seq h0 s) (init_extra_state a) (v block_len) key_v0 (B.as_seq h0 full_blocks)
(**) else
(**) update_multi_associative a (D.as_seq h0 s) key_v0 (B.as_seq h0 full_blocks)
(**) in
(**) aux ();
[@inline_let]
let prev_len: prev_len:D.prev_len_t a
{ if is_keccak a then True else len_v a prev_len % block_length a = 0 }
=
if is_keccak a then () else
len_add32 a (block_len_as_len a) full_blocks_len
in
update_last s prev_len rem rem_len
#pop-options
inline_for_extraction noextract
let part2 a m init update_multi update_last finish s dst key data len =
(**) key_and_data_fits a;
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) let h1 = ST.get () in
(**) assert(B.(modifies (loc_buffer s) h0 h1));
(**) let init_v : Ghost.erased (init_t a) = Spec.Agile.Hash.init a in
(**) assert (D.as_seq h1 s == Ghost.reveal init_v);
if len = 0ul then (
part2_update_empty a m init update_multi update_last s key data len
) else (
part2_update_nonempty a m init update_multi update_last s key data len
);
(**) let h3 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h1 (loc_union (loc_buffer s) (loc_buffer dst)) h3);
finish s dst;
(**) let h4 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h3 (loc_union (loc_buffer s) (loc_buffer dst)) h4);
(**) assert (B.as_seq h4 dst == hash_incremental a key_data_v0 ());
calc (Seq.equal) {
B.as_seq h4 dst;
(Seq.equal) { }
hash_incremental a key_data_v0 ();
(Seq.equal) { hash_is_hash_incremental' a key_data_v0 () }
hash' a key_data_v0 ();
(Seq.equal) { }
hash a key_data_v0;
}
/// This implementation is optimized. First, it reuses an existing hash state
/// ``s`` rather than allocating a new one. Second, it writes out the result of
/// the hash directly in its parameter ``key`` rather than taking a destination
/// output buffer.
inline_for_extraction noextract
val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
let part1 a m init update_multi update_last finish s key data len =
let dst = B.sub key 0ul (D.hash_len a) in
part2 a m init update_multi update_last finish s dst key data len
let block_len_positive (a: hash_alg): Lemma (D.block_len a `FStar.UInt32.gt` 0ul) = ()
let hash_lt_block (a: fixed_len_alg): Lemma (hash_length a < block_length a) = ()
#set-options "--z3rlimit 200"
let mk_compute i hash alloca init update_multi update_last finish dst key key_len data data_len =
[@inline_let] let a = D.get_alg i in
[@inline_let] let m = D.get_spec i in
block_len_positive a;
hash_lt_block a;
(**) let h0 = ST.get() in
push_frame ();
(**) let h1 = ST.get () in
let l = D.block_len a in
let key_block = B.alloca (u8 0x00) l in
mk_wrap_key a hash key_block key key_len;
(**) let h2 = ST.get () in
(**) assert (B.as_seq h2 key_block `Seq.equal` wrap a (B.as_seq h0 key));
let ipad = B.alloca (u8 0x36) l in
xor_bytes_inplace ipad key_block l;
(**) let h3 = ST.get () in
(**) assert (B.as_seq h3 ipad `Seq.equal` S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
let opad = B.alloca (u8 0x5c) l in
xor_bytes_inplace opad key_block l;
(**) let h4 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad
(**) `loc_union` loc_buffer opad) h1 h4);
(**) S.lemma_eq_intro (B.as_seq h4 ipad) (S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 opad) (S.(xor (u8 0x5c) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 data) (B.as_seq h0 data);
let s = alloca () in
part1 a m init update_multi update_last finish s ipad data data_len;
(**) key_and_data_fits a;
(**) let h5 = ST.get () in
(**) S.lemma_eq_intro (S.slice (B.as_seq h5 ipad) 0 (hash_length a))
(**) (Spec.Agile.Hash.hash a S.(append (xor (u8 0x36) (wrap a (B.as_seq h0 key)))
(**) (B.as_seq h0 data)));
let hash1 = B.sub ipad 0ul (D.hash_len a) in
init s;
part2 a m init update_multi update_last finish s dst opad hash1 (D.hash_len a);
(**) let h6 = ST.get () in
(**) assert (B.as_seq h6 dst `S.equal` hmac a (B.as_seq h0 key) (B.as_seq h0 data));
pop_frame ();
(**) let h7 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad `loc_union`
(**) loc_buffer opad `loc_union` loc_buffer s) h1 h2);
(**) LowStar.Monotonic.Buffer.modifies_fresh_frame_popped h0 h1 (B.loc_buffer dst) h6 h7
let compute_sha1: compute_st SHA1 =
let open Hacl.Hash.SHA1 in
mk_compute (D.mk_impl SHA1 ()) hash_oneshot alloca init
update_multi update_last finish
let compute_sha2_256: compute_st SHA2_256 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_256 ()) hash_256 alloca_256 init_256
update_multi_256 update_last_256 finish_256 | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.HMAC.compute_st Spec.Hash.Definitions.SHA2_384 | Prims.Tot | [
"total"
] | [] | [
"Hacl.HMAC.mk_compute",
"Hacl.Hash.Definitions.mk_impl",
"Spec.Hash.Definitions.SHA2_384",
"Hacl.Streaming.SHA2.hash_384",
"Hacl.Hash.SHA2.alloca_384",
"Hacl.Hash.SHA2.init_384",
"Hacl.Hash.SHA2.update_multi_384",
"Hacl.Hash.SHA2.update_last_384",
"Hacl.Hash.SHA2.finish_384",
"Hacl.HMAC.compute_st"
] | [] | false | false | false | true | false | let compute_sha2_384:compute_st SHA2_384 =
| let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_384 ())
hash_384
alloca_384
init_384
update_multi_384
update_last_384
finish_384 | false |
Hacl.Impl.Curve25519.Generic.fst | Hacl.Impl.Curve25519.Generic.ladder_step_loop | val ladder_step_loop:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) =
Lib.LoopCombinators.repeati 251
(S.ladder_step (as_seq h0 k) (fget_xz h0 q))
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1))) | val ladder_step_loop:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) =
Lib.LoopCombinators.repeati 251
(S.ladder_step (as_seq h0 k) (fget_xz h0 q))
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1))) | let ladder_step_loop #s k q p01_tmp1_swap tmp2 =
let h0 = ST.get () in
[@ inline_let]
let spec_fh h0 =
S.ladder_step (as_seq h0 k) (fget_x h0 q, fget_z h0 q) in
[@ inline_let]
let acc h : GTot (tuple3 S.proj_point S.proj_point uint64) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
(fget_xz h nq, fget_xz h nq_p1, LSeq.index (as_seq h bit) 0) in
[@ inline_let]
let inv h (i:nat{i <= 251}) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h /\
v (LSeq.index (as_seq h bit) 0) <= 1 /\
state_inv_t h (get_x q) /\ state_inv_t h (get_z q) /\
state_inv_t h (get_x nq) /\ state_inv_t h (get_z nq) /\
state_inv_t h (get_x nq_p1) /\ state_inv_t h (get_z nq_p1) /\
acc h == Lib.LoopCombinators.repeati i (spec_fh h0) (acc h0) in
Lib.Loops.for 0ul 251ul inv
(fun i ->
Lib.LoopCombinators.unfold_repeati 251 (spec_fh h0) (acc h0) (v i);
ladder_step #s k q i p01_tmp1_swap tmp2) | {
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 252,
"start_col": 0,
"start_line": 223
} | module Hacl.Impl.Curve25519.Generic
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Curve25519.Fields
include Hacl.Impl.Curve25519.Finv
include Hacl.Impl.Curve25519.AddAndDouble
module ST = FStar.HyperStack.ST
module BSeq = Lib.ByteSequence
module LSeq = Lib.Sequence
module C = Hacl.Impl.Curve25519.Fields.Core
module S = Spec.Curve25519
module M = Hacl.Spec.Curve25519.AddAndDouble
module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas
friend Lib.LoopCombinators
#set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options"
//#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
inline_for_extraction noextract
let scalar = lbuffer uint8 32ul
inline_for_extraction noextract
val scalar_bit:
s:scalar
-> n:size_t{v n < 256}
-> Stack uint64
(requires fun h0 -> live h0 s)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.ith_bit (as_seq h0 s) (v n) /\ v r <= 1)
let scalar_bit s n =
let h0 = ST.get () in
mod_mask_lemma ((LSeq.index (as_seq h0 s) (v n / 8)) >>. (n %. 8ul)) 1ul;
assert_norm (1 = pow2 1 - 1);
assert (v (mod_mask #U8 #SEC 1ul) == v (u8 1));
to_u64 ((s.(n /. 8ul) >>. (n %. 8ul)) &. u8 1)
inline_for_extraction noextract
val decode_point:
#s:field_spec
-> o:point s
-> i:lbuffer uint8 32ul
-> Stack unit
(requires fun h0 -> live h0 o /\ live h0 i /\ disjoint o i)
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
state_inv_t h1 (get_x o) /\ state_inv_t h1 (get_z o) /\
fget_x h1 o == S.decodePoint (as_seq h0 i) /\ fget_z h1 o == 1)
[@ Meta.Attribute.specialize ]
let decode_point #s o i =
push_frame();
let tmp = create 4ul (u64 0) in
let h0 = ST.get () in
uints_from_bytes_le #U64 tmp i;
let h1 = ST.get () in
BSeq.uints_from_bytes_le_nat_lemma #U64 #SEC #4 (as_seq h0 i);
assert (BSeq.nat_from_intseq_le (as_seq h1 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i));
let tmp3 = tmp.(3ul) in
tmp.(3ul) <- tmp3 &. u64 0x7fffffffffffffff;
mod_mask_lemma tmp3 63ul;
assert_norm (0x7fffffffffffffff = pow2 63 - 1);
assert (v (mod_mask #U64 #SEC 63ul) == v (u64 0x7fffffffffffffff));
let h2 = ST.get () in
assert (v (LSeq.index (as_seq h2 tmp) 3) < pow2 63);
Lemmas.lemma_felem64_mod255 (as_seq h1 tmp);
assert (BSeq.nat_from_intseq_le (as_seq h2 tmp) == BSeq.nat_from_bytes_le (as_seq h0 i) % pow2 255);
let x : felem s = sub o 0ul (nlimb s) in
let z : felem s = sub o (nlimb s) (nlimb s) in
set_one z;
load_felem x tmp;
pop_frame()
val encode_point:
#s:field_spec
-> o:lbuffer uint8 32ul
-> i:point s
-> Stack unit
(requires fun h0 ->
live h0 o /\ live h0 i /\ disjoint o i /\
state_inv_t h0 (get_x i) /\ state_inv_t h0 (get_z i))
(ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\
as_seq h1 o == S.encodePoint (fget_x h0 i, fget_z h0 i))
[@ Meta.Attribute.specialize ]
let encode_point #s o i =
push_frame();
let x : felem s = sub i 0ul (nlimb s) in
let z : felem s = sub i (nlimb s) (nlimb s) in
let tmp = create_felem s in
let u64s = create 4ul (u64 0) in
let tmp_w = create (2ul `FStar.UInt32.mul` ((nwide s) <: FStar.UInt32.t)) (wide_zero s) in
let h0 = ST.get () in
finv tmp z tmp_w;
fmul tmp tmp x tmp_w;
let h1 = ST.get () in
assert (feval h1 tmp == S.fmul (S.fpow (feval h0 z) (pow2 255 - 21)) (feval h0 x));
assert (feval h1 tmp == S.fmul (feval h0 x) (S.fpow (feval h0 z) (pow2 255 - 21)));
store_felem u64s tmp;
let h2 = ST.get () in
assert (as_seq h2 u64s == BSeq.nat_to_intseq_le 4 (feval h1 tmp));
uints_to_bytes_le #U64 4ul o u64s;
let h3 = ST.get () in
BSeq.uints_to_bytes_le_nat_lemma #U64 #SEC 4 (feval h1 tmp);
assert (as_seq h3 o == BSeq.nat_to_bytes_le 32 (feval h1 tmp));
pop_frame()
// TODO: why re-define the signature here?
val cswap2:
#s:field_spec
-> bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
live h0 p1 /\ live h0 p2 /\ disjoint p1 p2)
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2) /\
(fget_xz h1 p1, fget_xz h1 p2) == S.cswap2 bit (fget_xz h0 p1) (fget_xz h0 p2))
[@ Meta.Attribute.inline_ ]
let cswap2 #s bit p0 p1 =
C.cswap2 #s bit p0 p1
val ladder_step:
#s:field_spec
-> k:scalar
-> q:point s
-> i:size_t{v i < 251}
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) = S.ladder_step (as_seq h0 k) (fget_xz h0 q) (v i)
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\
b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x q) /\ state_inv_t h1 (get_z q) /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1)))
#push-options "--z3rlimit 200 --fuel 0 --ifuel 1"
[@ Meta.Attribute.inline_ ]
let ladder_step #s k q i p01_tmp1_swap tmp2 =
let p01_tmp1 = sub p01_tmp1_swap 0ul (8ul *! nlimb s) in
let swap : lbuffer uint64 1ul = sub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let nq = sub p01_tmp1 0ul (2ul *! nlimb s) in
let nq_p1 = sub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) in
assert (gsub p01_tmp1_swap 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1 0ul (2ul *! nlimb s) == nq);
assert (gsub p01_tmp1 (2ul *! nlimb s) (2ul *! nlimb s) == nq_p1);
assert (gsub p01_tmp1_swap 0ul (8ul *! nlimb s) == p01_tmp1);
assert (gsub p01_tmp1_swap (8ul *! nlimb s) 1ul == swap);
let h0 = ST.get () in
let bit = scalar_bit k (253ul -. i) in
assert (v bit == v (S.ith_bit (as_seq h0 k) (253 - v i)));
let sw = swap.(0ul) ^. bit in
logxor_lemma1 (LSeq.index (as_seq h0 swap) 0) bit;
cswap2 #s sw nq nq_p1;
point_add_and_double #s q p01_tmp1 tmp2;
swap.(0ul) <- bit
#pop-options
#push-options "--z3rlimit 300 --fuel 1 --ifuel 1"
val ladder_step_loop:
#s:field_spec
-> k:scalar
-> q:point s
-> p01_tmp1_swap:lbuffer (limb s) (8ul *! nlimb s +! 1ul)
-> tmp2:felem_wide2 s
-> Stack unit
(requires fun h0 ->
live h0 k /\ live h0 q /\ live h0 p01_tmp1_swap /\ live h0 tmp2 /\
LowStar.Monotonic.Buffer.all_disjoint [loc k; loc q; loc p01_tmp1_swap; loc tmp2] /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
v (LSeq.index (as_seq h0 bit) 0) <= 1 /\
state_inv_t h0 (get_x q) /\ state_inv_t h0 (get_z q) /\
state_inv_t h0 (get_x nq) /\ state_inv_t h0 (get_z nq) /\
state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1)))
(ensures fun h0 _ h1 ->
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h1 /\
(let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit : lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
let (p0, p1, b) =
Lib.LoopCombinators.repeati 251
(S.ladder_step (as_seq h0 k) (fget_xz h0 q))
(fget_xz h0 nq, fget_xz h0 nq_p1, LSeq.index (as_seq h0 bit) 0) in
p0 == fget_xz h1 nq /\ p1 == fget_xz h1 nq_p1 /\ b == LSeq.index (as_seq h1 bit) 0 /\
v (LSeq.index (as_seq h1 bit) 0) <= 1 /\
state_inv_t h1 (get_x nq) /\ state_inv_t h1 (get_z nq) /\
state_inv_t h1 (get_x nq_p1) /\ state_inv_t h1 (get_z nq_p1))) | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.AddAndDouble.fst.checked",
"Hacl.Impl.Curve25519.Finv.fst.checked",
"Hacl.Impl.Curve25519.Fields.Core.fsti.checked",
"Hacl.Impl.Curve25519.Fields.fst.checked",
"Hacl.Impl.Curve25519.AddAndDouble.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Curve25519.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field64.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.AddAndDouble",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Fields.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.AddAndDouble",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Finv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Hacl.Impl.Curve25519.Generic.scalar ->
q: Hacl.Impl.Curve25519.AddAndDouble.point s ->
p01_tmp1_swap:
Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s)
(8ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s +! 1ul) ->
tmp2: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.Generic.scalar",
"Hacl.Impl.Curve25519.AddAndDouble.point",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Lib.Loops.for",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Prims.op_LessThan",
"Hacl.Impl.Curve25519.Generic.ladder_step",
"Prims.unit",
"Lib.LoopCombinators.unfold_repeati",
"FStar.Pervasives.Native.tuple3",
"Spec.Curve25519.proj_point",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.logical",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"Lib.Sequence.index",
"FStar.UInt32.uint_to_t",
"Lib.Buffer.as_seq",
"Hacl.Impl.Curve25519.Fields.Core.state_inv_t",
"Hacl.Impl.Curve25519.AddAndDouble.get_x",
"Hacl.Impl.Curve25519.AddAndDouble.get_z",
"Prims.eq2",
"Lib.IntTypes.uint64",
"Lib.LoopCombinators.repeati",
"Lib.Buffer.lbuffer_t",
"FStar.UInt32.t",
"Lib.Buffer.gsub",
"Lib.IntTypes.mul",
"FStar.Pervasives.Native.Mktuple3",
"Hacl.Impl.Curve25519.AddAndDouble.fget_xz",
"FStar.Pervasives.Native.tuple2",
"Spec.Curve25519.elem",
"Spec.Curve25519.ladder_step",
"Lib.IntTypes.uint8",
"FStar.Pervasives.Native.Mktuple2",
"Hacl.Impl.Curve25519.AddAndDouble.fget_x",
"Hacl.Impl.Curve25519.AddAndDouble.fget_z",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let ladder_step_loop #s k q p01_tmp1_swap tmp2 =
| let h0 = ST.get () in
[@@ inline_let ]let spec_fh h0 = S.ladder_step (as_seq h0 k) (fget_x h0 q, fget_z h0 q) in
[@@ inline_let ]let acc h : GTot (tuple3 S.proj_point S.proj_point uint64) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit:lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
(fget_xz h nq, fget_xz h nq_p1, LSeq.index (as_seq h bit) 0)
in
[@@ inline_let ]let inv h (i: nat{i <= 251}) =
let nq = gsub p01_tmp1_swap 0ul (2ul *! nlimb s) in
let nq_p1 = gsub p01_tmp1_swap (2ul *! nlimb s) (2ul *! nlimb s) in
let bit:lbuffer uint64 1ul = gsub p01_tmp1_swap (8ul *! nlimb s) 1ul in
modifies (loc p01_tmp1_swap |+| loc tmp2) h0 h /\ v (LSeq.index (as_seq h bit) 0) <= 1 /\
state_inv_t h (get_x q) /\ state_inv_t h (get_z q) /\ state_inv_t h (get_x nq) /\
state_inv_t h (get_z nq) /\ state_inv_t h (get_x nq_p1) /\ state_inv_t h (get_z nq_p1) /\
acc h == Lib.LoopCombinators.repeati i (spec_fh h0) (acc h0)
in
Lib.Loops.for 0ul
251ul
inv
(fun i ->
Lib.LoopCombinators.unfold_repeati 251 (spec_fh h0) (acc h0) (v i);
ladder_step #s k q i p01_tmp1_swap tmp2) | false |
Hacl.Streaming.Poly1305_256.fst | Hacl.Streaming.Poly1305_256.mac | val mac: poly1305_mac_st M256 | val mac: poly1305_mac_st M256 | let mac = poly1305_poly1305_mac_higher #M256 True poly1305_finish poly1305_update poly1305_init | {
"file_name": "code/streaming/Hacl.Streaming.Poly1305_256.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 95,
"end_line": 9,
"start_col": 0,
"start_line": 9
} | module Hacl.Streaming.Poly1305_256
open Hacl.Meta.Poly1305
open Hacl.Poly1305_256
friend Hacl.Meta.Poly1305 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Hacl.Poly1305_256.fsti.checked",
"Hacl.Meta.Poly1305.fst.checked",
"Hacl.Meta.Poly1305.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Poly1305_256.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Poly1305_256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Meta.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Fields",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Impl.Poly1305.poly1305_mac_st Hacl.Impl.Poly1305.Fields.M256 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Meta.Poly1305.poly1305_poly1305_mac_higher",
"Hacl.Impl.Poly1305.Fields.M256",
"Prims.l_True",
"Hacl.Poly1305_256.poly1305_finish",
"Hacl.Poly1305_256.poly1305_update",
"Hacl.Poly1305_256.poly1305_init"
] | [] | false | false | false | true | false | let mac =
| poly1305_poly1305_mac_higher #M256 True poly1305_finish poly1305_update poly1305_init | false |
Hacl.HMAC.fst | Hacl.HMAC.compute_blake2b_32 | val compute_blake2b_32: compute_st Blake2B | val compute_blake2b_32: compute_st Blake2B | let compute_blake2b_32: compute_st Blake2B =
let open Hacl.Hash.Blake2b_32 in
mk_compute (D.mk_impl Blake2B C.M32) hash alloca init update_multi update_last finish | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 87,
"end_line": 461,
"start_col": 0,
"start_line": 459
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len }
noextract inline_for_extraction
let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len))
inline_for_extraction noextract
val part2_update_nonempty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len > 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
open FStar.Mul
val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1)
let split_nb_rem_extend_one_block l d =
FStar.Math.Lemmas.add_div_mod_1 d l
#push-options "--z3rlimit 400"
let part2_update_nonempty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
let block_len = D.block_len a in
let n_blocks, rem_len = Lib.UpdateMulti.split_at_last_st block_len len in
let full_blocks_len = n_blocks `FStar.UInt32.mul` block_len in
let full_blocks = B.sub data 0ul full_blocks_len in
let rem = B.sub data full_blocks_len rem_len in
(**) assert (S.length key_data_v0 == v len + block_length a);
(**) split_nb_rem_extend_one_block (block_length a) (v len);
(**) assert (let bs, l = split_blocks a key_data_v0 in
bs `S.equal` (key_v0 `S.append` B.as_seq h0 full_blocks) /\
l `S.equal` B.as_seq h0 rem);
[@inline_let]
let ev = if is_blake a then zero_to_len a else () in
(**) assert (D.ev_v ev == init_extra_state a);
(**) assert (B.length key == block_length a * 1);
update_multi s ev key 1ul;
(**) let h1 = ST.get () in
(**) assert (D.as_seq h1 s ==
(**) Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) key_v0));
[@inline_let]
let ev1 = uint32_to_ev a block_len in
update_multi s ev1 full_blocks n_blocks;
(**) let h2 = ST.get () in
(**) let aux () : Lemma (D.as_seq h2 s == Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) (S.append key_v0 (B.as_seq h0 full_blocks))))
(**) = if is_blake a then
(**) update_multi_associative_blake a (D.as_seq h0 s) (init_extra_state a) (v block_len) key_v0 (B.as_seq h0 full_blocks)
(**) else
(**) update_multi_associative a (D.as_seq h0 s) key_v0 (B.as_seq h0 full_blocks)
(**) in
(**) aux ();
[@inline_let]
let prev_len: prev_len:D.prev_len_t a
{ if is_keccak a then True else len_v a prev_len % block_length a = 0 }
=
if is_keccak a then () else
len_add32 a (block_len_as_len a) full_blocks_len
in
update_last s prev_len rem rem_len
#pop-options
inline_for_extraction noextract
let part2 a m init update_multi update_last finish s dst key data len =
(**) key_and_data_fits a;
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) let h1 = ST.get () in
(**) assert(B.(modifies (loc_buffer s) h0 h1));
(**) let init_v : Ghost.erased (init_t a) = Spec.Agile.Hash.init a in
(**) assert (D.as_seq h1 s == Ghost.reveal init_v);
if len = 0ul then (
part2_update_empty a m init update_multi update_last s key data len
) else (
part2_update_nonempty a m init update_multi update_last s key data len
);
(**) let h3 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h1 (loc_union (loc_buffer s) (loc_buffer dst)) h3);
finish s dst;
(**) let h4 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h3 (loc_union (loc_buffer s) (loc_buffer dst)) h4);
(**) assert (B.as_seq h4 dst == hash_incremental a key_data_v0 ());
calc (Seq.equal) {
B.as_seq h4 dst;
(Seq.equal) { }
hash_incremental a key_data_v0 ();
(Seq.equal) { hash_is_hash_incremental' a key_data_v0 () }
hash' a key_data_v0 ();
(Seq.equal) { }
hash a key_data_v0;
}
/// This implementation is optimized. First, it reuses an existing hash state
/// ``s`` rather than allocating a new one. Second, it writes out the result of
/// the hash directly in its parameter ``key`` rather than taking a destination
/// output buffer.
inline_for_extraction noextract
val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
let part1 a m init update_multi update_last finish s key data len =
let dst = B.sub key 0ul (D.hash_len a) in
part2 a m init update_multi update_last finish s dst key data len
let block_len_positive (a: hash_alg): Lemma (D.block_len a `FStar.UInt32.gt` 0ul) = ()
let hash_lt_block (a: fixed_len_alg): Lemma (hash_length a < block_length a) = ()
#set-options "--z3rlimit 200"
let mk_compute i hash alloca init update_multi update_last finish dst key key_len data data_len =
[@inline_let] let a = D.get_alg i in
[@inline_let] let m = D.get_spec i in
block_len_positive a;
hash_lt_block a;
(**) let h0 = ST.get() in
push_frame ();
(**) let h1 = ST.get () in
let l = D.block_len a in
let key_block = B.alloca (u8 0x00) l in
mk_wrap_key a hash key_block key key_len;
(**) let h2 = ST.get () in
(**) assert (B.as_seq h2 key_block `Seq.equal` wrap a (B.as_seq h0 key));
let ipad = B.alloca (u8 0x36) l in
xor_bytes_inplace ipad key_block l;
(**) let h3 = ST.get () in
(**) assert (B.as_seq h3 ipad `Seq.equal` S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
let opad = B.alloca (u8 0x5c) l in
xor_bytes_inplace opad key_block l;
(**) let h4 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad
(**) `loc_union` loc_buffer opad) h1 h4);
(**) S.lemma_eq_intro (B.as_seq h4 ipad) (S.(xor (u8 0x36) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 opad) (S.(xor (u8 0x5c) (wrap a (B.as_seq h0 key))));
(**) S.lemma_eq_intro (B.as_seq h4 data) (B.as_seq h0 data);
let s = alloca () in
part1 a m init update_multi update_last finish s ipad data data_len;
(**) key_and_data_fits a;
(**) let h5 = ST.get () in
(**) S.lemma_eq_intro (S.slice (B.as_seq h5 ipad) 0 (hash_length a))
(**) (Spec.Agile.Hash.hash a S.(append (xor (u8 0x36) (wrap a (B.as_seq h0 key)))
(**) (B.as_seq h0 data)));
let hash1 = B.sub ipad 0ul (D.hash_len a) in
init s;
part2 a m init update_multi update_last finish s dst opad hash1 (D.hash_len a);
(**) let h6 = ST.get () in
(**) assert (B.as_seq h6 dst `S.equal` hmac a (B.as_seq h0 key) (B.as_seq h0 data));
pop_frame ();
(**) let h7 = ST.get () in
(**) assert B.(modifies (loc_buffer key_block `loc_union` loc_buffer ipad `loc_union`
(**) loc_buffer opad `loc_union` loc_buffer s) h1 h2);
(**) LowStar.Monotonic.Buffer.modifies_fresh_frame_popped h0 h1 (B.loc_buffer dst) h6 h7
let compute_sha1: compute_st SHA1 =
let open Hacl.Hash.SHA1 in
mk_compute (D.mk_impl SHA1 ()) hash_oneshot alloca init
update_multi update_last finish
let compute_sha2_256: compute_st SHA2_256 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_256 ()) hash_256 alloca_256 init_256
update_multi_256 update_last_256 finish_256
let compute_sha2_384: compute_st SHA2_384 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_384 ()) hash_384 alloca_384 init_384
update_multi_384 update_last_384 finish_384
let compute_sha2_512: compute_st SHA2_512 =
let open Hacl.Streaming.SHA2 in
let open Hacl.Hash.SHA2 in
mk_compute (D.mk_impl SHA2_512 ()) hash_512 alloca_512 init_512
update_multi_512 update_last_512 finish_512
let compute_blake2s_32: compute_st Blake2S =
let open Hacl.Hash.Blake2s_32 in
mk_compute (D.mk_impl Blake2S C.M32) hash alloca init update_multi update_last finish | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.HMAC.compute_st Spec.Hash.Definitions.Blake2B | Prims.Tot | [
"total"
] | [] | [
"Hacl.HMAC.mk_compute",
"Hacl.Hash.Definitions.mk_impl",
"Spec.Hash.Definitions.Blake2B",
"Hacl.Impl.Blake2.Core.M32",
"Hacl.Hash.Blake2b_32.hash",
"Hacl.Hash.Blake2b_32.alloca",
"Hacl.Hash.Blake2b_32.init",
"Hacl.Hash.Blake2b_32.update_multi",
"Hacl.Hash.Blake2b_32.update_last",
"Hacl.Hash.Blake2b_32.finish",
"Hacl.HMAC.compute_st"
] | [] | false | false | false | true | false | let compute_blake2b_32:compute_st Blake2B =
| let open Hacl.Hash.Blake2b_32 in
mk_compute (D.mk_impl Blake2B C.M32) hash alloca init update_multi update_last finish | false |
Pulse.Checker.While.fst | Pulse.Checker.While.check | val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_While? t.term})
(check:check_t)
: T.Tac (checker_result_t g pre post_hint) | val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_While? t.term})
(check:check_t)
: T.Tac (checker_result_t g pre post_hint) | let check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_While? t.term})
(check:check_t)
: T.Tac (checker_result_t g pre post_hint) =
let g = push_context "while loop" t.range g in
let Tm_While { invariant=inv; condition=cond; body; condition_var } = t.term in
let (| ex_inv, inv_typing |) =
check_vprop (push_context "invariant" (term_range inv) g)
(tm_exists_sl u0 (mk_binder_ppname tm_bool condition_var) inv)
in
if not (Tm_ExistsSL? ex_inv.t)
then fail g (Some t.range)
(Printf.sprintf "check_while: typechecked invariant %s is not an existential"
(P.term_to_string ex_inv));
let Tm_ExistsSL u {binder_ppname=nm; binder_ty=ty} inv = ex_inv.t in
if not (eq_tm ty tm_bool) ||
not (eq_univ u u0)
then fail g (Some nm.range)
(Printf.sprintf "While loop invariant exists but its witness type is %s, expected bool"
(P.term_to_string ty));
let while_cond_comp_typing = while_cond_comp_typing u nm ty inv inv_typing in
let (| res_typing, cond_pre_typing, x, post_typing |) =
Metatheory.(st_comp_typing_inversion (fst <| comp_typing_inversion while_cond_comp_typing))
in
let while_cond_hint : post_hint_for_env g =
post_hint_from_comp_typing while_cond_comp_typing
in
let (| cond, cond_comp, cond_typing |) =
let ppname = mk_ppname_no_range "_while_c" in
let r = check
(push_context "check_while_condition" cond.range g)
(comp_pre (comp_while_cond nm inv))
cond_pre_typing
(Some while_cond_hint)
ppname
cond in
apply_checker_result_k r ppname
in
if eq_comp cond_comp (comp_while_cond nm inv)
then begin
let while_body_comp_typing = while_body_comp_typing u nm ty inv inv_typing in
let (| res_typing, body_pre_typing, x, post_typing |) =
Metatheory.(st_comp_typing_inversion (fst <| comp_typing_inversion while_body_comp_typing))
in
let while_post_hint : post_hint_for_env g =
post_hint_from_comp_typing while_body_comp_typing
in
debug g (fun _ ->
Printf.sprintf "while_body post_hint: %s\n"
(Pulse.Syntax.Printer.term_to_string while_post_hint.post)
);
let (| body, body_comp, body_typing |) =
let ppname = mk_ppname_no_range "_while_b" in
let r = check
(push_context "check_while_body" body.range g)
(comp_pre (comp_while_body nm inv))
body_pre_typing
(Some while_post_hint)
ppname
body in
apply_checker_result_k r ppname in
if eq_comp body_comp (comp_while_body nm inv)
then
let d = T_While g inv cond body inv_typing cond_typing body_typing in
prove_post_hint (try_frame_pre pre_typing (match_comp_res_with_post_hint d post_hint) res_ppname) post_hint t.range
else fail g None
(Printf.sprintf "Could not prove the inferred type of the while body matches the annotation\n\
Inferred type = %s\n\
Annotated type = %s\n"
(P.comp_to_string body_comp)
(P.comp_to_string (comp_while_body nm inv)))
end
else fail g None
(Printf.sprintf "Could not prove that the inferred type of the while condition matches the annotation\n\
Inferred type = %s\n\
Annotated type = %s\n"
(P.comp_to_string cond_comp)
(P.comp_to_string (comp_while_cond nm inv))) | {
"file_name": "lib/steel/pulse/Pulse.Checker.While.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 70,
"end_line": 129,
"start_col": 0,
"start_line": 41
} | (*
Copyright 2023 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 Pulse.Checker.While
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Base
open Pulse.Checker.Prover
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Metatheory = Pulse.Typing.Metatheory
module RU = Pulse.RuntimeUtils
let while_cond_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: comp_typing_u g (comp_while_cond x inv_body)
= Metatheory.admit_comp_typing g (comp_while_cond x inv_body)
let while_body_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: comp_typing_u g (comp_while_body x inv_body)
= Metatheory.admit_comp_typing g (comp_while_body x inv_body) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.While.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 4,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
g: Pulse.Typing.Env.env ->
pre: Pulse.Syntax.Base.term ->
pre_typing: Pulse.Typing.tot_typing g pre Pulse.Syntax.Base.tm_vprop ->
post_hint: Pulse.Typing.post_hint_opt g ->
res_ppname: Pulse.Syntax.Base.ppname ->
t: Pulse.Syntax.Base.st_term{Tm_While? (Mkst_term?.term t)} ->
check: Pulse.Checker.Base.check_t
-> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g pre post_hint) | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.post_hint_opt",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.st_term",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_Tm_While",
"Pulse.Syntax.Base.__proj__Mkst_term__item__term",
"Pulse.Checker.Base.check_t",
"Pulse.Checker.Pure.push_context",
"Pulse.Syntax.Base.term_range",
"Pulse.Syntax.Base.universe",
"FStar.Sealed.Inhabited.sealed",
"Prims.list",
"Prims.Nil",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Typing.comp_while_cond",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__u",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.var",
"Pulse.Typing.fresh_wrt",
"Pulse.Syntax.Naming.freevars",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Syntax.Naming.open_term",
"Pulse.Syntax.Base.comp_st",
"Prims.l_and",
"Prims.eq2",
"Pulse.Syntax.Base.vprop",
"Pulse.Syntax.Base.comp_pre",
"Pulse.Typing.comp_post_matches_hint",
"FStar.Pervasives.Native.Some",
"Pulse.Typing.post_hint_t",
"Pulse.Typing.st_typing",
"Pulse.Syntax.Base.__proj__Mkst_term__item__range",
"Pulse.Syntax.Base.eq_comp",
"Pulse.Typing.comp_while_body",
"Pulse.Checker.Prover.prove_post_hint",
"Pulse.Checker.Base.checker_result_t",
"FStar.Pervasives.Native.None",
"Pulse.Checker.Prover.try_frame_pre",
"FStar.Pervasives.dtuple3",
"Pulse.Checker.Base.match_comp_res_with_post_hint",
"Pulse.Typing.wtag",
"Pulse.Syntax.Base.ctag",
"Pulse.Syntax.Base.STT",
"Pulse.Syntax.Base.Tm_While",
"Pulse.Syntax.Base.Mkst_term'__Tm_While__payload",
"Pulse.Typing.comp_while",
"Pulse.Typing.T_While",
"Prims.bool",
"Pulse.Typing.Env.fail",
"Pulse.Syntax.Base.range",
"Prims.string",
"FStar.Printf.sprintf",
"Pulse.Syntax.Printer.comp_to_string",
"Pulse.Typing.Combinators.st_typing_in_ctxt",
"Pulse.Checker.Base.apply_checker_result_k",
"Pulse.Syntax.Base.mk_ppname_no_range",
"Prims.unit",
"Pulse.Checker.Base.debug",
"Pulse.Syntax.Printer.term_to_string",
"Pulse.Typing.__proj__Mkpost_hint_t__item__post",
"Pulse.Typing.post_hint_for_env",
"Pulse.Checker.Base.post_hint_from_comp_typing",
"FStar.Pervasives.dtuple4",
"Pulse.Typing.Metatheory.Base.st_comp_typing_inversion",
"FStar.Pervasives.Native.fst",
"Pulse.Typing.st_comp_typing",
"Pulse.Typing.Metatheory.Base.iname_typing",
"Pulse.Typing.Metatheory.Base.comp_typing_inversion",
"Pulse.Typing.comp_typing_u",
"Pulse.Checker.While.while_body_comp_typing",
"Pulse.Checker.While.while_cond_comp_typing",
"Prims.op_BarBar",
"Prims.op_Negation",
"Pulse.Syntax.Base.eq_tm",
"Pulse.Typing.tm_bool",
"Pulse.Syntax.Base.eq_univ",
"Pulse.Syntax.Pure.u0",
"Pulse.Syntax.Base.__proj__Mkppname__item__range",
"Pulse.Syntax.Base.term'",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"Pulse.Syntax.Base.uu___is_Tm_ExistsSL",
"Prims.dtuple2",
"Pulse.Checker.Pure.check_vprop",
"Pulse.Syntax.Base.tm_exists_sl",
"Pulse.Syntax.Base.mk_binder_ppname",
"Pulse.Syntax.Base.st_term'"
] | [] | false | true | false | false | false | let check
(g: env)
(pre: term)
(pre_typing: tot_typing g pre tm_vprop)
(post_hint: post_hint_opt g)
(res_ppname: ppname)
(t: st_term{Tm_While? t.term})
(check: check_t)
: T.Tac (checker_result_t g pre post_hint) =
| let g = push_context "while loop" t.range g in
let Tm_While { invariant = inv ; condition = cond ; body = body ; condition_var = condition_var } =
t.term
in
let (| ex_inv , inv_typing |) =
check_vprop (push_context "invariant" (term_range inv) g)
(tm_exists_sl u0 (mk_binder_ppname tm_bool condition_var) inv)
in
if not (Tm_ExistsSL? ex_inv.t)
then
fail g
(Some t.range)
(Printf.sprintf "check_while: typechecked invariant %s is not an existential"
(P.term_to_string ex_inv));
let Tm_ExistsSL u { binder_ppname = nm ; binder_ty = ty } inv = ex_inv.t in
if not (eq_tm ty tm_bool) || not (eq_univ u u0)
then
fail g
(Some nm.range)
(Printf.sprintf "While loop invariant exists but its witness type is %s, expected bool"
(P.term_to_string ty));
let while_cond_comp_typing = while_cond_comp_typing u nm ty inv inv_typing in
let (| res_typing , cond_pre_typing , x , post_typing |) =
let open Metatheory in
st_comp_typing_inversion (fst <| comp_typing_inversion while_cond_comp_typing)
in
let while_cond_hint:post_hint_for_env g = post_hint_from_comp_typing while_cond_comp_typing in
let (| cond , cond_comp , cond_typing |) =
let ppname = mk_ppname_no_range "_while_c" in
let r =
check (push_context "check_while_condition" cond.range g)
(comp_pre (comp_while_cond nm inv))
cond_pre_typing
(Some while_cond_hint)
ppname
cond
in
apply_checker_result_k r ppname
in
if eq_comp cond_comp (comp_while_cond nm inv)
then
let while_body_comp_typing = while_body_comp_typing u nm ty inv inv_typing in
let (| res_typing , body_pre_typing , x , post_typing |) =
let open Metatheory in
st_comp_typing_inversion (fst <| comp_typing_inversion while_body_comp_typing)
in
let while_post_hint:post_hint_for_env g = post_hint_from_comp_typing while_body_comp_typing in
debug g
(fun _ ->
Printf.sprintf "while_body post_hint: %s\n"
(Pulse.Syntax.Printer.term_to_string while_post_hint.post));
let (| body , body_comp , body_typing |) =
let ppname = mk_ppname_no_range "_while_b" in
let r =
check (push_context "check_while_body" body.range g)
(comp_pre (comp_while_body nm inv))
body_pre_typing
(Some while_post_hint)
ppname
body
in
apply_checker_result_k r ppname
in
if eq_comp body_comp (comp_while_body nm inv)
then
let d = T_While g inv cond body inv_typing cond_typing body_typing in
prove_post_hint (try_frame_pre pre_typing (match_comp_res_with_post_hint d post_hint) res_ppname
)
post_hint
t.range
else
fail g
None
(Printf.sprintf "Could not prove the inferred type of the while body matches the annotation\nInferred type = %s\nAnnotated type = %s\n"
(P.comp_to_string body_comp)
(P.comp_to_string (comp_while_body nm inv)))
else
fail g
None
(Printf.sprintf "Could not prove that the inferred type of the while condition matches the annotation\nInferred type = %s\nAnnotated type = %s\n"
(P.comp_to_string cond_comp)
(P.comp_to_string (comp_while_cond nm inv))) | false |
Hacl.HMAC.fst | Hacl.HMAC.mk_wrap_key | val mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a) : wrap_key_st a | val mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a) : wrap_key_st a | let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 93,
"start_col": 0,
"start_line": 67
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40" | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.fixed_len_alg -> hash: Hacl.Hash.Definitions.hash_st a
-> Hacl.HMAC.wrap_key_st a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.fixed_len_alg",
"Hacl.Hash.Definitions.hash_st",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.block_length",
"Prims.l_and",
"Spec.Hash.Definitions.less_than_max_input_length",
"LowStar.Monotonic.Buffer.disjoint",
"FStar.UInt32.t",
"Prims.op_Equality",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"FStar.UInt32.lte",
"Hacl.Hash.Definitions.block_len",
"Prims._assert",
"FStar.Seq.Base.seq",
"LowStar.Monotonic.Buffer.as_seq",
"Spec.Agile.HMAC.wrap",
"Prims.unit",
"FStar.Seq.Base.lemma_eq_elim",
"FStar.Seq.Base.append",
"FStar.Seq.Base.equal",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.blit",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Spec.Agile.Hash.hash",
"FStar.Seq.Base.create",
"FStar.UInt32.sub",
"Lib.IntTypes.u8",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Ignore.ignore",
"LowStar.Monotonic.Buffer.mbuffer",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"LowStar.Buffer.sub",
"FStar.Ghost.hide",
"EverCrypt.Helpers.uint32_t",
"Hacl.HMAC.helper_smtpat",
"Hacl.HMAC.wrap_key_st"
] | [] | false | false | false | false | false | let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a) : wrap_key_st a =
| fun output key len ->
[@@ inline_let ]let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i ((D.block_len a) `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
let h0 = ST.get () in
assert (Seq.equal (B.as_seq h0 zeroes)
(Seq.create (v ((D.block_len a) `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` (D.block_len a)
then
(B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
assert (B.as_seq h1 output == wrap a (B.as_seq h0 key)))
else
(hash nkey key len;
let h1 = ST.get () in
assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))) | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.of_nat | val of_nat (x:nat) : poly | val of_nat (x:nat) : poly | let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 19,
"start_col": 0,
"start_line": 15
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
() | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.nat -> Vale.Math.Poly2_s.poly | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Vale.Math.Poly2_s.zero",
"Prims.bool",
"Prims.op_Modulus",
"Vale.Math.Poly2.op_Plus_Dot",
"Vale.Math.Poly2_s.one",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2_s.shift",
"Vale.Math.Poly2.Bits.of_nat",
"Prims.op_Division"
] | [
"recursion"
] | false | false | false | true | false | let rec of_nat x =
| if x = 0
then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one | false |
Hacl.HMAC.fst | Hacl.HMAC.len_add32 | val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len } | val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len } | let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len)) | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 80,
"end_line": 222,
"start_col": 0,
"start_line": 214
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len } | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.hash_alg{Prims.op_Negation (Spec.Hash.Definitions.is_keccak a)} ->
prev_len: Spec.Hash.Definitions.len_t a ->
input_len:
FStar.UInt32.t
{ Spec.Hash.Definitions.less_than_max_input_length (FStar.UInt32.v input_len +
Spec.Hash.Definitions.len_v a prev_len)
a }
-> x:
Spec.Hash.Definitions.len_t a
{ Spec.Hash.Definitions.len_v a x =
Spec.Hash.Definitions.len_v a prev_len + FStar.UInt32.v input_len } | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Prims.op_Negation",
"Spec.Hash.Definitions.is_keccak",
"Spec.Hash.Definitions.len_t",
"FStar.UInt32.t",
"Spec.Hash.Definitions.less_than_max_input_length",
"Prims.op_Addition",
"FStar.UInt32.v",
"Spec.Hash.Definitions.len_v",
"FStar.UInt64.op_Plus_Hat",
"FStar.Int.Cast.uint32_to_uint64",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.UInt128.op_Plus_Hat",
"FStar.UInt128.uint64_to_uint128",
"Prims.op_Equality",
"Prims.int"
] | [] | false | false | false | false | false | let len_add32 a prev_len input_len =
| let open FStar.Int.Cast.Full in
match a with
| SHA2_224
| SHA2_256
| MD5
| SHA1
| Blake2S ->
assert_norm (pow2 61 < pow2 64);
let open FStar.UInt64 in prev_len +^ uint32_to_uint64 input_len
| SHA2_384
| SHA2_512
| Blake2B ->
assert_norm (pow2 125 < pow2 128);
let open FStar.UInt128 in prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len) | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_to_of_uint | val lemma_to_of_uint (n:pos) (u:uint_t n) : Lemma
(ensures to_uint n (of_uint n u) == u)
[SMTPat (to_uint n (of_uint n u))] | val lemma_to_of_uint (n:pos) (u:uint_t n) : Lemma
(ensures to_uint n (of_uint n u) == u)
[SMTPat (to_uint n (of_uint n u))] | let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
() | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 13,
"start_col": 0,
"start_line": 5
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.pos -> u9: FStar.UInt.uint_t n
-> FStar.Pervasives.Lemma
(ensures Vale.Math.Poly2.Bits_s.to_uint n (Vale.Math.Poly2.Bits_s.of_uint n u9) == u9)
[SMTPat (Vale.Math.Poly2.Bits_s.to_uint n (Vale.Math.Poly2.Bits_s.of_uint n u9))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"FStar.UInt.uint_t",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Prims.bool",
"FStar.BitVector.bv_t",
"FStar.UInt.to_vec",
"Vale.Math.Poly2.Lemmas.lemma_reverse_define_all",
"Vale.Math.Poly2.Lemmas.lemma_index",
"Vale.Math.Poly2.Bits_s.to_uint",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Bits_s.of_uint"
] | [] | true | false | true | false | false | let lemma_to_of_uint n u =
| let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
() | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.lemma_mont_is_point_at_inf | val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p)) | val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p)) | let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 59,
"start_col": 0,
"start_line": 57
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p:
Spec.P256.PointOps.proj_point
{ let _ = p in
(let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ _ _ z = _ in
z < Spec.P256.PointOps.prime)
<:
Type0 }
-> FStar.Pervasives.Lemma
(ensures
Spec.P256.PointOps.is_point_at_inf p ==
Spec.P256.PointOps.is_point_at_inf (Hacl.Impl.P256.Point.from_mont_point p)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.P256.PointOps.proj_point",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Hacl.Spec.P256.Montgomery.lemma_from_mont_zero",
"Prims.unit"
] | [] | false | false | true | false | false | let lemma_mont_is_point_at_inf p =
| let px, py, pz = p in
SM.lemma_from_mont_zero pz | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_of_uint_zero | val lemma_of_uint_zero (n: nat) : Lemma (ensures of_uint_ n 0 == zero) | val lemma_of_uint_zero (n: nat) : Lemma (ensures of_uint_ n 0 == zero) | let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 32,
"start_col": 0,
"start_line": 28
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat
-> FStar.Pervasives.Lemma (ensures Vale.Math.Poly2.Bits.of_uint_ n 0 == Vale.Math.Poly2_s.zero) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.Bits.of_uint_",
"Vale.Math.Poly2_s.zero",
"Prims.unit",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Vale.Math.Poly2_s.poly",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_of_uint_zero (n: nat) : Lemma (ensures of_uint_ n 0 == zero) =
| lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_to_nat_rec | val lemma_to_nat_rec (len: nat) (p: poly) (c n i: nat)
: Lemma (requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[ len - n + i ] == (of_nat c).[ i ]) | val lemma_to_nat_rec (len: nat) (p: poly) (c n i: nat)
: Lemma (requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[ len - n + i ] == (of_nat c).[ i ]) | let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 73,
"end_line": 48,
"start_col": 0,
"start_line": 43
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Prims.nat -> p: Vale.Math.Poly2_s.poly -> c: Prims.nat -> n: Prims.nat -> i: Prims.nat
-> FStar.Pervasives.Lemma
(requires
Vale.Math.Poly2_s.degree p < len /\
FStar.Pervasives.normalize (Vale.Math.Poly2.Bits.poly_nat_eq_rec len p c n))
(ensures p.[ len - n + i ] == (Vale.Math.Poly2.Bits.of_nat c).[ i ]) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Math.Poly2_s.poly",
"Prims.op_AmpAmp",
"Prims.op_GreaterThan",
"Vale.Math.Poly2.Bits.lemma_to_nat_rec",
"Prims.op_Division",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.unit",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.Math.Poly2_s.degree",
"FStar.Pervasives.normalize",
"Vale.Math.Poly2.Bits.poly_nat_eq_rec",
"Prims.squash",
"Prims.eq2",
"Vale.Math.Poly2_s.op_String_Access",
"Prims.op_Addition",
"Vale.Math.Poly2.Bits.of_nat",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_to_nat_rec (len: nat) (p: poly) (c n i: nat)
: Lemma (requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[ len - n + i ] == (of_nat c).[ i ]) =
| lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1) | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_of_nat_of_uint | val lemma_of_nat_of_uint (n:nat) (x:nat) : Lemma
(requires x < pow2 n)
(ensures of_nat x == of_uint_ n x) | val lemma_of_nat_of_uint (n:nat) (x:nat) : Lemma
(requires x < pow2 n)
(ensures of_nat x == of_uint_ n x) | let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 41,
"start_col": 0,
"start_line": 34
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat -> x: Prims.nat
-> FStar.Pervasives.Lemma (requires x < Prims.pow2 n)
(ensures Vale.Math.Poly2.Bits.of_nat x == Vale.Math.Poly2.Bits.of_uint_ n x) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.op_GreaterThan",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.Bits.of_nat",
"Vale.Math.Poly2.Bits_s.of_uint",
"Prims.unit",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all",
"Vale.Math.Poly2.Bits.lemma_of_nat_of_uint",
"Prims.op_Subtraction",
"Prims.op_Division",
"Prims.bool"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_of_nat_of_uint n x =
| if n > 0
then
(lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)) | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.of_nat32_zero | val of_nat32_zero : _:unit{of_nat32 0 == zero} | val of_nat32_zero : _:unit{of_nat32 0 == zero} | let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 70,
"start_col": 0,
"start_line": 67
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit{Vale.Math.Poly2.Bits.of_nat32 0 == Vale.Math.Poly2_s.zero} | Prims.Tot | [
"total"
] | [] | [
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.Bits.of_nat32",
"Vale.Math.Poly2_s.zero",
"Prims.unit",
"Vale.Arch.TypesNative.lemma_zero_nth",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all"
] | [] | false | false | false | false | false | let of_nat32_zero =
| lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_of_to_vec_zero | val lemma_of_to_vec_zero (i n: nat)
: Lemma (requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)] | val lemma_of_to_vec_zero (i n: nat)
: Lemma (requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)] | let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 26,
"start_col": 0,
"start_line": 21
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Prims.nat -> n: Prims.nat
-> FStar.Pervasives.Lemma (requires i < n)
(ensures FStar.Seq.Base.index (FStar.UInt.to_vec 0) i == false)
[SMTPat (FStar.Seq.Base.index (FStar.UInt.to_vec 0) i)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.op_LessThan",
"Prims.op_Addition",
"Vale.Math.Poly2.Bits.lemma_of_to_vec_zero",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.unit",
"Prims.b2t",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.index",
"FStar.UInt.to_vec",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_of_to_vec_zero (i n: nat)
: Lemma (requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)] =
| if i + 1 < n then lemma_of_to_vec_zero i (n - 1) | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.of_nat32 | val of_nat32 (n:nat32) : p:poly{degree p < 32 /\ p == of_nat n} | val of_nat32 (n:nat32) : p:poly{degree p < 32 /\ p == of_nat n} | let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 60,
"start_col": 0,
"start_line": 58
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Vale.Def.Types_s.nat32
-> p:
Vale.Math.Poly2_s.poly{Vale.Math.Poly2_s.degree p < 32 /\ p == Vale.Math.Poly2.Bits.of_nat n} | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat32",
"Vale.Math.Poly2.Bits_s.of_uint",
"Prims.unit",
"Vale.Math.Poly2.Bits.lemma_of_nat_of_uint",
"Vale.Math.Poly2_s.poly",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.Math.Poly2_s.degree",
"Prims.eq2",
"Vale.Math.Poly2.Bits.of_nat"
] | [] | false | false | false | false | false | let of_nat32 n =
| lemma_of_nat_of_uint 32 n;
of_uint 32 n | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_to_nat | val lemma_to_nat (len:nat) (p:poly) (c:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c len))
(ensures p == of_nat c) | val lemma_to_nat (len:nat) (p:poly) (c:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c len))
(ensures p == of_nat c) | let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 56,
"start_col": 0,
"start_line": 50
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Prims.nat -> p: Vale.Math.Poly2_s.poly -> c: Prims.nat
-> FStar.Pervasives.Lemma
(requires
Vale.Math.Poly2_s.degree p < len /\
FStar.Pervasives.normalize (Vale.Math.Poly2.Bits.poly_nat_eq_rec len p c len))
(ensures p == Vale.Math.Poly2.Bits.of_nat c) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.Bits.of_nat",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.int",
"Prims.eq2",
"Prims.bool",
"Vale.Math.Poly2_s.op_String_Access",
"Prims.l_True",
"Prims.squash",
"Vale.Math.Poly2_s.poly_index",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims.op_LessThanOrEqual",
"Vale.Math.Poly2.Bits.lemma_to_nat_rec",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all"
] | [] | false | false | true | false | false | let lemma_to_nat len p c =
| lemma_bitwise_all ();
let f (i: int) : Lemma (p.[ i ] == (of_nat c).[ i ]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c) | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.create_aff_point | val create_aff_point: unit -> StackInline aff_point
(requires fun h -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 8 (u64 0))) | val create_aff_point: unit -> StackInline aff_point
(requires fun h -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 8 (u64 0))) | let create_aff_point () =
create 8ul (u64 0) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 24,
"start_col": 0,
"start_line": 23
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.HyperStack.ST.StackInline Hacl.Impl.P256.Point.aff_point | FStar.HyperStack.ST.StackInline | [] | [] | [
"Prims.unit",
"Lib.Buffer.create",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Lib.Buffer.lbuffer",
"Hacl.Impl.P256.Point.aff_point"
] | [] | false | true | false | false | false | let create_aff_point () =
| create 8ul (u64 0) | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.of_nat32_ones | val of_nat32_ones : _:unit{of_nat32 0xffffffff == ones 32} | val of_nat32_ones : _:unit{of_nat32 0xffffffff == ones 32} | let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 74,
"start_col": 0,
"start_line": 72
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit{Vale.Math.Poly2.Bits.of_nat32 0xffffffff == Vale.Math.Poly2.ones 32} | Prims.Tot | [
"total"
] | [] | [
"Vale.Math.Poly2.Bits.lemma_to_nat",
"Vale.Math.Poly2.ones",
"Prims.unit",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all"
] | [] | false | false | false | false | false | let of_nat32_ones =
| lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_of_nat_of_uint32 | val lemma_of_nat_of_uint32 (x: nat32) : Lemma (ensures of_nat32 x == of_nat x) | val lemma_of_nat_of_uint32 (x: nat32) : Lemma (ensures of_nat32 x == of_nat x) | let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 65,
"start_col": 0,
"start_line": 62
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Vale.Def.Types_s.nat32
-> FStar.Pervasives.Lemma
(ensures Vale.Math.Poly2.Bits.of_nat32 x == Vale.Math.Poly2.Bits.of_nat x) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.nat32",
"Vale.Math.Poly2.Bits.lemma_of_nat_of_uint",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Bits.of_nat32",
"Vale.Math.Poly2.Bits.of_nat",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_of_nat_of_uint32 (x: nat32) : Lemma (ensures of_nat32 x == of_nat x) =
| lemma_of_nat_of_uint 32 x | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.make_base_point | val make_base_point: p:point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
point_inv h1 p /\ from_mont_point (as_point_nat h1 p) == S.base_point) | val make_base_point: p:point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
point_inv h1 p /\ from_mont_point (as_point_nat h1 p) == S.base_point) | let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 38,
"start_col": 0,
"start_line": 32
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Field.make_fone",
"Prims.unit",
"Hacl.Impl.P256.Constants.make_g_y",
"Hacl.Impl.P256.Constants.make_g_x",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.getz",
"Hacl.Impl.P256.Point.gety",
"Hacl.Impl.P256.Point.getx"
] | [] | false | true | false | false | false | let make_base_point p =
| let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_poly128_extract_nat32s | val lemma_poly128_extract_nat32s (a0 a1 a2 a3:nat32) : Lemma
(
let a = poly128_of_nat32s a0 a1 a2 a3 in
of_nat32 a0 == mask a 32 /\
of_nat32 a1 == mask (shift a (-32)) 32 /\
of_nat32 a2 == mask (shift a (-64)) 32 /\
of_nat32 a3 == shift a (-96)
) | val lemma_poly128_extract_nat32s (a0 a1 a2 a3:nat32) : Lemma
(
let a = poly128_of_nat32s a0 a1 a2 a3 in
of_nat32 a0 == mask a 32 /\
of_nat32 a1 == mask (shift a (-32)) 32 /\
of_nat32 a2 == mask (shift a (-64)) 32 /\
of_nat32 a3 == shift a (-96)
) | let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
() | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 100,
"start_col": 0,
"start_line": 93
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b)) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a0: Vale.Def.Types_s.nat32 ->
a1: Vale.Def.Types_s.nat32 ->
a2: Vale.Def.Types_s.nat32 ->
a3: Vale.Def.Types_s.nat32
-> FStar.Pervasives.Lemma
(ensures
(let a = Vale.Math.Poly2.Bits.poly128_of_nat32s a0 a1 a2 a3 in
Vale.Math.Poly2.Bits.of_nat32 a0 == Vale.Math.Poly2.mask a 32 /\
Vale.Math.Poly2.Bits.of_nat32 a1 ==
Vale.Math.Poly2.mask (Vale.Math.Poly2_s.shift a (- 32)) 32 /\
Vale.Math.Poly2.Bits.of_nat32 a2 ==
Vale.Math.Poly2.mask (Vale.Math.Poly2_s.shift a (- 64)) 32 /\
Vale.Math.Poly2.Bits.of_nat32 a3 == Vale.Math.Poly2_s.shift a (- 96))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.nat32",
"Prims.unit",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.Bits.of_nat32",
"Vale.Math.Poly2_s.shift",
"Prims.op_Minus",
"Vale.Math.Poly2.mask",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Bits.poly128_of_nat32s"
] | [] | true | false | true | false | false | let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
| let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (- 32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (- 64)) 32);
lemma_equal (of_nat32 a3) (shift a (- 96));
() | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.is_point_at_inf | val is_point_at_inf: p:point -> Stack uint64
(requires fun h -> live h p /\ point_inv h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
(let pM = from_mont_point (as_point_nat h0 p) in
(if S.is_point_at_inf pM then v r = ones_v U64 else v r = 0) /\
(if S.is_point_at_inf (as_point_nat h0 p) then v r = ones_v U64 else v r = 0))) | val is_point_at_inf: p:point -> Stack uint64
(requires fun h -> live h p /\ point_inv h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
(let pM = from_mont_point (as_point_nat h0 p) in
(if S.is_point_at_inf pM then v r = ones_v U64 else v r = 0) /\
(if S.is_point_at_inf (as_point_nat h0 p) then v r = ones_v U64 else v r = 0))) | let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 67,
"start_col": 0,
"start_line": 63
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64 | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Bignum.bn_is_zero_mask4",
"Lib.IntTypes.uint64",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.getz",
"Prims.unit",
"Hacl.Impl.P256.Point.lemma_mont_is_point_at_inf",
"Hacl.Impl.P256.Point.as_point_nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let is_point_at_inf p =
| let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_quad32_extract_nat32s | val lemma_quad32_extract_nat32s (a:poly) : Lemma
(requires degree a <= 127)
(ensures (
let Mkfour a0 a1 a2 a3 = to_quad32 a in
of_nat32 a0 == mask a 32 /\
of_nat32 a1 == mask (shift a (-32)) 32 /\
of_nat32 a2 == mask (shift a (-64)) 32 /\
of_nat32 a3 == shift a (-96)
)) | val lemma_quad32_extract_nat32s (a:poly) : Lemma
(requires degree a <= 127)
(ensures (
let Mkfour a0 a1 a2 a3 = to_quad32 a in
of_nat32 a0 == mask a 32 /\
of_nat32 a1 == mask (shift a (-32)) 32 /\
of_nat32 a2 == mask (shift a (-64)) 32 /\
of_nat32 a3 == shift a (-96)
)) | let lemma_quad32_extract_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
lemma_quad32_to_nat32s a;
lemma_poly128_extract_nat32s a0 a1 a2 a3;
() | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 120,
"start_col": 0,
"start_line": 116
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
()
#reset-options "--z3rlimit 20"
let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a)
#reset-options
let lemma_quad32_to_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Math.Poly2_s.poly
-> FStar.Pervasives.Lemma (requires Vale.Math.Poly2_s.degree a <= 127)
(ensures
(let _ = Vale.Math.Poly2.Bits_s.to_quad32 a in
(let { lo0 = a0 ; lo1 = a1 ; hi2 = a2 ; hi3 = a3 } = _ in
Vale.Math.Poly2.Bits.of_nat32 a0 == Vale.Math.Poly2.mask a 32 /\
Vale.Math.Poly2.Bits.of_nat32 a1 ==
Vale.Math.Poly2.mask (Vale.Math.Poly2_s.shift a (- 32)) 32 /\
Vale.Math.Poly2.Bits.of_nat32 a2 ==
Vale.Math.Poly2.mask (Vale.Math.Poly2_s.shift a (- 64)) 32 /\
Vale.Math.Poly2.Bits.of_nat32 a3 == Vale.Math.Poly2_s.shift a (- 96))
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Vale.Def.Types_s.nat32",
"Prims.unit",
"Vale.Math.Poly2.Bits.lemma_poly128_extract_nat32s",
"Vale.Math.Poly2.Bits.lemma_quad32_to_nat32s",
"Vale.Def.Types_s.quad32",
"Vale.Math.Poly2.Bits_s.to_quad32"
] | [] | false | false | true | false | false | let lemma_quad32_extract_nat32s a =
| let Mkfour a0 a1 a2 a3 = to_quad32 a in
lemma_quad32_to_nat32s a;
lemma_poly128_extract_nat32s a0 a1 a2 a3;
() | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.copy_point | val copy_point: res:point -> p:point -> Stack unit
(requires fun h -> live h p /\ live h res /\ disjoint p res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == as_seq h0 p) | val copy_point: res:point -> p:point -> Stack unit
(requires fun h -> live h p /\ live h res /\ disjoint p res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == as_seq h0 p) | let copy_point res p =
copy res p | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 81,
"start_col": 0,
"start_line": 80
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Point.point -> p: Hacl.Impl.P256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Lib.Buffer.copy",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Prims.unit"
] | [] | false | true | false | false | false | let copy_point res p =
| copy res p | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.of_nat32_eq | val of_nat32_eq (a b:nat32) : Lemma
(requires of_nat32 a == of_nat32 b)
(ensures a == b) | val of_nat32_eq (a b:nat32) : Lemma
(requires of_nat32 a == of_nat32 b)
(ensures a == b) | let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
() | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 81,
"start_col": 0,
"start_line": 76
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Def.Types_s.nat32 -> b: Vale.Def.Types_s.nat32
-> FStar.Pervasives.Lemma
(requires Vale.Math.Poly2.Bits.of_nat32 a == Vale.Math.Poly2.Bits.of_nat32 b) (ensures a == b) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.nat32",
"Prims.unit",
"Vale.Math.Poly2.Bits.lemma_to_of_uint",
"Vale.Math.Poly2.Bits.lemma_of_nat_of_uint"
] | [] | true | false | true | false | false | let of_nat32_eq a b =
| lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
() | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.of_nat32_xor | val of_nat32_xor (a b:nat32) : Lemma
(of_nat32 a +. of_nat32 b == of_nat32 (ixor a b)) | val of_nat32_xor (a b:nat32) : Lemma
(of_nat32 a +. of_nat32 b == of_nat32 (ixor a b)) | let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b)) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 86,
"start_col": 0,
"start_line": 83
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
() | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Def.Types_s.nat32 -> b: Vale.Def.Types_s.nat32
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Poly2.Bits.of_nat32 a +. Vale.Math.Poly2.Bits.of_nat32 b ==
Vale.Math.Poly2.Bits.of_nat32 (Vale.Def.Types_s.ixor a b)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.nat32",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.op_Plus_Dot",
"Vale.Math.Poly2.Bits.of_nat32",
"Vale.Def.Types_s.ixor",
"Vale.Def.Words_s.pow2_32",
"Prims.unit",
"Vale.Arch.TypesNative.lemma_ixor_nth_all",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all"
] | [] | true | false | true | false | false | let of_nat32_xor a b =
| lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b)) | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.of_nat32_and | val of_nat32_and (a b:nat32) : Lemma
(poly_and (of_nat32 a) (of_nat32 b) == of_nat32 (iand a b)) | val of_nat32_and (a b:nat32) : Lemma
(poly_and (of_nat32 a) (of_nat32 b) == of_nat32 (iand a b)) | let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b)) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 72,
"end_line": 91,
"start_col": 0,
"start_line": 88
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b)) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Def.Types_s.nat32 -> b: Vale.Def.Types_s.nat32
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Poly2.poly_and (Vale.Math.Poly2.Bits.of_nat32 a) (Vale.Math.Poly2.Bits.of_nat32 b) ==
Vale.Math.Poly2.Bits.of_nat32 (Vale.Def.Types_s.iand a b)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.nat32",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.poly_and",
"Vale.Math.Poly2.Bits.of_nat32",
"Vale.Def.Types_s.iand",
"Vale.Def.Words_s.pow2_32",
"Prims.unit",
"Vale.Arch.TypesNative.lemma_iand_nth_all",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all"
] | [] | true | false | true | false | false | let of_nat32_and a b =
| lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b)) | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.make_point_at_inf | val make_point_at_inf: p:point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
point_inv h1 p /\ from_mont_point (as_point_nat h1 p) == S.point_at_inf) | val make_point_at_inf: p:point -> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
point_inv h1 p /\ from_mont_point (as_point_nat h1 p) == S.point_at_inf) | let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 48,
"start_col": 0,
"start_line": 42
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Field.make_fzero",
"Prims.unit",
"Hacl.Impl.P256.Field.make_fone",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.getz",
"Hacl.Impl.P256.Point.gety",
"Hacl.Impl.P256.Point.getx"
] | [] | false | true | false | false | false | let make_point_at_inf p =
| let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.is_point_at_inf_vartime | val is_point_at_inf_vartime: p:point -> Stack bool
(requires fun h -> live h p /\ point_inv h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.is_point_at_inf (as_point_nat h0 p) /\
r == S.is_point_at_inf (from_mont_point (as_point_nat h0 p))) | val is_point_at_inf_vartime: p:point -> Stack bool
(requires fun h -> live h p /\ point_inv h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.is_point_at_inf (as_point_nat h0 p) /\
r == S.is_point_at_inf (from_mont_point (as_point_nat h0 p))) | let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 24,
"end_line": 75,
"start_col": 0,
"start_line": 71
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Bignum.bn_is_zero_vartime4",
"Prims.bool",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.getz",
"Prims.unit",
"Hacl.Impl.P256.Point.lemma_mont_is_point_at_inf",
"Hacl.Impl.P256.Point.as_point_nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let is_point_at_inf_vartime p =
| let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz | false |
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.a'_ | val a'_ : Prims.int | let a'_ = 3 | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 20,
"start_col": 0,
"start_line": 20
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let a'_ =
| 3 | false |
|
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_of_double32_degree | val lemma_of_double32_degree (d:double32) : Lemma
(degree (of_double32 d) < 64)
[SMTPat (degree (of_double32 d))] | val lemma_of_double32_degree (d:double32) : Lemma
(degree (of_double32 d) < 64)
[SMTPat (degree (of_double32 d))] | let lemma_of_double32_degree (d:double32) =
reveal_of_double32 d | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 139,
"start_col": 0,
"start_line": 138
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
()
#reset-options "--z3rlimit 20"
let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a)
#reset-options
let lemma_quad32_to_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3)
let lemma_quad32_extract_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
lemma_quad32_to_nat32s a;
lemma_poly128_extract_nat32s a0 a1 a2 a3;
()
let lemma_quad32_double a =
let q = to_quad32 a in
let lo = quad32_double_lo q in
let hi = quad32_double_hi q in
let n = monomial 64 in
reveal_to_quad32 a;
reveal_of_double32 lo;
reveal_of_double32 hi;
lemma_split_define a 64;
lemma_add_define_all ();
lemma_reverse_define_all ();
lemma_index_all ();
lemma_equal (of_double32 lo) (a %. n);
lemma_equal (of_double32 hi) (a /. n);
() | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d: Vale.Def.Types_s.double32
-> FStar.Pervasives.Lemma
(ensures Vale.Math.Poly2_s.degree (Vale.Math.Poly2.Bits_s.of_double32 d) < 64)
[SMTPat (Vale.Math.Poly2_s.degree (Vale.Math.Poly2.Bits_s.of_double32 d))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.double32",
"Vale.Math.Poly2.Bits_s.reveal_of_double32",
"Prims.unit"
] | [] | true | false | true | false | false | let lemma_of_double32_degree (d: double32) =
| reveal_of_double32 d | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_quad32_to_nat32s | val lemma_quad32_to_nat32s (a:poly) : Lemma
(requires degree a <= 127)
(ensures (
let Mkfour a0 a1 a2 a3 = to_quad32 a in
a == poly128_of_nat32s a0 a1 a2 a3
)) | val lemma_quad32_to_nat32s (a:poly) : Lemma
(requires degree a <= 127)
(ensures (
let Mkfour a0 a1 a2 a3 = to_quad32 a in
a == poly128_of_nat32s a0 a1 a2 a3
)) | let lemma_quad32_to_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 114,
"start_col": 0,
"start_line": 110
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
()
#reset-options "--z3rlimit 20"
let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a)
#reset-options | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Math.Poly2_s.poly
-> FStar.Pervasives.Lemma (requires Vale.Math.Poly2_s.degree a <= 127)
(ensures
(let _ = Vale.Math.Poly2.Bits_s.to_quad32 a in
(let { lo0 = a0 ; lo1 = a1 ; hi2 = a2 ; hi3 = a3 } = _ in
a == Vale.Math.Poly2.Bits.poly128_of_nat32s a0 a1 a2 a3)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Vale.Def.Types_s.nat32",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.Bits.poly128_of_nat32s",
"Prims.unit",
"Vale.Math.Poly2.Lemmas.lemma_bitwise_all",
"Vale.Math.Poly2.Bits_s.reveal_to_quad32",
"Vale.Def.Types_s.quad32",
"Vale.Math.Poly2.Bits_s.to_quad32"
] | [] | false | false | true | false | false | let lemma_quad32_to_nat32s a =
| let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3) | false |
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.x2 | val x2 : Prims.int | let x2 = 3 | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 10,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_ | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let x2 =
| 3 | false |
|
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.f | val f : Prims.int | let f = a'_ | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 21,
"start_col": 0,
"start_line": 21
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [
"FStar.InteractiveHelpers.ParseTest.a'_"
] | [] | false | false | false | true | false | let f =
| a'_ | false |
|
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_of_quad32_degree | val lemma_of_quad32_degree (q:quad32) : Lemma
(degree (of_quad32 q) < 128)
[SMTPat (degree (of_quad32 q))] | val lemma_of_quad32_degree (q:quad32) : Lemma
(degree (of_quad32 q) < 128)
[SMTPat (degree (of_quad32 q))] | let lemma_of_quad32_degree (q:quad32) =
reveal_of_quad32 q | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 142,
"start_col": 0,
"start_line": 141
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
()
#reset-options "--z3rlimit 20"
let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a)
#reset-options
let lemma_quad32_to_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3)
let lemma_quad32_extract_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
lemma_quad32_to_nat32s a;
lemma_poly128_extract_nat32s a0 a1 a2 a3;
()
let lemma_quad32_double a =
let q = to_quad32 a in
let lo = quad32_double_lo q in
let hi = quad32_double_hi q in
let n = monomial 64 in
reveal_to_quad32 a;
reveal_of_double32 lo;
reveal_of_double32 hi;
lemma_split_define a 64;
lemma_add_define_all ();
lemma_reverse_define_all ();
lemma_index_all ();
lemma_equal (of_double32 lo) (a %. n);
lemma_equal (of_double32 hi) (a /. n);
()
let lemma_of_double32_degree (d:double32) =
reveal_of_double32 d | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | q: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(ensures Vale.Math.Poly2_s.degree (Vale.Math.Poly2.Bits_s.of_quad32 q) < 128)
[SMTPat (Vale.Math.Poly2_s.degree (Vale.Math.Poly2.Bits_s.of_quad32 q))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.quad32",
"Vale.Math.Poly2.Bits_s.reveal_of_quad32",
"Prims.unit"
] | [] | true | false | true | false | false | let lemma_of_quad32_degree (q: quad32) =
| reveal_of_quad32 q | false |
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.x3 | val x3 : Prims.int | let x3 = x1-x2 | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 25,
"start_col": 0,
"start_line": 25
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_
let x1 = Some?.v (Some 3) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.op_Subtraction",
"FStar.InteractiveHelpers.ParseTest.x1",
"FStar.InteractiveHelpers.ParseTest.x2"
] | [] | false | false | false | true | false | let x3 =
| x1 - x2 | false |
|
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.test1 | val test1 : b: Prims.bool -> l: Prims.list Prims.int -> Prims.bool | let test1 b (l : list int) =
if b then
match l with
| [] -> true
| _ -> false
else
match l with
| [x] -> true
| _ -> false | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 16,
"end_line": 61,
"start_col": 0,
"start_line": 53
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_
let x1 = Some?.v (Some 3)
let x2 = 3
let x3 = x1-x2
let simpl_ex1 (x : nat) =
let y = 4 in
let 'x = 7 in
let 'a = 4 in
let 'd = "hello world!" in
let '_u''x = 5 in
let z = 3 in
let w : w:nat{w >= 10} =
if x > 3 then
begin
assert(y + x > 7);
let x' = x + 1 in
assert(y + x' > 8);
let x'' = 2 * (y + x') in
assert(x'' > 16);
assert(x'' >= 10);
2 * x'
end
else 12
in
assert(
x >= 0 /\
y >= 0);
let w' = 2 * w + z in
w' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Prims.bool -> l: Prims.list Prims.int -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Prims.list",
"Prims.int"
] | [] | false | false | false | true | false | let test1 b (l: list int) =
| if b
then
match l with
| [] -> true
| _ -> false
else
match l with
| [x] -> true
| _ -> false | false |
|
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.create_point | val create_point: unit -> StackInline point
(requires fun h -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 12 (u64 0))) | val create_point: unit -> StackInline point
(requires fun h -> True)
(ensures fun h0 f h1 ->
stack_allocated f h0 h1 (LSeq.create 12 (u64 0))) | let create_point () =
create 12ul (u64 0) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 28,
"start_col": 0,
"start_line": 27
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.HyperStack.ST.StackInline Hacl.Impl.P256.Point.point | FStar.HyperStack.ST.StackInline | [] | [] | [
"Prims.unit",
"Lib.Buffer.create",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Lib.Buffer.lbuffer",
"Hacl.Impl.P256.Point.point"
] | [] | false | true | false | false | false | let create_point () =
| create 12ul (u64 0) | false |
Loop.fst | Loop.cd | [@@ FStar.Tactics.Typeclasses.tcinstance]
val cd (dict: c 'a) : d 'a | [@@ FStar.Tactics.Typeclasses.tcinstance]
val cd (dict: c 'a) : d 'a | instance cd (dict : c 'a) : d 'a = { y = dict.x } | {
"file_name": "examples/typeclasses/Loop.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 26,
"start_col": 0,
"start_line": 26
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Loop
(* Making sure typeclass resolution does not loop *)
open FStar.Tactics.Typeclasses
(* two classes for inhabitation *)
class c a = { x : a }
class d a = { y : a } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Loop.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dict: Loop.c 'a -> Loop.d 'a | Prims.Tot | [
"total"
] | [] | [
"Loop.c",
"Loop.Mkd",
"Loop.__proj__Mkc__item__x",
"Loop.d"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let cd (dict: c 'a) : d 'a =
| { y = dict.x } | false |
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.test5 | val test5 : a: Type0 -> Type0 | let test5 a =
f1 #(list a) | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 85,
"start_col": 0,
"start_line": 84
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_
let x1 = Some?.v (Some 3)
let x2 = 3
let x3 = x1-x2
let simpl_ex1 (x : nat) =
let y = 4 in
let 'x = 7 in
let 'a = 4 in
let 'd = "hello world!" in
let '_u''x = 5 in
let z = 3 in
let w : w:nat{w >= 10} =
if x > 3 then
begin
assert(y + x > 7);
let x' = x + 1 in
assert(y + x' > 8);
let x'' = 2 * (y + x') in
assert(x'' > 16);
assert(x'' >= 10);
2 * x'
end
else 12
in
assert(
x >= 0 /\
y >= 0);
let w' = 2 * w + z in
w'
let test1 b (l : list int) =
if b then
match l with
| [] -> true
| _ -> false
else
match l with
| [x] -> true
| _ -> false
let test2 #a b (l : list a) =
if b then ()
else assert(not b);
let x = 3 in
let y =
4 +
begin
if b then
let x = 4 in 2 * x
else 8
end
in
x + y
let test3 'a = test2 'a
let test4 b l =
assert(test2 b l == test2 b l)
let f1 (#a : Type0) : Type = list a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.InteractiveHelpers.ParseTest.f1",
"Prims.list"
] | [] | false | false | false | true | true | let test5 a =
| f1 #(list a) | false |
|
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.test3 | val test3 : 'a: Prims.bool -> l: Prims.list _ -> Prims.int | let test3 'a = test2 'a | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 77,
"start_col": 0,
"start_line": 77
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_
let x1 = Some?.v (Some 3)
let x2 = 3
let x3 = x1-x2
let simpl_ex1 (x : nat) =
let y = 4 in
let 'x = 7 in
let 'a = 4 in
let 'd = "hello world!" in
let '_u''x = 5 in
let z = 3 in
let w : w:nat{w >= 10} =
if x > 3 then
begin
assert(y + x > 7);
let x' = x + 1 in
assert(y + x' > 8);
let x'' = 2 * (y + x') in
assert(x'' > 16);
assert(x'' >= 10);
2 * x'
end
else 12
in
assert(
x >= 0 /\
y >= 0);
let w' = 2 * w + z in
w'
let test1 b (l : list int) =
if b then
match l with
| [] -> true
| _ -> false
else
match l with
| [x] -> true
| _ -> false
let test2 #a b (l : list a) =
if b then ()
else assert(not b);
let x = 3 in
let y =
4 +
begin
if b then
let x = 4 in 2 * x
else 8
end
in
x + y | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | 'a: Prims.bool -> l: Prims.list _ -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"FStar.InteractiveHelpers.ParseTest.test2",
"Prims.list",
"Prims.int"
] | [] | false | false | false | true | false | let test3 'a =
| test2 'a | false |
|
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.test4 | val test4 : b: Prims.bool -> l: Prims.list _ -> Prims.unit | let test4 b l =
assert(test2 b l == test2 b l) | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 80,
"start_col": 0,
"start_line": 79
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_
let x1 = Some?.v (Some 3)
let x2 = 3
let x3 = x1-x2
let simpl_ex1 (x : nat) =
let y = 4 in
let 'x = 7 in
let 'a = 4 in
let 'd = "hello world!" in
let '_u''x = 5 in
let z = 3 in
let w : w:nat{w >= 10} =
if x > 3 then
begin
assert(y + x > 7);
let x' = x + 1 in
assert(y + x' > 8);
let x'' = 2 * (y + x') in
assert(x'' > 16);
assert(x'' >= 10);
2 * x'
end
else 12
in
assert(
x >= 0 /\
y >= 0);
let w' = 2 * w + z in
w'
let test1 b (l : list int) =
if b then
match l with
| [] -> true
| _ -> false
else
match l with
| [x] -> true
| _ -> false
let test2 #a b (l : list a) =
if b then ()
else assert(not b);
let x = 3 in
let y =
4 +
begin
if b then
let x = 4 in 2 * x
else 8
end
in
x + y
let test3 'a = test2 'a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Prims.bool -> l: Prims.list _ -> Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Prims.list",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"FStar.InteractiveHelpers.ParseTest.test2",
"Prims.unit"
] | [] | false | false | false | true | false | let test4 b l =
| assert (test2 b l == test2 b l) | false |
|
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.is_xy_valid_vartime | val is_xy_valid_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == (aff_point_x_as_nat h0 p < S.prime &&
aff_point_y_as_nat h0 p < S.prime)) | val is_xy_valid_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == (aff_point_x_as_nat h0 p < S.prime &&
aff_point_y_as_nat h0 p < S.prime)) | let is_xy_valid_vartime p =
let px = aff_getx p in
let py = aff_gety p in
let lessX = bn_is_lt_prime_mask4 px in
let lessY = bn_is_lt_prime_mask4 py in
let res = logand lessX lessY in
logand_lemma lessX lessY;
Hacl.Bignum.Base.unsafe_bool_of_limb res | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 225,
"start_col": 0,
"start_line": 218
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff
[@CInline]
let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r
/// Point load and store functions
[@CInline]
let aff_point_store res p =
let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py
[@CInline]
let point_store res p =
push_frame ();
let aff_p = create_aff_point () in
to_aff_point aff_p p;
aff_point_store res aff_p;
pop_frame ()
inline_for_extraction noextract
val is_xy_valid_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == (aff_point_x_as_nat h0 p < S.prime &&
aff_point_y_as_nat h0 p < S.prime)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.aff_point -> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Spec.Bignum.Base.unsafe_bool_of_limb",
"Lib.IntTypes.U64",
"Prims.unit",
"Lib.IntTypes.logand_lemma",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Lib.IntTypes.logand",
"Prims.bool",
"Hacl.Impl.P256.Field.bn_is_lt_prime_mask4",
"Lib.IntTypes.uint64",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.aff_gety",
"Hacl.Impl.P256.Point.aff_getx"
] | [] | false | true | false | false | false | let is_xy_valid_vartime p =
| let px = aff_getx p in
let py = aff_gety p in
let lessX = bn_is_lt_prime_mask4 px in
let lessY = bn_is_lt_prime_mask4 py in
let res = logand lessX lessY in
logand_lemma lessX lessY;
Hacl.Bignum.Base.unsafe_bool_of_limb res | false |
Loop.fst | Loop.dc | [@@ FStar.Tactics.Typeclasses.tcinstance]
val dc (dict: d 'a) : c 'a | [@@ FStar.Tactics.Typeclasses.tcinstance]
val dc (dict: d 'a) : c 'a | instance dc (dict : d 'a) : c 'a = { x = dict.y } | {
"file_name": "examples/typeclasses/Loop.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 27,
"start_col": 0,
"start_line": 27
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Loop
(* Making sure typeclass resolution does not loop *)
open FStar.Tactics.Typeclasses
(* two classes for inhabitation *)
class c a = { x : a }
class d a = { y : a } | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Loop.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dict: Loop.d 'a -> Loop.c 'a | Prims.Tot | [
"total"
] | [] | [
"Loop.d",
"Loop.Mkc",
"Loop.__proj__Mkd__item__y",
"Loop.c"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let dc (dict: d 'a) : c 'a =
| { x = dict.y } | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_of_to_quad32_mask | val lemma_of_to_quad32_mask (a:poly) : Lemma
(of_quad32 (to_quad32 a) == mask a 128) | val lemma_of_to_quad32_mask (a:poly) : Lemma
(of_quad32 (to_quad32 a) == mask a 128) | let lemma_of_to_quad32_mask a =
reveal_to_quad32 a;
reveal_of_quad32 (to_quad32 a);
lemma_index_all ();
lemma_reverse_define_all ();
lemma_mask_define_all ();
lemma_equal (mask a 128) (of_quad32 (to_quad32 a)) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 181,
"start_col": 0,
"start_line": 175
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
()
#reset-options "--z3rlimit 20"
let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a)
#reset-options
let lemma_quad32_to_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3)
let lemma_quad32_extract_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
lemma_quad32_to_nat32s a;
lemma_poly128_extract_nat32s a0 a1 a2 a3;
()
let lemma_quad32_double a =
let q = to_quad32 a in
let lo = quad32_double_lo q in
let hi = quad32_double_hi q in
let n = monomial 64 in
reveal_to_quad32 a;
reveal_of_double32 lo;
reveal_of_double32 hi;
lemma_split_define a 64;
lemma_add_define_all ();
lemma_reverse_define_all ();
lemma_index_all ();
lemma_equal (of_double32 lo) (a %. n);
lemma_equal (of_double32 hi) (a /. n);
()
let lemma_of_double32_degree (d:double32) =
reveal_of_double32 d
let lemma_of_quad32_degree (q:quad32) =
reveal_of_quad32 q
#reset-options "--z3rlimit 30"
let lemma_to_of_quad32 q =
reveal_of_quad32 q;
reveal_to_quad32 (of_quad32 q);
let a = of_quad32 q in
let Mkfour q0 q1 q2 q3 = q in
let Mkfour q0' q1' q2' q3' = to_quad32 a in
lemma_index a;
lemma_reverse_define_all ();
let s0 = UInt.to_vec #32 q0 in
let s1 = UInt.to_vec #32 q1 in
let s2 = UInt.to_vec #32 q2 in
let s3 = UInt.to_vec #32 q3 in
let s0' = UInt.to_vec #32 q0' in
let s1' = UInt.to_vec #32 q1' in
let s2' = UInt.to_vec #32 q2' in
let s3' = UInt.to_vec #32 q3' in
assert (equal s0 s0');
assert (equal s1 s1');
assert (equal s2 s2');
assert (equal s3 s3');
()
#reset-options
let lemma_of_to_quad32 a =
reveal_to_quad32 a;
reveal_of_quad32 (to_quad32 a);
lemma_index_all ();
lemma_reverse_define_all ();
lemma_equal a (of_quad32 (to_quad32 a)) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Math.Poly2_s.poly
-> FStar.Pervasives.Lemma
(ensures
Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 a) ==
Vale.Math.Poly2.mask a 128) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.mask",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Prims.unit",
"Vale.Math.Poly2.Lemmas.lemma_mask_define_all",
"Vale.Math.Poly2.Lemmas.lemma_reverse_define_all",
"Vale.Math.Poly2.Lemmas.lemma_index_all",
"Vale.Math.Poly2.Bits_s.reveal_of_quad32",
"Vale.Math.Poly2.Bits_s.reveal_to_quad32"
] | [] | true | false | true | false | false | let lemma_of_to_quad32_mask a =
| reveal_to_quad32 a;
reveal_of_quad32 (to_quad32 a);
lemma_index_all ();
lemma_reverse_define_all ();
lemma_mask_define_all ();
lemma_equal (mask a 128) (of_quad32 (to_quad32 a)) | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_quad32_double | val lemma_quad32_double (a:poly) : Lemma
(requires degree a <= 127)
(ensures
of_double32 (quad32_double_lo (to_quad32 a)) == a %. monomial 64 /\
of_double32 (quad32_double_hi (to_quad32 a)) == a /. monomial 64 /\
a == (a /. monomial 64) *. monomial 64 +. a %. monomial 64 /\
(a /. monomial 64) *. monomial 64 == shift (a /. monomial 64) 64
) | val lemma_quad32_double (a:poly) : Lemma
(requires degree a <= 127)
(ensures
of_double32 (quad32_double_lo (to_quad32 a)) == a %. monomial 64 /\
of_double32 (quad32_double_hi (to_quad32 a)) == a /. monomial 64 /\
a == (a /. monomial 64) *. monomial 64 +. a %. monomial 64 /\
(a /. monomial 64) *. monomial 64 == shift (a /. monomial 64) 64
) | let lemma_quad32_double a =
let q = to_quad32 a in
let lo = quad32_double_lo q in
let hi = quad32_double_hi q in
let n = monomial 64 in
reveal_to_quad32 a;
reveal_of_double32 lo;
reveal_of_double32 hi;
lemma_split_define a 64;
lemma_add_define_all ();
lemma_reverse_define_all ();
lemma_index_all ();
lemma_equal (of_double32 lo) (a %. n);
lemma_equal (of_double32 hi) (a /. n);
() | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 136,
"start_col": 0,
"start_line": 122
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
()
#reset-options "--z3rlimit 20"
let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a)
#reset-options
let lemma_quad32_to_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3)
let lemma_quad32_extract_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
lemma_quad32_to_nat32s a;
lemma_poly128_extract_nat32s a0 a1 a2 a3;
() | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Math.Poly2_s.poly
-> FStar.Pervasives.Lemma (requires Vale.Math.Poly2_s.degree a <= 127)
(ensures
Vale.Math.Poly2.Bits_s.of_double32 (Vale.Arch.Types.quad32_double_lo (Vale.Math.Poly2.Bits_s.to_quad32
a)) ==
a %. Vale.Math.Poly2_s.monomial 64 /\
Vale.Math.Poly2.Bits_s.of_double32 (Vale.Arch.Types.quad32_double_hi (Vale.Math.Poly2.Bits_s.to_quad32
a)) ==
a /. Vale.Math.Poly2_s.monomial 64 /\
a ==
a /. Vale.Math.Poly2_s.monomial 64 *. Vale.Math.Poly2_s.monomial 64 +.
a %. Vale.Math.Poly2_s.monomial 64 /\
a /. Vale.Math.Poly2_s.monomial 64 *. Vale.Math.Poly2_s.monomial 64 ==
Vale.Math.Poly2_s.shift (a /. Vale.Math.Poly2_s.monomial 64) 64) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Prims.unit",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.Bits_s.of_double32",
"Vale.Math.Poly2.op_Slash_Dot",
"Vale.Math.Poly2.op_Percent_Dot",
"Vale.Math.Poly2.Lemmas.lemma_index_all",
"Vale.Math.Poly2.Lemmas.lemma_reverse_define_all",
"Vale.Math.Poly2.Lemmas.lemma_add_define_all",
"Vale.Math.Poly2.Lemmas.lemma_split_define",
"Vale.Math.Poly2.Bits_s.reveal_of_double32",
"Vale.Math.Poly2.Bits_s.reveal_to_quad32",
"Vale.Math.Poly2_s.monomial",
"Vale.Def.Types_s.double32",
"Vale.Arch.Types.quad32_double_hi",
"Vale.Arch.Types.quad32_double_lo",
"Vale.Def.Types_s.quad32",
"Vale.Math.Poly2.Bits_s.to_quad32"
] | [] | true | false | true | false | false | let lemma_quad32_double a =
| let q = to_quad32 a in
let lo = quad32_double_lo q in
let hi = quad32_double_hi q in
let n = monomial 64 in
reveal_to_quad32 a;
reveal_of_double32 lo;
reveal_of_double32 hi;
lemma_split_define a 64;
lemma_add_define_all ();
lemma_reverse_define_all ();
lemma_index_all ();
lemma_equal (of_double32 lo) (a %. n);
lemma_equal (of_double32 hi) (a /. n);
() | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.is_y_sqr_is_y2_vartime | val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y))) | val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y))) | let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 169,
"start_col": 0,
"start_line": 166
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y))) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | y2: Hacl.Impl.P256.Bignum.felem -> y: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Spec.Bignum.Base.unsafe_bool_of_limb",
"Lib.IntTypes.U64",
"Prims.bool",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Hacl.Impl.P256.Field.feq_mask",
"Lib.IntTypes.uint64",
"Prims.unit",
"Hacl.Impl.P256.Field.fsqr"
] | [] | false | true | false | false | false | let is_y_sqr_is_y2_vartime y2 y =
| fsqr y y;
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r | false |
Steel.MonotonicHigherReference.fst | Steel.MonotonicHigherReference.alloc | val alloc (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelT (ref a p) emp (fun r -> pts_to r full_perm v) | val alloc (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelT (ref a p) emp (fun r -> pts_to r full_perm v) | let alloc (#a:Type) (p:Preorder.preorder a) (v:a)
= let h = Current [v] full_perm in
assert (compatible pcm_history h h);
let x : ref a p = alloc h in
intro_pure_full x v h;
x | {
"file_name": "lib/steel/Steel.MonotonicHigherReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 5,
"end_line": 75,
"start_col": 0,
"start_line": 70
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.MonotonicHigherReference
open FStar.Ghost
open FStar.PCM
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.PCMReference
open Steel.FractionalPermission
open Steel.Preorder
module Preorder = FStar.Preorder
module Q = Steel.Preorder
module M = Steel.Memory
module PR = Steel.PCMReference
open FStar.Real
#set-options "--ide_id_info_off"
let ref a p = M.ref (history a p) pcm_history
[@@__reduce__]
let pts_to_body #a #p (r:ref a p) (f:perm) (v:Ghost.erased a) (h:history a p) =
PR.pts_to r h `star`
pure (history_val h v f)
let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:Ghost.erased a) =
h_exists (pts_to_body r f v)
let pts_to_sl r f v = hp_of (pts_to' r f v)
let intro_pure #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelT unit
(PR.pts_to r h)
(fun _ -> pts_to_body r f v h)
= rewrite_slprop (PR.pts_to r h) (pts_to_body _ _ _ _) (fun m ->
emp_unit (M.pts_to r h);
pure_star_interp (M.pts_to r h) (history_val h v f) m)
let intro_pure_full #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelT unit
(PR.pts_to r h)
(fun _ -> pts_to r f v)
= intro_pure #a #p #f r v h;
intro_exists h (pts_to_body r f v) | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.PCMReference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.MonotonicHigherReference.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.PCMReference",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Steel.Preorder",
"short_module": "Q"
},
{
"abbrev": false,
"full_module": "Steel.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.PCMReference",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: FStar.Preorder.preorder a -> v: a -> Steel.Effect.SteelT (Steel.MonotonicHigherReference.ref a p) | Steel.Effect.SteelT | [] | [] | [
"FStar.Preorder.preorder",
"Steel.MonotonicHigherReference.ref",
"Prims.unit",
"Steel.MonotonicHigherReference.intro_pure_full",
"Steel.FractionalPermission.full_perm",
"Steel.PCMReference.alloc",
"Steel.Preorder.history",
"Steel.Preorder.pcm_history",
"Steel.Memory.ref",
"Prims._assert",
"FStar.PCM.compatible",
"Steel.Preorder.Current",
"Prims.Cons",
"Prims.Nil"
] | [] | false | true | false | false | false | let alloc (#a: Type) (p: Preorder.preorder a) (v: a) =
| let h = Current [v] full_perm in
assert (compatible pcm_history h h);
let x:ref a p = alloc h in
intro_pure_full x v h;
x | false |
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_of_to_quad32 | val lemma_of_to_quad32 (a:poly) : Lemma
(requires degree a < 128)
(ensures of_quad32 (to_quad32 a) == a) | val lemma_of_to_quad32 (a:poly) : Lemma
(requires degree a < 128)
(ensures of_quad32 (to_quad32 a) == a) | let lemma_of_to_quad32 a =
reveal_to_quad32 a;
reveal_of_quad32 (to_quad32 a);
lemma_index_all ();
lemma_reverse_define_all ();
lemma_equal a (of_quad32 (to_quad32 a)) | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 173,
"start_col": 0,
"start_line": 168
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
()
#reset-options "--z3rlimit 20"
let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a)
#reset-options
let lemma_quad32_to_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3)
let lemma_quad32_extract_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
lemma_quad32_to_nat32s a;
lemma_poly128_extract_nat32s a0 a1 a2 a3;
()
let lemma_quad32_double a =
let q = to_quad32 a in
let lo = quad32_double_lo q in
let hi = quad32_double_hi q in
let n = monomial 64 in
reveal_to_quad32 a;
reveal_of_double32 lo;
reveal_of_double32 hi;
lemma_split_define a 64;
lemma_add_define_all ();
lemma_reverse_define_all ();
lemma_index_all ();
lemma_equal (of_double32 lo) (a %. n);
lemma_equal (of_double32 hi) (a /. n);
()
let lemma_of_double32_degree (d:double32) =
reveal_of_double32 d
let lemma_of_quad32_degree (q:quad32) =
reveal_of_quad32 q
#reset-options "--z3rlimit 30"
let lemma_to_of_quad32 q =
reveal_of_quad32 q;
reveal_to_quad32 (of_quad32 q);
let a = of_quad32 q in
let Mkfour q0 q1 q2 q3 = q in
let Mkfour q0' q1' q2' q3' = to_quad32 a in
lemma_index a;
lemma_reverse_define_all ();
let s0 = UInt.to_vec #32 q0 in
let s1 = UInt.to_vec #32 q1 in
let s2 = UInt.to_vec #32 q2 in
let s3 = UInt.to_vec #32 q3 in
let s0' = UInt.to_vec #32 q0' in
let s1' = UInt.to_vec #32 q1' in
let s2' = UInt.to_vec #32 q2' in
let s3' = UInt.to_vec #32 q3' in
assert (equal s0 s0');
assert (equal s1 s1');
assert (equal s2 s2');
assert (equal s3 s3');
()
#reset-options | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Math.Poly2_s.poly
-> FStar.Pervasives.Lemma (requires Vale.Math.Poly2_s.degree a < 128)
(ensures Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 a) == a) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.lemma_equal",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Prims.unit",
"Vale.Math.Poly2.Lemmas.lemma_reverse_define_all",
"Vale.Math.Poly2.Lemmas.lemma_index_all",
"Vale.Math.Poly2.Bits_s.reveal_of_quad32",
"Vale.Math.Poly2.Bits_s.reveal_to_quad32"
] | [] | true | false | true | false | false | let lemma_of_to_quad32 a =
| reveal_to_quad32 a;
reveal_of_quad32 (to_quad32 a);
lemma_index_all ();
lemma_reverse_define_all ();
lemma_equal a (of_quad32 (to_quad32 a)) | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.to_proj_point | val to_proj_point: res:point -> p:aff_point -> Stack unit
(requires fun h ->
live h p /\ live h res /\ disjoint p res /\
aff_point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
from_mont_point (as_point_nat h1 res) == S.to_proj_point (as_aff_point_nat h0 p)) | val to_proj_point: res:point -> p:aff_point -> Stack unit
(requires fun h ->
live h p /\ live h res /\ disjoint p res /\
aff_point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
from_mont_point (as_point_nat h1 res) == S.to_proj_point (as_aff_point_nat h0 p)) | let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 131,
"start_col": 0,
"start_line": 119
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame () | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Point.point -> p: Hacl.Impl.P256.Point.aff_point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Impl.P256.Field.make_fone",
"Prims.unit",
"Hacl.Impl.P256.Field.to_mont",
"Hacl.Spec.P256.Montgomery.lemma_to_from_mont_id",
"Hacl.Impl.P256.Bignum.as_nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.getz",
"Hacl.Impl.P256.Point.gety",
"Hacl.Impl.P256.Point.getx",
"Hacl.Impl.P256.Point.aff_gety",
"Hacl.Impl.P256.Point.aff_getx"
] | [] | false | true | false | false | false | let to_proj_point res p =
| let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.aff_point_store | val aff_point_store: res:lbuffer uint8 64ul -> p:aff_point -> Stack unit
(requires fun h ->
live h res /\ live h p /\ disjoint res p /\
aff_point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.aff_point_store (as_aff_point_nat h0 p)) | val aff_point_store: res:lbuffer uint8 64ul -> p:aff_point -> Stack unit
(requires fun h ->
live h res /\ live h p /\ disjoint res p /\
aff_point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.aff_point_store (as_aff_point_nat h0 p)) | let aff_point_store res p =
let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 199,
"start_col": 0,
"start_line": 196
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff
[@CInline]
let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r
/// Point load and store functions | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> p: Hacl.Impl.P256.Point.aff_point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Impl.P256.Bignum.bn2_to_bytes_be4",
"Prims.unit",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.aff_gety",
"Hacl.Impl.P256.Point.aff_getx"
] | [] | false | true | false | false | false | let aff_point_store res p =
| let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py | false |
Hacl.HMAC.fst | Hacl.HMAC.part1 | val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data))) | val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data))) | let part1 a m init update_multi update_last finish s key data len =
let dst = B.sub key 0ul (D.hash_len a) in
part2 a m init update_multi update_last finish s dst key data len | {
"file_name": "code/hmac/Hacl.HMAC.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 383,
"start_col": 0,
"start_line": 381
} | module Hacl.HMAC
module S = FStar.Seq
module D = Hacl.Hash.Definitions
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
module MB = LowStar.Monotonic.Buffer
module C = Hacl.Impl.Blake2.Core
open FStar.HyperStack.ST
open LowStar.BufferOps
open Spec.Hash.Definitions
open Spec.Agile.HMAC
open Spec.Agile.Hash
open Spec.Hash.Incremental
open Spec.Hash.Incremental.Definitions
open Spec.Hash.Lemmas
friend Spec.Agile.HMAC
friend Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
/// Helpers
inline_for_extraction
val xor_bytes_inplace:
a: B.buffer uint8 ->
b: B.buffer uint8 ->
len: UInt32.t {v len = B.length a /\ v len = B.length b} ->
Stack unit
(requires fun h0 -> B.disjoint a b /\ B.live h0 a /\ B.live h0 b)
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer a) h0 h1) /\
B.as_seq h1 a == Spec.Loops.seq_map2 ( ^. ) (B.as_seq h0 a) (B.as_seq h0 b))
inline_for_extraction
let xor_bytes_inplace a b len =
C.Loops.in_place_map2 a b len ( ^. )
/// Agile implementation
// we rely on the output being zero-initialized for the correctness of padding
inline_for_extraction noextract
let wrap_key_st (a: fixed_len_alg) =
output: B.buffer uint8 { B.length output == block_length a } ->
key: B.buffer uint8 {B.length key `less_than_max_input_length` a /\ B.disjoint output key} ->
len: UInt32.t {v len = B.length key} ->
Stack unit
(requires fun h0 ->
B.live h0 output /\ B.live h0 key /\
B.as_seq h0 output == Seq.create (block_length a) (u8 0))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer output) h0 h1) /\
B.as_seq h1 output == wrap a (B.as_seq h0 key))
/// This one is only to avoid a warning about a pattern that is not encoding properly.
inline_for_extraction
let helper_smtpat (a: fixed_len_alg) (len: uint32_t{ v len `less_than_max_input_length` a }):
x:uint32_t { x `FStar.UInt32.lte` D.block_len a } =
if len `FStar.UInt32.lte` D.block_len a then len else D.hash_len a
#set-options "--z3rlimit 40"
inline_for_extraction noextract
let mk_wrap_key (a: fixed_len_alg) (hash: D.hash_st a): wrap_key_st a =
fun output key len ->
[@inline_let] //18-08-02 does *not* prevents unused-but-set-variable warning in C
let i = helper_smtpat a len in
let nkey = B.sub output 0ul i in
let zeroes = B.sub output i (D.block_len a `FStar.UInt32.sub` i) in
LowStar.Ignore.ignore zeroes;
(**) assert B.(loc_disjoint (loc_buffer nkey) (loc_buffer zeroes));
(**) let h0 = ST.get () in
(**) assert (Seq.equal (B.as_seq h0 zeroes) (Seq.create (v (D.block_len a `FStar.UInt32.sub` i)) (u8 0)));
if len `FStar.UInt32.lte` D.block_len a then begin
B.blit key 0ul nkey 0ul len;
let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (B.as_seq h0 key));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end else begin
hash nkey key len;
(**) let h1 = ST.get () in
(**) assert (Seq.equal (B.as_seq h1 zeroes) (B.as_seq h0 zeroes));
(**) assert (Seq.equal (B.as_seq h1 nkey) (Spec.Agile.Hash.hash a (B.as_seq h0 key)));
(**) assert (Seq.equal (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes)));
(**) Seq.lemma_eq_elim (B.as_seq h1 output) (S.append (B.as_seq h1 nkey) (B.as_seq h1 zeroes));
(**) assert (B.as_seq h1 output == wrap a (B.as_seq h0 key))
end
inline_for_extraction noextract
let block_len_as_len (a: fixed_len_alg { not (is_keccak a) }):
Tot (l:len_t a { len_v a l = block_length a })
=
let open FStar.Int.Cast.Full in
assert_norm (128 < pow2 32);
match a with
| MD5 | SHA1 | SHA2_224 | SHA2_256 | Blake2S -> uint32_to_uint64 (D.block_len a)
| SHA2_384 | SHA2_512 | Blake2B -> uint64_to_uint128 (uint32_to_uint64 (D.block_len a))
/// This implementation is optimized by reusing an existing hash state ``s``
/// rather than allocating a new one. Note that the disjointness hypotheses are
/// voluntarily very loose (in particular, the hash state and the key are not
/// necessarily disjoint).
inline_for_extraction noextract
val part2:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
dst: B.buffer uint8 { B.length dst = hash_length a } ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
B.disjoint s dst /\
MB.(all_live h0 [ buf s; buf dst; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer dst)) h0 h1) /\
B.as_seq h1 dst `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data)))
// TODO: move
(* We can't directly introduce uint128 literals *)
inline_for_extraction noextract
let zero_to_len (a:hash_alg) : (if is_keccak a then unit else (x:len_t a { len_v a x == 0 })) =
match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| Blake2S -> UInt64.uint_to_t 0
| SHA2_384 | SHA2_512
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (UInt64.uint_to_t 0)
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
inline_for_extraction noextract
val part2_update_empty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len = 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
let lemma_split_one_block (a:hash_alg) (s:bytes) : Lemma
(requires S.length s == block_length a)
(ensures (key_and_data_fits a; split_blocks a s == (S.empty, s)))
= ()
let part2_update_empty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
update_last s (zero_to_len a) key (D.block_len a);
(**) assert(key_data_v0 `S.equal` key_v0);
(if not (is_blake a) then
(**) Spec.Hash.Lemmas.update_multi_zero a (D.as_seq h0 s)
else
(**) Spec.Hash.Lemmas.update_multi_zero_blake a 0 (D.as_seq h0 s));
(**) lemma_split_one_block a key_v0
inline_for_extraction noextract
let uint32_to_ev (a:hash_alg) (n:UInt32.t{v n % block_length a == 0}) :
ev:D.extra_state a
{if is_blake a then D.ev_v #a ev == v n else True}
= match a with
| MD5 | SHA1
| SHA2_224 | SHA2_256
| SHA2_384 | SHA2_512
| SHA3_224 | SHA3_256 | SHA3_384 | SHA3_512 | Shake128 | Shake256 -> ()
| Blake2S -> FStar.Int.Cast.uint32_to_uint64 n
| Blake2B -> FStar.Int.Cast.Full.uint64_to_uint128 (FStar.Int.Cast.uint32_to_uint64 n)
noextract inline_for_extraction
val len_add32 (a: hash_alg{not (is_keccak a)})
(prev_len: len_t a)
(input_len: UInt32.t { (UInt32.v input_len + len_v a prev_len) `less_than_max_input_length` a }):
x:len_t a { len_v a x = len_v a prev_len + UInt32.v input_len }
noextract inline_for_extraction
let len_add32 a prev_len input_len =
let open FStar.Int.Cast.Full in
match a with
| SHA2_224 | SHA2_256 | MD5 | SHA1 | Blake2S ->
assert_norm (pow2 61 < pow2 64);
FStar.UInt64.(prev_len +^ uint32_to_uint64 input_len)
| SHA2_384 | SHA2_512 | Blake2B ->
assert_norm (pow2 125 < pow2 128);
FStar.UInt128.(prev_len +^ uint64_to_uint128 (uint32_to_uint64 input_len))
inline_for_extraction noextract
val part2_update_nonempty:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
v len > 0 /\
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]))
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_buffer s) h0 h1) /\
(let bs, l = split_blocks a (S.append (B.as_seq h0 key) (B.as_seq h0 data)) in
D.as_seq h1 s `Seq.equal`
Spec.Hash.Incremental.Definitions.update_last a
(Spec.Agile.Hash.update_multi a (D.as_seq h0 s) (init_extra_state a) bs)
(if is_keccak a then () else S.length bs) l))
open FStar.Mul
val split_nb_rem_extend_one_block (l:pos) (d:pos)
: Lemma (
let nb, rem = Lib.UpdateMulti.split_at_last_lazy_nb_rem l (d + l) in
let nb', rem' = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d in
rem == rem' /\ nb == nb' + 1)
let split_nb_rem_extend_one_block l d =
FStar.Math.Lemmas.add_div_mod_1 d l
#push-options "--z3rlimit 400"
let part2_update_nonempty a m init update_multi update_last s key data len =
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) key_and_data_fits a;
let block_len = D.block_len a in
let n_blocks, rem_len = Lib.UpdateMulti.split_at_last_st block_len len in
let full_blocks_len = n_blocks `FStar.UInt32.mul` block_len in
let full_blocks = B.sub data 0ul full_blocks_len in
let rem = B.sub data full_blocks_len rem_len in
(**) assert (S.length key_data_v0 == v len + block_length a);
(**) split_nb_rem_extend_one_block (block_length a) (v len);
(**) assert (let bs, l = split_blocks a key_data_v0 in
bs `S.equal` (key_v0 `S.append` B.as_seq h0 full_blocks) /\
l `S.equal` B.as_seq h0 rem);
[@inline_let]
let ev = if is_blake a then zero_to_len a else () in
(**) assert (D.ev_v ev == init_extra_state a);
(**) assert (B.length key == block_length a * 1);
update_multi s ev key 1ul;
(**) let h1 = ST.get () in
(**) assert (D.as_seq h1 s ==
(**) Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) key_v0));
[@inline_let]
let ev1 = uint32_to_ev a block_len in
update_multi s ev1 full_blocks n_blocks;
(**) let h2 = ST.get () in
(**) let aux () : Lemma (D.as_seq h2 s == Spec.Agile.Hash.(update_multi a (D.as_seq h0 s) (init_extra_state a) (S.append key_v0 (B.as_seq h0 full_blocks))))
(**) = if is_blake a then
(**) update_multi_associative_blake a (D.as_seq h0 s) (init_extra_state a) (v block_len) key_v0 (B.as_seq h0 full_blocks)
(**) else
(**) update_multi_associative a (D.as_seq h0 s) key_v0 (B.as_seq h0 full_blocks)
(**) in
(**) aux ();
[@inline_let]
let prev_len: prev_len:D.prev_len_t a
{ if is_keccak a then True else len_v a prev_len % block_length a = 0 }
=
if is_keccak a then () else
len_add32 a (block_len_as_len a) full_blocks_len
in
update_last s prev_len rem rem_len
#pop-options
inline_for_extraction noextract
let part2 a m init update_multi update_last finish s dst key data len =
(**) key_and_data_fits a;
(**) let h0 = ST.get () in
(**) let key_v0 : Ghost.erased _ = B.as_seq h0 key in
(**) let data_v0 : Ghost.erased _ = B.as_seq h0 data in
(**) let key_data_v0 : Ghost.erased _ = Seq.append key_v0 data_v0 in
(**) let h1 = ST.get () in
(**) assert(B.(modifies (loc_buffer s) h0 h1));
(**) let init_v : Ghost.erased (init_t a) = Spec.Agile.Hash.init a in
(**) assert (D.as_seq h1 s == Ghost.reveal init_v);
if len = 0ul then (
part2_update_empty a m init update_multi update_last s key data len
) else (
part2_update_nonempty a m init update_multi update_last s key data len
);
(**) let h3 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h1 (loc_union (loc_buffer s) (loc_buffer dst)) h3);
finish s dst;
(**) let h4 = ST.get () in
(**) B.(modifies_trans
(loc_union (loc_buffer s) (loc_buffer dst)) h0 h3 (loc_union (loc_buffer s) (loc_buffer dst)) h4);
(**) assert (B.as_seq h4 dst == hash_incremental a key_data_v0 ());
calc (Seq.equal) {
B.as_seq h4 dst;
(Seq.equal) { }
hash_incremental a key_data_v0 ();
(Seq.equal) { hash_is_hash_incremental' a key_data_v0 () }
hash' a key_data_v0 ();
(Seq.equal) { }
hash a key_data_v0;
}
/// This implementation is optimized. First, it reuses an existing hash state
/// ``s`` rather than allocating a new one. Second, it writes out the result of
/// the hash directly in its parameter ``key`` rather than taking a destination
/// output buffer.
inline_for_extraction noextract
val part1:
a: fixed_len_alg ->
m : D.m_spec a ->
init: D.init_st (|a, m|) ->
update_multi: D.update_multi_st (|a, m|) ->
update_last: D.update_last_st (|a, m|) ->
finish: D.finish_st (|a, m|) ->
s: D.state (|a, m|) ->
key: B.buffer uint8 { B.length key = block_length a } ->
data: B.buffer uint8 ->
len: UInt32.t { B.length data = v len } ->
Stack unit
(requires fun h0 ->
B.disjoint s key /\
B.disjoint s data /\
MB.(all_live h0 [ buf s; buf key; buf data ]) /\
D.as_seq h0 s == Spec.Agile.Hash.init a
)
(ensures fun h0 _ h1 ->
key_and_data_fits a;
B.(modifies (loc_union (loc_buffer s) (loc_buffer key)) h0 h1) /\
S.slice (B.as_seq h1 key) 0 (hash_length a) `Seq.equal`
Spec.Agile.Hash.hash a (S.append (B.as_seq h0 key) (B.as_seq h0 data))) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.Definitions.fst.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.HMAC.fst.checked",
"Spec.Agile.Hash.fst.checked",
"Spec.Agile.Hash.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Impl.Blake2.Core.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2s_32.fsti.checked",
"Hacl.Hash.Blake2b_32.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.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.Int.Cast.Full.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.HMAC.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Incremental",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Blake2.Core",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.fixed_len_alg ->
m: Hacl.Hash.Definitions.m_spec a ->
init: Hacl.Hash.Definitions.init_st (| a, m |) ->
update_multi: Hacl.Hash.Definitions.update_multi_st (| a, m |) ->
update_last: Hacl.Hash.Definitions.update_last_st (| a, m |) ->
finish: Hacl.Hash.Definitions.finish_st (| a, m |) ->
s: Hacl.Hash.Definitions.state (| a, m |) ->
key:
LowStar.Buffer.buffer Lib.IntTypes.uint8
{LowStar.Monotonic.Buffer.length key = Spec.Hash.Definitions.block_length a} ->
data: LowStar.Buffer.buffer Lib.IntTypes.uint8 ->
len: FStar.UInt32.t{LowStar.Monotonic.Buffer.length data = Lib.IntTypes.v len}
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Hash.Definitions.fixed_len_alg",
"Hacl.Hash.Definitions.m_spec",
"Hacl.Hash.Definitions.init_st",
"Prims.Mkdtuple2",
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.update_multi_st",
"Hacl.Hash.Definitions.update_last_st",
"Hacl.Hash.Definitions.finish_st",
"Hacl.Hash.Definitions.state",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.block_length",
"FStar.UInt32.t",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.HMAC.part2",
"Prims.unit",
"LowStar.Monotonic.Buffer.mbuffer",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"LowStar.Buffer.sub",
"FStar.UInt32.__uint_to_t",
"FStar.Ghost.hide",
"Hacl.Hash.Definitions.hash_len"
] | [] | false | true | false | false | false | let part1 a m init update_multi update_last finish s key data len =
| let dst = B.sub key 0ul (D.hash_len a) in
part2 a m init update_multi update_last finish s dst key data len | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.recover_y_vartime | val recover_y_vartime (y x:felem) (is_odd:bool) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
(b <==> Some? (S.recover_y (as_nat h0 x) is_odd)) /\
(b ==> (as_nat h1 y < S.prime/\
as_nat h1 y == Some?.v (S.recover_y (as_nat h0 x) is_odd)))) | val recover_y_vartime (y x:felem) (is_odd:bool) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
(b <==> Some? (S.recover_y (as_nat h0 x) is_odd)) /\
(b ==> (as_nat h1 y < S.prime/\
as_nat h1 y == Some?.v (S.recover_y (as_nat h0 x) is_odd)))) | let recover_y_vartime y x is_odd =
let is_y_valid = recover_y_vartime_candidate y x in
if not is_y_valid then false
else begin
let is_y_odd = bn_is_odd4 y in
let is_y_odd = Lib.RawIntTypes.u64_to_UInt64 is_y_odd =. 1uL in
fnegate_conditional_vartime y (is_y_odd <> is_odd);
true end | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 294,
"start_col": 0,
"start_line": 287
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff
[@CInline]
let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r
/// Point load and store functions
[@CInline]
let aff_point_store res p =
let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py
[@CInline]
let point_store res p =
push_frame ();
let aff_p = create_aff_point () in
to_aff_point aff_p p;
aff_point_store res aff_p;
pop_frame ()
inline_for_extraction noextract
val is_xy_valid_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == (aff_point_x_as_nat h0 p < S.prime &&
aff_point_y_as_nat h0 p < S.prime))
let is_xy_valid_vartime p =
let px = aff_getx p in
let py = aff_gety p in
let lessX = bn_is_lt_prime_mask4 px in
let lessY = bn_is_lt_prime_mask4 py in
let res = logand lessX lessY in
logand_lemma lessX lessY;
Hacl.Bignum.Base.unsafe_bool_of_limb res
[@CInline]
let aff_point_load_vartime p b =
let p_x = sub b 0ul 32ul in
let p_y = sub b 32ul 32ul in
let bn_p_x = aff_getx p in
let bn_p_y = aff_gety p in
bn_from_bytes_be4 bn_p_x p_x;
bn_from_bytes_be4 bn_p_y p_y;
let is_xy_valid = is_xy_valid_vartime p in
if not is_xy_valid then false
else is_on_curve_vartime p
[@CInline]
let load_point_vartime p b =
push_frame ();
let p_aff = create_aff_point () in
let res = aff_point_load_vartime p_aff b in
if res then to_proj_point p p_aff;
pop_frame ();
res
inline_for_extraction noextract
val recover_y_vartime_candidate (y x:felem) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\ as_nat h1 y < S.prime /\
(let x = as_nat h0 x in
let y2 = S.(x *% x *% x +% a_coeff *% x +% b_coeff) in
as_nat h1 y == S.fsqrt y2 /\ (b <==> (S.fmul (as_nat h1 y) (as_nat h1 y) == y2))))
let recover_y_vartime_candidate y x =
push_frame ();
let y2M = create_felem () in
let xM = create_felem () in
let yM = create_felem () in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 x);
to_mont xM x;
compute_rp_ec_equation xM y2M; // y2M = x *% x *% x +% S.a_coeff *% x +% S.b_coeff
FI.fsqrt yM y2M; // yM = fsqrt y2M
let h1 = ST.get () in
from_mont y yM;
let is_y_valid = is_y_sqr_is_y2_vartime y2M yM in
pop_frame ();
is_y_valid
inline_for_extraction noextract
val recover_y_vartime (y x:felem) (is_odd:bool) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
(b <==> Some? (S.recover_y (as_nat h0 x) is_odd)) /\
(b ==> (as_nat h1 y < S.prime/\
as_nat h1 y == Some?.v (S.recover_y (as_nat h0 x) is_odd)))) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | y: Hacl.Impl.P256.Bignum.felem -> x: Hacl.Impl.P256.Bignum.felem -> is_odd: Prims.bool
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Prims.bool",
"Prims.op_Negation",
"Prims.unit",
"Hacl.Impl.P256.Field.fnegate_conditional_vartime",
"Prims.op_disEquality",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"FStar.UInt64.__uint_to_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Hacl.Impl.P256.Bignum.bn_is_odd4",
"Lib.IntTypes.uint64",
"Hacl.Impl.P256.Point.recover_y_vartime_candidate"
] | [] | false | true | false | false | false | let recover_y_vartime y x is_odd =
| let is_y_valid = recover_y_vartime_candidate y x in
if not is_y_valid
then false
else
let is_y_odd = bn_is_odd4 y in
let is_y_odd = Lib.RawIntTypes.u64_to_UInt64 is_y_odd =. 1uL in
fnegate_conditional_vartime y (is_y_odd <> is_odd);
true | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.compute_rp_ec_equation | val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff)) | val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff)) | let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 155,
"start_col": 0,
"start_line": 146
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Hacl.Impl.P256.Bignum.felem -> res: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.P256.Field.fadd",
"Hacl.Impl.P256.Constants.make_b_coeff",
"Hacl.Impl.P256.Field.fmul",
"Hacl.Impl.P256.Constants.make_a_coeff",
"Hacl.Impl.P256.Field.fcube",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let compute_rp_ec_equation x res =
| push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame () | false |
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.x1 | val x1 : Prims.int | let x1 = Some?.v (Some 3) | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 25,
"end_line": 23,
"start_col": 0,
"start_line": 23
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_ | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.__proj__Some__item__v",
"Prims.int",
"FStar.Pervasives.Native.Some"
] | [] | false | false | false | true | false | let x1 =
| Some?.v (Some 3) | false |
|
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.aff_point_load_vartime | val aff_point_load_vartime: res:aff_point -> b:lbuffer uint8 64ul -> Stack bool
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
(let ps = S.aff_point_load (as_seq h0 b) in
(r <==> Some? ps) /\ (r ==> (aff_point_inv h1 res /\ as_aff_point_nat h1 res == Some?.v ps)))) | val aff_point_load_vartime: res:aff_point -> b:lbuffer uint8 64ul -> Stack bool
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
(let ps = S.aff_point_load (as_seq h0 b) in
(r <==> Some? ps) /\ (r ==> (aff_point_inv h1 res /\ as_aff_point_nat h1 res == Some?.v ps)))) | let aff_point_load_vartime p b =
let p_x = sub b 0ul 32ul in
let p_y = sub b 32ul 32ul in
let bn_p_x = aff_getx p in
let bn_p_y = aff_gety p in
bn_from_bytes_be4 bn_p_x p_x;
bn_from_bytes_be4 bn_p_y p_y;
let is_xy_valid = is_xy_valid_vartime p in
if not is_xy_valid then false
else is_on_curve_vartime p | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 239,
"start_col": 0,
"start_line": 229
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff
[@CInline]
let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r
/// Point load and store functions
[@CInline]
let aff_point_store res p =
let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py
[@CInline]
let point_store res p =
push_frame ();
let aff_p = create_aff_point () in
to_aff_point aff_p p;
aff_point_store res aff_p;
pop_frame ()
inline_for_extraction noextract
val is_xy_valid_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == (aff_point_x_as_nat h0 p < S.prime &&
aff_point_y_as_nat h0 p < S.prime))
let is_xy_valid_vartime p =
let px = aff_getx p in
let py = aff_gety p in
let lessX = bn_is_lt_prime_mask4 px in
let lessY = bn_is_lt_prime_mask4 py in
let res = logand lessX lessY in
logand_lemma lessX lessY;
Hacl.Bignum.Base.unsafe_bool_of_limb res | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Point.aff_point -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.aff_point",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.op_Negation",
"Prims.bool",
"Hacl.Impl.P256.Point.is_on_curve_vartime",
"Hacl.Impl.P256.Point.is_xy_valid_vartime",
"Prims.unit",
"Hacl.Impl.P256.Bignum.bn_from_bytes_be4",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.aff_gety",
"Hacl.Impl.P256.Point.aff_getx",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub"
] | [] | false | true | false | false | false | let aff_point_load_vartime p b =
| let p_x = sub b 0ul 32ul in
let p_y = sub b 32ul 32ul in
let bn_p_x = aff_getx p in
let bn_p_y = aff_gety p in
bn_from_bytes_be4 bn_p_x p_x;
bn_from_bytes_be4 bn_p_y p_y;
let is_xy_valid = is_xy_valid_vartime p in
if not is_xy_valid then false else is_on_curve_vartime p | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.codes | val codes : Type0 | let codes = va_codes | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 15,
"start_col": 7,
"start_line": 15
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_codes"
] | [] | false | false | false | true | true | let codes =
| va_codes | false |
|
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.test2 | val test2 : b: Prims.bool -> l: Prims.list a -> Prims.int | let test2 #a b (l : list a) =
if b then ()
else assert(not b);
let x = 3 in
let y =
4 +
begin
if b then
let x = 4 in 2 * x
else 8
end
in
x + y | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 75,
"start_col": 0,
"start_line": 63
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_
let x1 = Some?.v (Some 3)
let x2 = 3
let x3 = x1-x2
let simpl_ex1 (x : nat) =
let y = 4 in
let 'x = 7 in
let 'a = 4 in
let 'd = "hello world!" in
let '_u''x = 5 in
let z = 3 in
let w : w:nat{w >= 10} =
if x > 3 then
begin
assert(y + x > 7);
let x' = x + 1 in
assert(y + x' > 8);
let x'' = 2 * (y + x') in
assert(x'' > 16);
assert(x'' >= 10);
2 * x'
end
else 12
in
assert(
x >= 0 /\
y >= 0);
let w' = 2 * w + z in
w'
let test1 b (l : list int) =
if b then
match l with
| [] -> true
| _ -> false
else
match l with
| [x] -> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Prims.bool -> l: Prims.list a -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Prims.list",
"Prims.op_Addition",
"Prims.int",
"FStar.Mul.op_Star",
"Prims.unit",
"Prims._assert",
"Prims.b2t",
"Prims.op_Negation"
] | [] | false | false | false | true | false | let test2 #a b (l: list a) =
| if b then () else assert (not b);
let x = 3 in
let y =
4 +
(if b
then
let x = 4 in
2 * x
else 8)
in
x + y | false |
|
Vale.Math.Poly2.Bits.fst | Vale.Math.Poly2.Bits.lemma_to_of_quad32 | val lemma_to_of_quad32 (q:quad32) : Lemma
(ensures to_quad32 (of_quad32 q) == q)
[SMTPat (to_quad32 (of_quad32 q))] | val lemma_to_of_quad32 (q:quad32) : Lemma
(ensures to_quad32 (of_quad32 q) == q)
[SMTPat (to_quad32 (of_quad32 q))] | let lemma_to_of_quad32 q =
reveal_of_quad32 q;
reveal_to_quad32 (of_quad32 q);
let a = of_quad32 q in
let Mkfour q0 q1 q2 q3 = q in
let Mkfour q0' q1' q2' q3' = to_quad32 a in
lemma_index a;
lemma_reverse_define_all ();
let s0 = UInt.to_vec #32 q0 in
let s1 = UInt.to_vec #32 q1 in
let s2 = UInt.to_vec #32 q2 in
let s3 = UInt.to_vec #32 q3 in
let s0' = UInt.to_vec #32 q0' in
let s1' = UInt.to_vec #32 q1' in
let s2' = UInt.to_vec #32 q2' in
let s3' = UInt.to_vec #32 q3' in
assert (equal s0 s0');
assert (equal s1 s1');
assert (equal s2 s2');
assert (equal s3 s3');
() | {
"file_name": "vale/code/lib/math/Vale.Math.Poly2.Bits.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 165,
"start_col": 0,
"start_line": 145
} | module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative
let lemma_to_of_uint n u =
let a = of_uint n u in
let u' = to_uint n a in
lemma_index a;
lemma_reverse_define_all ();
let s = UInt.to_vec #n u in
let s' = UInt.to_vec #n u' in
assert (equal s s');
()
let rec of_nat x =
if x = 0 then zero
else
let p = shift (of_nat (x / 2)) 1 in
if x % 2 = 0 then p else p +. one
let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
(requires i < n)
(ensures index (to_vec #n 0) i == false)
[SMTPat (index (to_vec #n 0) i)]
=
if i + 1 < n then lemma_of_to_vec_zero i (n - 1)
let lemma_of_uint_zero (n:nat) : Lemma
(ensures of_uint_ n 0 == zero)
=
lemma_bitwise_all ();
lemma_equal (of_uint_ n 0) zero
let rec lemma_of_nat_of_uint n x
=
if n > 0 then
(
lemma_of_nat_of_uint (n - 1) (x / 2);
lemma_bitwise_all ();
lemma_equal (of_nat x) (of_uint n x)
)
let rec lemma_to_nat_rec (len:nat) (p:poly) (c:nat) (n:nat) (i:nat) : Lemma
(requires degree p < len /\ normalize (poly_nat_eq_rec len p c n))
(ensures p.[len - n + i] == (of_nat c).[i])
=
lemma_bitwise_all ();
if (i > 0 && n > 0) then lemma_to_nat_rec len p (c / 2) (n - 1) (i - 1)
let lemma_to_nat len p c =
lemma_bitwise_all ();
let f (i:int) : Lemma (p.[i] == (of_nat c).[i]) =
if 0 <= i then lemma_to_nat_rec len p c len i
in
FStar.Classical.forall_intro f;
lemma_equal p (of_nat c)
let of_nat32 n =
lemma_of_nat_of_uint 32 n;
of_uint 32 n
let lemma_of_nat_of_uint32 (x:nat32) : Lemma
(ensures of_nat32 x == of_nat x)
=
lemma_of_nat_of_uint 32 x
let of_nat32_zero =
lemma_bitwise_all ();
lemma_zero_nth 32;
lemma_equal (of_nat32 0) zero
let of_nat32_ones =
lemma_bitwise_all ();
lemma_to_nat 32 (ones 32) 0xffffffff
let of_nat32_eq a b =
lemma_of_nat_of_uint 32 a;
lemma_of_nat_of_uint 32 b;
lemma_to_of_uint 32 a;
lemma_to_of_uint 32 b;
()
let of_nat32_xor a b =
lemma_bitwise_all ();
lemma_ixor_nth_all 32;
lemma_equal (of_nat32 a +. of_nat32 b) (of_nat32 (ixor a b))
let of_nat32_and a b =
lemma_bitwise_all ();
lemma_iand_nth_all 32;
lemma_equal (poly_and (of_nat32 a) (of_nat32 b)) (of_nat32 (iand a b))
let lemma_poly128_extract_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
lemma_bitwise_all ();
lemma_equal (of_nat32 a0) (mask a 32);
lemma_equal (of_nat32 a1) (mask (shift a (-32)) 32);
lemma_equal (of_nat32 a2) (mask (shift a (-64)) 32);
lemma_equal (of_nat32 a3) (shift a (-96));
()
#reset-options "--z3rlimit 20"
let lemma_quad32_of_nat32s a0 a1 a2 a3 =
let a = poly128_of_nat32s a0 a1 a2 a3 in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_quad32_vec_equal (Mkfour a0 a1 a2 a3) (to_quad32 a)
#reset-options
let lemma_quad32_to_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
reveal_to_quad32 a;
lemma_bitwise_all ();
lemma_equal a (poly128_of_nat32s a0 a1 a2 a3)
let lemma_quad32_extract_nat32s a =
let Mkfour a0 a1 a2 a3 = to_quad32 a in
lemma_quad32_to_nat32s a;
lemma_poly128_extract_nat32s a0 a1 a2 a3;
()
let lemma_quad32_double a =
let q = to_quad32 a in
let lo = quad32_double_lo q in
let hi = quad32_double_hi q in
let n = monomial 64 in
reveal_to_quad32 a;
reveal_of_double32 lo;
reveal_of_double32 hi;
lemma_split_define a 64;
lemma_add_define_all ();
lemma_reverse_define_all ();
lemma_index_all ();
lemma_equal (of_double32 lo) (a %. n);
lemma_equal (of_double32 hi) (a /. n);
()
let lemma_of_double32_degree (d:double32) =
reveal_of_double32 d
let lemma_of_quad32_degree (q:quad32) =
reveal_of_quad32 q | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.TypesNative.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Math.Poly2.Bits.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | q: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(ensures Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2.Bits_s.of_quad32 q) == q)
[SMTPat (Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2.Bits_s.of_quad32 q))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.nat32",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Prims.bool",
"FStar.BitVector.bv_t",
"FStar.UInt.to_vec",
"Vale.Math.Poly2.Lemmas.lemma_reverse_define_all",
"Vale.Math.Poly2.Lemmas.lemma_index",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.Math.Poly2.Bits_s.reveal_to_quad32",
"Vale.Math.Poly2.Bits_s.reveal_of_quad32"
] | [] | false | false | true | false | false | let lemma_to_of_quad32 q =
| reveal_of_quad32 q;
reveal_to_quad32 (of_quad32 q);
let a = of_quad32 q in
let Mkfour q0 q1 q2 q3 = q in
let Mkfour q0' q1' q2' q3' = to_quad32 a in
lemma_index a;
lemma_reverse_define_all ();
let s0 = UInt.to_vec #32 q0 in
let s1 = UInt.to_vec #32 q1 in
let s2 = UInt.to_vec #32 q2 in
let s3 = UInt.to_vec #32 q3 in
let s0' = UInt.to_vec #32 q0' in
let s1' = UInt.to_vec #32 q1' in
let s2' = UInt.to_vec #32 q2' in
let s3' = UInt.to_vec #32 q3' in
assert (equal s0 s0');
assert (equal s1 s1');
assert (equal s2 s2');
assert (equal s3 s3');
() | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.code | val code : Type0 | let code = va_code | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 14,
"start_col": 7,
"start_line": 14
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | true | let code =
| va_code | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.eval | val eval : c: Vale.PPC64LE.Decls.va_code ->
s0: Vale.PPC64LE.Decls.va_state ->
f0: Vale.PPC64LE.Decls.va_fuel ->
sN: Vale.PPC64LE.Decls.va_state
-> Vale.Def.Prop_s.prop0 | let eval = eval_code | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 17,
"start_col": 7,
"start_line": 17
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Vale.PPC64LE.Decls.va_code ->
s0: Vale.PPC64LE.Decls.va_state ->
f0: Vale.PPC64LE.Decls.va_fuel ->
sN: Vale.PPC64LE.Decls.va_state
-> Vale.Def.Prop_s.prop0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.eval_code"
] | [] | false | false | false | true | false | let eval =
| eval_code | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.fuel | val fuel : Type0 | let fuel = va_fuel | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 16,
"start_col": 7,
"start_line": 16
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_fuel"
] | [] | false | false | false | true | true | let fuel =
| va_fuel | false |
|
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.to_aff_point_x | val to_aff_point_x: res:felem -> p:point -> Stack unit
(requires fun h ->
live h p /\ live h res /\ eq_or_disjoint p res /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res == fst (S.to_aff_point (from_mont_point (as_point_nat h0 p)))) | val to_aff_point_x: res:felem -> p:point -> Stack unit
(requires fun h ->
live h p /\ live h res /\ eq_or_disjoint p res /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res == fst (S.to_aff_point (from_mont_point (as_point_nat h0 p)))) | let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 115,
"start_col": 0,
"start_line": 106
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame () | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Bignum.felem -> p: Hacl.Impl.P256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.point",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.P256.Field.from_mont",
"Hacl.Impl.P256.Field.fmul",
"Hacl.Impl.P256.Finv.finv",
"Hacl.Impl.P256.Point.getz",
"Hacl.Impl.P256.Point.getx",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let to_aff_point_x res p =
| push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame () | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.is_on_curve_vartime | val is_on_curve_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p /\ aff_point_inv h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.is_on_curve (as_aff_point_nat h0 p)) | val is_on_curve_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p /\ aff_point_inv h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.is_on_curve (as_aff_point_nat h0 p)) | let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 190,
"start_col": 0,
"start_line": 174
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Hacl.Impl.P256.Point.aff_point -> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.aff_point",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Impl.P256.Point.is_y_sqr_is_y2_vartime",
"Hacl.Impl.P256.Point.compute_rp_ec_equation",
"Hacl.Spec.P256.Montgomery.lemma_to_from_mont_id",
"Hacl.Impl.P256.Bignum.as_nat",
"Hacl.Impl.P256.Field.to_mont",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.aff_gety",
"Hacl.Impl.P256.Point.aff_getx",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let is_on_curve_vartime p =
| push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r | false |
Pulse.Typing.Combinators.fst | Pulse.Typing.Combinators.add_frame | val add_frame (#g:env) (#t:st_term) (#c:comp_st) (t_typing:st_typing g t c)
(#frame:vprop)
(frame_typing:tot_typing g frame tm_vprop)
: t':st_term &
c':comp_st { c' == add_frame c frame } &
st_typing g t' c' | val add_frame (#g:env) (#t:st_term) (#c:comp_st) (t_typing:st_typing g t c)
(#frame:vprop)
(frame_typing:tot_typing g frame tm_vprop)
: t':st_term &
c':comp_st { c' == add_frame c frame } &
st_typing g t' c' | let add_frame (#g:env) (#t:st_term) (#c:comp_st) (t_typing:st_typing g t c)
(#frame:vprop)
(frame_typing:tot_typing g frame tm_vprop)
: t':st_term &
c':comp_st { c' == add_frame c frame } &
st_typing g t' c' =
(| t, add_frame c frame, T_Frame _ _ _ _ frame_typing t_typing |) | {
"file_name": "lib/steel/pulse/Pulse.Typing.Combinators.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 67,
"end_line": 424,
"start_col": 0,
"start_line": 417
} | (*
Copyright 2023 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 Pulse.Typing.Combinators
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
assume
val invert_forall_typing
(#g #u #b #body:_)
(d:tot_typing g (tm_forall_sl u b body) tm_vprop)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
: GTot (
tot_typing g b.binder_ty (tm_type u) &
tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop
)
assume
val construct_forall_typing
(#g #u #b #body:_)
(x:var { None? (lookup g x) /\ ~ (x `Set.mem` freevars body) })
(dt:tot_typing g b.binder_ty (tm_type u))
(db:tot_typing (push_binding g x ppname_default b.binder_ty) (open_term body x) tm_vprop)
: GTot (tot_typing g (tm_forall_sl u b body) tm_vprop)
let rec vprop_equiv_typing (#g:_) (#t0 #t1:term) (v:vprop_equiv g t0 t1)
: GTot ((tot_typing g t0 tm_vprop -> tot_typing g t1 tm_vprop) &
(tot_typing g t1 tm_vprop -> tot_typing g t0 tm_vprop))
(decreases v)
= match v with
| VE_Refl _ _ -> (fun x -> x), (fun x -> x)
| VE_Sym _ _ _ v' ->
let f, g = vprop_equiv_typing v' in
g, f
| VE_Trans g t0 t2 t1 v02 v21 ->
let f02, f20 = vprop_equiv_typing v02 in
let f21, f12 = vprop_equiv_typing v21 in
(fun x -> f21 (f02 x)),
(fun x -> f20 (f12 x))
| VE_Ctxt g s0 s1 s0' s1' v0 v1 ->
let f0, f0' = vprop_equiv_typing v0 in
let f1, f1' = vprop_equiv_typing v1 in
let ff (x:tot_typing g (tm_star s0 s1) tm_vprop)
: tot_typing g (tm_star s0' s1') tm_vprop
= let s0_typing = star_typing_inversion_l x in
let s1_typing = star_typing_inversion_r x in
let s0'_typing, s1'_typing = f0 s0_typing, f1 s1_typing in
star_typing s0'_typing s1'_typing
in
let gg (x:tot_typing g (tm_star s0' s1') tm_vprop)
: tot_typing g (tm_star s0 s1) tm_vprop
= let s0'_typing = star_typing_inversion_l x in
let s1'_typing = star_typing_inversion_r x in
star_typing (f0' s0'_typing) (f1' s1'_typing)
in
ff, gg
| VE_Unit g t ->
let fwd (x:tot_typing g (tm_star tm_emp t) tm_vprop)
: tot_typing g t tm_vprop
= let r = star_typing_inversion_r x in
r
in
let bk (x:tot_typing g t tm_vprop)
: tot_typing g (tm_star tm_emp t) tm_vprop
= star_typing emp_typing x
in
fwd, bk
| VE_Comm g t0 t1 ->
let f t0 t1 (x:tot_typing g (tm_star t0 t1) tm_vprop)
: tot_typing g (tm_star t1 t0) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt1 = star_typing_inversion_r x in
star_typing tt1 tt0
in
f t0 t1, f t1 t0
| VE_Assoc g t0 t1 t2 ->
let fwd (x:tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop)
: tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop
= let tt0 = star_typing_inversion_l x in
let tt12 = star_typing_inversion_r x in
let tt1 = star_typing_inversion_l tt12 in
let tt2 = star_typing_inversion_r tt12 in
star_typing (star_typing tt0 tt1) tt2
in
let bk (x : tot_typing g (tm_star (tm_star t0 t1) t2) tm_vprop)
: tot_typing g (tm_star t0 (tm_star t1 t2)) tm_vprop
= let tt01 = star_typing_inversion_l x in
let tt2 = star_typing_inversion_r x in
let tt0 = star_typing_inversion_l tt01 in
let tt1 = star_typing_inversion_r tt01 in
star_typing tt0 (star_typing tt1 tt2)
in
fwd, bk
| VE_Ext g t0 t1 token ->
let d1, d2 = vprop_eq_typing_inversion g t0 t1 token in
(fun _ -> d2),
(fun _ -> d1)
| VE_Fa g x u b t0 t1 d ->
let d0, d1 = vprop_equiv_typing d in
(fun fa0_typing ->
let b_typing, t0_typing = invert_forall_typing fa0_typing x in
let t1_typing = d0 t0_typing in
construct_forall_typing #g #u x b_typing t1_typing),
(fun fa1_typing ->
let b_typing, t1_typing = invert_forall_typing fa1_typing x in
let t0_typing = d1 t1_typing in
construct_forall_typing #g #u #b #t0 x b_typing t0_typing)
#push-options "--z3rlimit_factor 8 --ifuel 1 --fuel 2 --query_stats"
let bind_t (case_c1 case_c2:comp_st -> bool) =
(g:env) ->
(pre:term) ->
(e1:st_term) ->
(e2:st_term) ->
(c1:comp_st{ case_c1 c1 }) ->
(c2:comp_st{ case_c2 c2 }) ->
(px:nvar { ~ (Set.mem (snd px) (dom g)) }) ->
(d_e1:st_typing g e1 c1) ->
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1))) ->
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2) ->
(res_typing:universe_of g (comp_res c2) (comp_u c2)) ->
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop) ->
(bias_towards_continuation:bool) ->
T.TacH (t:st_term &
c:comp_st { st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True)
let mk_bind_st_st
: bind_t C_ST? C_ST?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
let inames_of (c:comp_st) : term =
match c with
| C_ST _
| C_STGhost _ -> tm_emp_inames
| C_STAtomic inames _ _ -> inames
let with_inames (c:comp_st) (i:term) =
match c with
| C_ST _ -> c
| C_STGhost sc -> C_STGhost sc
| C_STAtomic _ obs sc -> C_STAtomic i obs sc
let weaken_comp_inames (#g:env) (#e:st_term) (#c:comp_st) (d_e:st_typing g e c) (new_inames:term)
: T.Tac (c':comp_st { with_inames c new_inames == c' } &
st_typing g e c')
= match c with
| C_ST _
| C_STGhost _ -> (| c, d_e |)
| C_STAtomic inames obs sc ->
let d_e = T_Sub _ _ _ _ d_e (STS_AtomicInvs _ sc inames new_inames obs obs (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
(| with_inames c new_inames, d_e |)
let st_ghost_as_atomic (c:comp_st { C_STGhost? c }) =
C_STAtomic tm_emp_inames Neutral (st_comp_of_comp c)
let try_lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (option (st_typing g e (st_ghost_as_atomic c)))
= let w = try_get_non_informative_witness g (comp_u c) (comp_res c) in
match w with
| None -> None
| Some w ->
let d = T_Lift _ _ _ _ d (Lift_Ghost_Neutral _ c w) in
Some d
let lift_ghost_atomic (#g:env) (#e:st_term) (#c:comp_st { C_STGhost? c }) (d:st_typing g e c)
: T.Tac (st_typing g e (st_ghost_as_atomic c))
= let w = try_lift_ghost_atomic d in
match w with
| None ->
let open Pulse.PP in
let t = comp_res c in
fail_doc g (Some t.range) [
text "Expected a term with a non-informative (e.g., erased) type; got"
^/^ pp t
]
| Some d ->
d
let mk_bind_ghost_ghost
: bind_t C_STGhost? C_STGhost?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing _ ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
#push-options "--query_stats"
let mk_bind_atomic_atomic
: bind_t C_STAtomic? C_STAtomic?
= fun g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_k ->
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let C_STAtomic inames1 obs1 sc1 = c1 in
let C_STAtomic inames2 obs2 sc2 = c2 in
if at_most_one_observable obs1 obs2
then (
if eq_tm inames1 inames2
then begin
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
end
else if bias_k
then (
let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 inames2 obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let c1 = C_STAtomic inames2 obs1 sc1 in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
)
else begin
let new_inames = tm_join_inames inames1 inames2 in
let d_e1 = T_Sub _ _ _ _ d_e1 (STS_AtomicInvs _ sc1 inames1 new_inames obs1 obs1 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let d_e2 = T_Sub _ _ _ _ d_e2 (STS_AtomicInvs _ sc2 inames2 new_inames obs2 obs2 (check_prop_validity _ _ (tm_inames_subset_typing _ _ _))) in
let c1 = C_STAtomic new_inames obs1 sc1 in
let c2 = C_STAtomic new_inames obs2 sc2 in
let bc = Bind_comp g x c1 c2 res_typing x post_typing in
(| _, _, T_Bind _ e1 e2 _ _ b _ _ d_e1 d_c1res d_e2 bc |)
end
)
else (
T.fail "Should have been handled separately"
)
let rec mk_bind (g:env)
(pre:term)
(e1:st_term)
(e2:st_term)
(c1:comp_st)
(c2:comp_st)
(px:nvar { ~ (Set.mem (snd px) (dom g)) })
(d_e1:st_typing g e1 c1)
(d_c1res:tot_typing g (comp_res c1) (tm_type (comp_u c1)))
(d_e2:st_typing (push_binding g (snd px) (fst px) (comp_res c1)) (open_st_term_nv e2 px) c2)
(res_typing:universe_of g (comp_res c2) (comp_u c2))
(post_typing:tot_typing (push_binding g (snd px) (fst px) (comp_res c2))
(open_term_nv (comp_post c2) px)
tm_vprop)
(bias_towards_continuation:bool)
: T.TacH (t:st_term &
c:comp_st {
st_comp_of_comp c == st_comp_with_pre (st_comp_of_comp c2) pre /\
(bias_towards_continuation ==> effect_annot_of_comp c == effect_annot_of_comp c2) } &
st_typing g t c)
(requires fun _ ->
let _, x = px in
comp_pre c1 == pre /\
None? (lookup g x) /\
(~(x `Set.mem` freevars_st e2)) /\
open_term (comp_post c1) x == comp_pre c2 /\
(~ (x `Set.mem` freevars (comp_post c2))))
(ensures fun _ _ -> True) =
let _, x = px in
let b = nvar_as_binder px (comp_res c1) in
let fail_bias (#a:Type) tag
: T.TacH a (requires fun _ -> True) (ensures fun _ r -> FStar.Tactics.Result.Failed? r)
= let open Pulse.PP in
fail_doc g (Some e1.range)
[text "Cannot compose computations in this " ^/^ text tag ^/^ text " block:";
prefix 4 1 (text "This computation has effect: ") (pp (effect_annot_of_comp c1));
prefix 4 1 (text "The continuation has effect: ") (pp (effect_annot_of_comp c2))]
in
match c1, c2 with
| C_ST _, C_ST _ ->
mk_bind_st_st g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_STGhost _, C_STGhost _ ->
mk_bind_ghost_ghost g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_STAtomic inames1 obs1 sc1, C_STAtomic inames2 obs2 sc2 ->
if at_most_one_observable obs1 obs2
then (
mk_bind_atomic_atomic g pre e1 e2 c1 c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
else if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_STAtomic_ST _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
| C_STAtomic inames _ _, C_ST _ ->
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_STAtomic_ST _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_ST _, C_STAtomic inames _ _ ->
if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e2 = T_Lift _ _ _ _ d_e2 (Lift_STAtomic_ST _ c2) in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
| C_STGhost _, C_STAtomic _ Neutral _ -> (
match try_lift_ghost_atomic d_e1 with
| Some d_e1 ->
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| None ->
if bias_towards_continuation
then fail_bias "atomic"
else (
let d_e2 = T_Lift _ _ _ _ d_e2 (Lift_Neutral_Ghost _ c2) in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
)
| C_STAtomic _ Neutral _, C_STGhost _ -> (
if bias_towards_continuation
then (
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_Neutral_Ghost _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
else (
match try_lift_ghost_atomic d_e2 with
| Some d_e2 ->
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
| None ->
let d_e1 = T_Lift _ _ _ _ d_e1 (Lift_Neutral_Ghost _ c1) in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
)
)
| C_STGhost _, C_ST _
| C_STGhost _, C_STAtomic _ _ _ ->
let d_e1 = lift_ghost_atomic d_e1 in
mk_bind g pre e1 e2 _ c2 px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation
| C_ST _, C_STGhost _
| C_STAtomic _ _ _, C_STGhost _ ->
if bias_towards_continuation
then fail_bias "ghost"
else (
let d_e2 = lift_ghost_atomic d_e2 in
let (| t, c, d |) = mk_bind g pre e1 e2 _ _ px d_e1 d_c1res d_e2 res_typing post_typing bias_towards_continuation in
(| t, c, d |)
)
#pop-options
let bind_res_and_post_typing g c2 x post_hint
= let s2 = st_comp_of_comp c2 in
match post_hint with
| None ->
(* We're inferring a post, so these checks are unavoidable *)
(* since we need to type the result in a smaller env g *)
let (| u, res_typing |) = check_universe g s2.res in
if not (eq_univ u s2.u)
then fail g None "Unexpected universe for result type"
else if x `Set.mem` freevars s2.post
then fail g None (Printf.sprintf "Bound variable %d escapes scope in postcondition %s" x (P.term_to_string s2.post))
else (
let y = x in //fresh g in
let s2_post_opened = open_term_nv s2.post (v_as_nv y) in
let post_typing =
check_vprop_with_core (push_binding g y ppname_default s2.res) s2_post_opened in
res_typing, post_typing
)
| Some post ->
if x `Set.mem` freevars s2.post
then fail g None "Unexpected mismatched postcondition in bind" //exclude with a stronger type on check'
else (
let pr = post_hint_typing g post x in
pr.ty_typing, pr.post_typing
) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Result.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Typing.Combinators.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t_typing: Pulse.Typing.st_typing g t c ->
frame_typing: Pulse.Typing.tot_typing g frame Pulse.Syntax.Base.tm_vprop
-> FStar.Pervasives.dtuple3 Pulse.Syntax.Base.st_term
(fun _ -> c': Pulse.Syntax.Base.comp_st{c' == Pulse.Typing.add_frame c frame})
(fun t' c' -> Pulse.Typing.st_typing g t' c') | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp_st",
"Pulse.Typing.st_typing",
"Pulse.Syntax.Base.vprop",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"FStar.Pervasives.Mkdtuple3",
"Prims.eq2",
"Pulse.Typing.add_frame",
"Pulse.Typing.T_Frame",
"FStar.Pervasives.dtuple3"
] | [] | false | false | false | false | false | let add_frame
(#g: env)
(#t: st_term)
(#c: comp_st)
(t_typing: st_typing g t c)
(#frame: vprop)
(frame_typing: tot_typing g frame tm_vprop)
: t': st_term & c': comp_st{c' == add_frame c frame} & st_typing g t' c' =
| (| t, add_frame c frame, T_Frame _ _ _ _ frame_typing t_typing |) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.if_code | val if_code (b: bool) (c1 c2: code) : code | val if_code (b: bool) (c1 c2: code) : code | let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 50,
"start_col": 0,
"start_line": 50
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Prims.bool -> c1: Vale.PPC64LE.QuickCodes.code -> c2: Vale.PPC64LE.QuickCodes.code
-> Vale.PPC64LE.QuickCodes.code | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Vale.PPC64LE.QuickCodes.code"
] | [] | false | false | false | true | false | let if_code (b: bool) (c1 c2: code) : code =
| if b then c1 else c2 | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.labeled_wrap | val labeled_wrap (r: range) (msg: string) (p: Type0) : GTot Type0 | val labeled_wrap (r: range) (msg: string) (p: Type0) : GTot Type0 | let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 80,
"end_line": 20,
"start_col": 0,
"start_line": 20
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: FStar.Range.range -> msg: Prims.string -> p: Type0 -> Prims.GTot Type0 | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Range.range",
"Prims.string",
"FStar.Range.labeled"
] | [] | false | false | false | false | true | let labeled_wrap (r: range) (msg: string) (p: Type0) : GTot Type0 =
| labeled r msg p | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.point_store | val point_store: res:lbuffer uint8 64ul -> p:point -> Stack unit
(requires fun h ->
live h res /\ live h p /\ disjoint res p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.point_store (from_mont_point (as_point_nat h0 p))) | val point_store: res:lbuffer uint8 64ul -> p:point -> Stack unit
(requires fun h ->
live h res /\ live h p /\ disjoint res p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.point_store (from_mont_point (as_point_nat h0 p))) | let point_store res p =
push_frame ();
let aff_p = create_aff_point () in
to_aff_point aff_p p;
aff_point_store res aff_p;
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 208,
"start_col": 0,
"start_line": 203
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff
[@CInline]
let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r
/// Point load and store functions
[@CInline]
let aff_point_store res p =
let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> p: Hacl.Impl.P256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.P256.Point.point",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.P256.Point.aff_point_store",
"Hacl.Impl.P256.Point.to_aff_point",
"Hacl.Impl.P256.Point.aff_point",
"Hacl.Impl.P256.Point.create_aff_point",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let point_store res p =
| push_frame ();
let aff_p = create_aff_point () in
to_aff_point aff_p p;
aff_point_store res aff_p;
pop_frame () | false |
Hacl.Impl.P256.Point.fst | Hacl.Impl.P256.Point.aff_point_decompress_vartime | val aff_point_decompress_vartime (x y:felem) (s:lbuffer uint8 33ul) : Stack bool
(requires fun h ->
live h x /\ live h y /\ live h s /\
disjoint x y /\ disjoint x s /\ disjoint y s)
(ensures fun h0 b h1 -> modifies (loc x |+| loc y) h0 h1 /\
(b <==> Some? (S.aff_point_decompress (as_seq h0 s))) /\
(b ==> (let (xa, ya) = Some?.v (S.aff_point_decompress (as_seq h0 s)) in
as_nat h1 x < S.prime /\ as_nat h1 y < S.prime /\ as_nat h1 x == xa /\ as_nat h1 y == ya))) | val aff_point_decompress_vartime (x y:felem) (s:lbuffer uint8 33ul) : Stack bool
(requires fun h ->
live h x /\ live h y /\ live h s /\
disjoint x y /\ disjoint x s /\ disjoint y s)
(ensures fun h0 b h1 -> modifies (loc x |+| loc y) h0 h1 /\
(b <==> Some? (S.aff_point_decompress (as_seq h0 s))) /\
(b ==> (let (xa, ya) = Some?.v (S.aff_point_decompress (as_seq h0 s)) in
as_nat h1 x < S.prime /\ as_nat h1 y < S.prime /\ as_nat h1 x == xa /\ as_nat h1 y == ya))) | let aff_point_decompress_vartime x y s =
let s0 = s.(0ul) in
let s0 = Lib.RawIntTypes.u8_to_UInt8 s0 in
if not (s0 = 0x02uy || s0 = 0x03uy) then false
else begin
let xb = sub s 1ul 32ul in
bn_from_bytes_be4 x xb;
let is_x_valid = bn_is_lt_prime_mask4 x in
let is_x_valid = Hacl.Bignum.Base.unsafe_bool_of_limb is_x_valid in
let is_y_odd = s0 = 0x03uy in
if not is_x_valid then false
else recover_y_vartime y x is_y_odd end | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Point.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 310,
"start_col": 0,
"start_line": 298
} | module Hacl.Impl.P256.Point
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module FI = Hacl.Impl.P256.Finv
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create a point
let create_aff_point () =
create 8ul (u64 0)
let create_point () =
create 12ul (u64 0)
[@CInline]
let make_base_point p =
let x = getx p in
let y = gety p in
let z = getz p in
make_g_x x;
make_g_y y;
make_fone z
[@CInline]
let make_point_at_inf p =
let x = getx p in
let y = gety p in
let z = getz p in
make_fzero x;
make_fone y;
make_fzero z
/// Check if a point is a point-at-infinity
(* https://crypto.stackexchange.com/questions/43869/point-at-infinity-and-error-handling*)
val lemma_mont_is_point_at_inf: p:S.proj_point{let (_, _, z) = p in z < S.prime} ->
Lemma (S.is_point_at_inf p == S.is_point_at_inf (from_mont_point p))
let lemma_mont_is_point_at_inf p =
let px, py, pz = p in
SM.lemma_from_mont_zero pz
[@CInline]
let is_point_at_inf p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_mask4 pz
[@CInline]
let is_point_at_inf_vartime p =
let h0 = ST.get () in
lemma_mont_is_point_at_inf (as_point_nat h0 p);
let pz = getz p in
bn_is_zero_vartime4 pz
/// Create a copy of a point
let copy_point res p =
copy res p
/// Point conversion between Projective and Affine coordinates representations
[@CInline]
let to_aff_point res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let py = gety p in
let pz = getz p in
let x = aff_getx res in
let y = aff_gety res in
FI.finv zinv pz;
fmul x px zinv;
fmul y py zinv;
from_mont x x;
from_mont y y;
pop_frame ()
[@CInline]
let to_aff_point_x res p =
push_frame ();
let zinv = create_felem () in
let px = getx p in
let pz = getz p in
FI.finv zinv pz;
fmul res px zinv;
from_mont res res;
pop_frame ()
[@CInline]
let to_proj_point res p =
let px = aff_getx p in
let py = aff_gety p in
let rx = getx res in
let ry = gety res in
let rz = getz res in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
to_mont rx px;
to_mont ry py;
make_fone rz
/// Check if a point is on the curve
inline_for_extraction noextract
val compute_rp_ec_equation: x:felem -> res:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
as_nat h x < S.prime)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_nat h1 res < S.prime /\
(let x = fmont_as_nat h0 x in
fmont_as_nat h1 res ==
S.fadd (S.fadd (S.fmul (S.fmul x x) x) (S.fmul S.a_coeff x)) S.b_coeff))
let compute_rp_ec_equation x res =
push_frame ();
let tmp = create_felem () in
fcube res x;
make_a_coeff tmp;
fmul tmp tmp x;
fadd res tmp res;
make_b_coeff tmp;
fadd res tmp res;
pop_frame ()
inline_for_extraction noextract
val is_y_sqr_is_y2_vartime (y2 y:felem) : Stack bool
(requires fun h ->
live h y /\ live h y2 /\ disjoint y y2 /\
as_nat h y2 < S.prime /\ as_nat h y < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
b == (fmont_as_nat h0 y2 = S.fmul (fmont_as_nat h0 y) (fmont_as_nat h0 y)))
let is_y_sqr_is_y2_vartime y2 y =
fsqr y y; // y = y * y
let r = feq_mask y y2 in
Hacl.Bignum.Base.unsafe_bool_of_limb r
// y *% y =?= x *% x *% x +% a_coeff *% x +% b_coeff
[@CInline]
let is_on_curve_vartime p =
push_frame ();
let rp = create_felem () in
let tx = create_felem () in
let ty = create_felem () in
let px = aff_getx p in
let py = aff_gety p in
let h0 = ST.get () in
to_mont tx px;
to_mont ty py;
SM.lemma_to_from_mont_id (as_nat h0 px);
SM.lemma_to_from_mont_id (as_nat h0 py);
compute_rp_ec_equation tx rp;
let r = is_y_sqr_is_y2_vartime rp ty in
pop_frame ();
r
/// Point load and store functions
[@CInline]
let aff_point_store res p =
let px = aff_getx p in
let py = aff_gety p in
bn2_to_bytes_be4 res px py
[@CInline]
let point_store res p =
push_frame ();
let aff_p = create_aff_point () in
to_aff_point aff_p p;
aff_point_store res aff_p;
pop_frame ()
inline_for_extraction noextract
val is_xy_valid_vartime: p:aff_point -> Stack bool
(requires fun h -> live h p)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == (aff_point_x_as_nat h0 p < S.prime &&
aff_point_y_as_nat h0 p < S.prime))
let is_xy_valid_vartime p =
let px = aff_getx p in
let py = aff_gety p in
let lessX = bn_is_lt_prime_mask4 px in
let lessY = bn_is_lt_prime_mask4 py in
let res = logand lessX lessY in
logand_lemma lessX lessY;
Hacl.Bignum.Base.unsafe_bool_of_limb res
[@CInline]
let aff_point_load_vartime p b =
let p_x = sub b 0ul 32ul in
let p_y = sub b 32ul 32ul in
let bn_p_x = aff_getx p in
let bn_p_y = aff_gety p in
bn_from_bytes_be4 bn_p_x p_x;
bn_from_bytes_be4 bn_p_y p_y;
let is_xy_valid = is_xy_valid_vartime p in
if not is_xy_valid then false
else is_on_curve_vartime p
[@CInline]
let load_point_vartime p b =
push_frame ();
let p_aff = create_aff_point () in
let res = aff_point_load_vartime p_aff b in
if res then to_proj_point p p_aff;
pop_frame ();
res
inline_for_extraction noextract
val recover_y_vartime_candidate (y x:felem) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\ as_nat h1 y < S.prime /\
(let x = as_nat h0 x in
let y2 = S.(x *% x *% x +% a_coeff *% x +% b_coeff) in
as_nat h1 y == S.fsqrt y2 /\ (b <==> (S.fmul (as_nat h1 y) (as_nat h1 y) == y2))))
let recover_y_vartime_candidate y x =
push_frame ();
let y2M = create_felem () in
let xM = create_felem () in
let yM = create_felem () in
let h0 = ST.get () in
SM.lemma_to_from_mont_id (as_nat h0 x);
to_mont xM x;
compute_rp_ec_equation xM y2M; // y2M = x *% x *% x +% S.a_coeff *% x +% S.b_coeff
FI.fsqrt yM y2M; // yM = fsqrt y2M
let h1 = ST.get () in
from_mont y yM;
let is_y_valid = is_y_sqr_is_y2_vartime y2M yM in
pop_frame ();
is_y_valid
inline_for_extraction noextract
val recover_y_vartime (y x:felem) (is_odd:bool) : Stack bool
(requires fun h ->
live h x /\ live h y /\ disjoint x y /\ as_nat h x < S.prime)
(ensures fun h0 b h1 -> modifies (loc y) h0 h1 /\
(b <==> Some? (S.recover_y (as_nat h0 x) is_odd)) /\
(b ==> (as_nat h1 y < S.prime/\
as_nat h1 y == Some?.v (S.recover_y (as_nat h0 x) is_odd))))
let recover_y_vartime y x is_odd =
let is_y_valid = recover_y_vartime_candidate y x in
if not is_y_valid then false
else begin
let is_y_odd = bn_is_odd4 y in
let is_y_odd = Lib.RawIntTypes.u64_to_UInt64 is_y_odd =. 1uL in
fnegate_conditional_vartime y (is_y_odd <> is_odd);
true end | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Finv.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Point.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Finv",
"short_module": "FI"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: Hacl.Impl.P256.Bignum.felem ->
y: Hacl.Impl.P256.Bignum.felem ->
s: Lib.Buffer.lbuffer Lib.IntTypes.uint8 33ul
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.op_Negation",
"Prims.op_BarBar",
"Prims.op_Equality",
"FStar.UInt8.t",
"FStar.UInt8.__uint_to_t",
"Prims.bool",
"Hacl.Impl.P256.Point.recover_y_vartime",
"Prims.l_iff",
"Prims.b2t",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.U64",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Lib.IntTypes.ones",
"Hacl.Spec.Bignum.Base.unsafe_bool_of_limb",
"Lib.IntTypes.int_t",
"Hacl.Impl.P256.Field.bn_is_lt_prime_mask4",
"Lib.IntTypes.uint64",
"Prims.unit",
"Hacl.Impl.P256.Bignum.bn_from_bytes_be4",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.v",
"Lib.RawIntTypes.u8_to_UInt8",
"Lib.Buffer.op_Array_Access"
] | [] | false | true | false | false | false | let aff_point_decompress_vartime x y s =
| let s0 = s.(0ul) in
let s0 = Lib.RawIntTypes.u8_to_UInt8 s0 in
if not (s0 = 0x02uy || s0 = 0x03uy)
then false
else
let xb = sub s 1ul 32ul in
bn_from_bytes_be4 x xb;
let is_x_valid = bn_is_lt_prime_mask4 x in
let is_x_valid = Hacl.Bignum.Base.unsafe_bool_of_limb is_x_valid in
let is_y_odd = s0 = 0x03uy in
if not is_x_valid then false else recover_y_vartime y x is_y_odd | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.precedes_wrap | val precedes_wrap (#a: Type) (x y: a) : GTot Type0 | val precedes_wrap (#a: Type) (x y: a) : GTot Type0 | let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 35,
"start_col": 0,
"start_line": 35
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)] | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> y: a -> Prims.GTot Type0 | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.precedes"
] | [] | false | false | false | false | true | let precedes_wrap (#a: Type) (x y: a) : GTot Type0 =
| precedes x y | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_QEmpty | val va_QEmpty (#a: Type0) (v: a) : quickCodes a [] | val va_QEmpty (#a: Type0) (v: a) : quickCodes a [] | let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 73,
"start_col": 19,
"start_line": 73
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: a -> Vale.PPC64LE.QuickCodes.quickCodes a [] | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp"
] | [] | false | false | false | true | false | let va_QEmpty (#a: Type0) (v: a) : quickCodes a [] =
| QEmpty v | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_Seq_t | val wp_Seq_t : a: Type0 -> Type | let wp_Seq_t (a:Type0) = va_state -> a -> Type0 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 99,
"start_col": 0,
"start_line": 99
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type0 -> Type | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_state"
] | [] | false | false | false | true | true | let wp_Seq_t (a: Type0) =
| va_state -> a -> Type0 | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_proc | val wp_proc (#a: Type0) (c: code) (qc: quickCode a c) (s0: va_state) (k: (va_state -> a -> Type0))
: Type0 | val wp_proc (#a: Type0) (c: code) (qc: quickCode a c) (s0: va_state) (k: (va_state -> a -> Type0))
: Type0 | let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 97,
"start_col": 0,
"start_line": 95
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Vale.PPC64LE.QuickCodes.code ->
qc: Vale.PPC64LE.QuickCode.quickCode a c ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.QuickCode.quickProc_wp",
"Vale.PPC64LE.QuickCode.t_proof"
] | [] | false | false | false | false | true | let wp_proc (#a: Type0) (c: code) (qc: quickCode a c) (s0: va_state) (k: (va_state -> a -> Type0))
: Type0 =
| match qc with | QProc _ _ wp _ -> wp s0 k | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_QSeq | val va_QSeq
(#a: Type0)
(#b: Type)
(#c: code)
(#cs: codes)
(r: range)
(msg: string)
(qc: quickCode b c)
(qcs: quickCodes a cs)
: quickCodes a (c :: cs) | val va_QSeq
(#a: Type0)
(#b: Type)
(#c: code)
(#cs: codes)
(r: range)
(msg: string)
(qc: quickCode b c)
(qcs: quickCodes a cs)
: quickCodes a (c :: cs) | let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 180,
"end_line": 75,
"start_col": 19,
"start_line": 75
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Range.range ->
msg: Prims.string ->
qc: Vale.PPC64LE.QuickCode.quickCode b c ->
qcs: Vale.PPC64LE.QuickCodes.quickCodes a cs
-> Vale.PPC64LE.QuickCodes.quickCodes a (c :: cs) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCodes.codes",
"FStar.Range.range",
"Prims.string",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCodes.QSeq",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | false | false | let va_QSeq
(#a: Type0)
(#b: Type)
(#c: code)
(#cs: codes)
(r: range)
(msg: string)
(qc: quickCode b c)
(qcs: quickCodes a cs)
: quickCodes a (c :: cs) =
| QSeq r msg qc qcs | false |
Steel.MonotonicHigherReference.fst | Steel.MonotonicHigherReference.elim_pure | val elim_pure (#a #uses #p #f: _) (r: ref a p) (v: Ghost.erased a) (h: Ghost.erased (history a p))
: SteelGhostT (_: unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> PR.pts_to r h) | val elim_pure (#a #uses #p #f: _) (r: ref a p) (v: Ghost.erased a) (h: Ghost.erased (history a p))
: SteelGhostT (_: unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> PR.pts_to r h) | let elim_pure #a #uses #p #f
(r:ref a p)
(v:Ghost.erased a)
(h:Ghost.erased (history a p))
: SteelGhostT (_:unit{history_val h v f})
uses
(pts_to_body r f v h)
(fun _ -> PR.pts_to r h)
= let _ = extract_pure r v h in
drop (pure (history_val h v f)) | {
"file_name": "lib/steel/Steel.MonotonicHigherReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 35,
"end_line": 104,
"start_col": 0,
"start_line": 95
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.MonotonicHigherReference
open FStar.Ghost
open FStar.PCM
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.PCMReference
open Steel.FractionalPermission
open Steel.Preorder
module Preorder = FStar.Preorder
module Q = Steel.Preorder
module M = Steel.Memory
module PR = Steel.PCMReference
open FStar.Real
#set-options "--ide_id_info_off"
let ref a p = M.ref (history a p) pcm_history
[@@__reduce__]
let pts_to_body #a #p (r:ref a p) (f:perm) (v:Ghost.erased a) (h:history a p) =
PR.pts_to r h `star`
pure (history_val h v f)
let pts_to' (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:Ghost.erased a) =
h_exists (pts_to_body r f v)
let pts_to_sl r f v = hp_of (pts_to' r f v)
let intro_pure #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelT unit
(PR.pts_to r h)
(fun _ -> pts_to_body r f v h)
= rewrite_slprop (PR.pts_to r h) (pts_to_body _ _ _ _) (fun m ->
emp_unit (M.pts_to r h);
pure_star_interp (M.pts_to r h) (history_val h v f) m)
let intro_pure_full #a #p #f
(r:ref a p)
(v:a)
(h:history a p { history_val h v f })
: SteelT unit
(PR.pts_to r h)
(fun _ -> pts_to r f v)
= intro_pure #a #p #f r v h;
intro_exists h (pts_to_body r f v)
let alloc (#a:Type) (p:Preorder.preorder a) (v:a)
= let h = Current [v] full_perm in
assert (compatible pcm_history h h);
let x : ref a p = alloc h in
intro_pure_full x v h;
x
let extract_pure #a #uses #p #f
(r:ref a p)
(v:Ghost.erased a)
(h:Ghost.erased (history a p))
: SteelGhostT (_:unit{history_val h v f})
uses
(pts_to_body r f v h)
(fun _ -> pts_to_body r f v h)
= rewrite_slprop
(pts_to_body r f v h)
(PR.pts_to r h `star` pure (history_val h v f))
(fun _ -> ());
elim_pure (history_val h v f);
rewrite_slprop (PR.pts_to r h) (pts_to_body r f v h) (fun m ->
emp_unit (M.pts_to r h);
pure_star_interp (M.pts_to r h) (history_val h v f) m
) | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.PCMReference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.MonotonicHigherReference.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": true,
"full_module": "Steel.PCMReference",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Steel.Preorder",
"short_module": "Q"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.PCMReference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: Steel.MonotonicHigherReference.ref a p ->
v: FStar.Ghost.erased a ->
h: FStar.Ghost.erased (Steel.Preorder.history a p)
-> Steel.Effect.Atomic.SteelGhostT
(_: Prims.unit{Steel.Preorder.history_val (FStar.Ghost.reveal h) v f}) | Steel.Effect.Atomic.SteelGhostT | [] | [] | [
"Steel.Memory.inames",
"FStar.Preorder.preorder",
"Steel.FractionalPermission.perm",
"Steel.MonotonicHigherReference.ref",
"FStar.Ghost.erased",
"Steel.Preorder.history",
"Steel.Effect.Atomic.drop",
"Steel.Effect.Common.pure",
"Steel.Preorder.history_val",
"FStar.Ghost.reveal",
"Prims.unit",
"Steel.MonotonicHigherReference.extract_pure",
"Steel.MonotonicHigherReference.pts_to_body",
"Steel.PCMReference.pts_to",
"Steel.Preorder.pcm_history",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let elim_pure #a #uses #p #f (r: ref a p) (v: Ghost.erased a) (h: Ghost.erased (history a p))
: SteelGhostT (_: unit{history_val h v f}) uses (pts_to_body r f v h) (fun _ -> PR.pts_to r h) =
| let _ = extract_pure r v h in
drop (pure (history_val h v f)) | false |
FStar.InteractiveHelpers.ParseTest.fst | FStar.InteractiveHelpers.ParseTest.simpl_ex1 | val simpl_ex1 : x: Prims.nat -> Prims.int | let simpl_ex1 (x : nat) =
let y = 4 in
let 'x = 7 in
let 'a = 4 in
let 'd = "hello world!" in
let '_u''x = 5 in
let z = 3 in
let w : w:nat{w >= 10} =
if x > 3 then
begin
assert(y + x > 7);
let x' = x + 1 in
assert(y + x' > 8);
let x'' = 2 * (y + x') in
assert(x'' > 16);
assert(x'' >= 10);
2 * x'
end
else 12
in
assert(
x >= 0 /\
y >= 0);
let w' = 2 * w + z in
w' | {
"file_name": "examples/interactive/FStar.InteractiveHelpers.ParseTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 51,
"start_col": 0,
"start_line": 27
} | module FStar.InteractiveHelpers.ParseTest
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.List
open FStar.Tactics.V2
open FStar.Mul
open FStar.InteractiveHelpers
open FStar.InteractiveHelpers.Tutorial.Definitions
/// This file contains some functions "interesting to parse", to test the parser
/// for the F* extended mode. It is for development/debugging purpose only.
#push-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(*** Tests *)
let a'_ = 3
let f = a'_
let x1 = Some?.v (Some 3)
let x2 = 3
let x3 = x1-x2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Tutorial.Definitions.fst.checked",
"FStar.InteractiveHelpers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.ParseTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Tutorial.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Prims.nat -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.unit",
"Prims._assert",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_GreaterThan",
"Prims.bool",
"Prims.string"
] | [] | false | false | false | true | false | let simpl_ex1 (x: nat) =
| let y = 4 in
let 'x = 7 in
let 'a = 4 in
let 'd = "hello world!" in
let '_u''x = 5 in
let z = 3 in
let w:w: nat{w >= 10} =
if x > 3
then
(assert (y + x > 7);
let x' = x + 1 in
assert (y + x' > 8);
let x'' = 2 * (y + x') in
assert (x'' > 16);
assert (x'' >= 10);
2 * x')
else 12
in
assert (x >= 0 /\ y >= 0);
let w' = 2 * w + z in
w' | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.k_AssertBy | val k_AssertBy : p: Type0 -> _: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0 | let k_AssertBy (p:Type0) (_:va_state) () = p | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 44,
"end_line": 101,
"start_col": 0,
"start_line": 101
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0 | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Type0 -> _: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_state",
"Prims.unit"
] | [] | false | false | false | true | true | let k_AssertBy (p: Type0) (_: va_state) () =
| p | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_Bind_t | val wp_Bind_t : a: Type0 -> Type | let wp_Bind_t (a:Type0) = va_state -> a -> Type0 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 100,
"start_col": 0,
"start_line": 100
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type0 -> Type | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_state"
] | [] | false | false | false | true | true | let wp_Bind_t (a: Type0) =
| va_state -> a -> Type0 | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_range1 | val va_range1 : FStar.Range.range | let va_range1 = mk_range "" 0 0 0 0 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 104,
"start_col": 0,
"start_line": 104
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Range.range | Prims.Tot | [
"total"
] | [] | [
"FStar.Range.mk_range"
] | [] | false | false | false | true | false | let va_range1 =
| mk_range "" 0 0 0 0 | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.va_QBind | val va_QBind
(#a: Type0)
(#b: Type)
(#c: code)
(#cs: codes)
(r: range)
(msg: string)
(qc: quickCode b c)
(qcs: (va_state -> b -> GTot (quickCodes a cs)))
: quickCodes a (c :: cs) | val va_QBind
(#a: Type0)
(#b: Type)
(#c: code)
(#cs: codes)
(r: range)
(msg: string)
(qc: quickCode b c)
(qcs: (va_state -> b -> GTot (quickCodes a cs)))
: quickCodes a (c :: cs) | let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 206,
"end_line": 72,
"start_col": 19,
"start_line": 72
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Range.range ->
msg: Prims.string ->
qc: Vale.PPC64LE.QuickCode.quickCode b c ->
qcs:
(_: Vale.PPC64LE.Decls.va_state -> _: b
-> Prims.GTot (Vale.PPC64LE.QuickCodes.quickCodes a cs))
-> Vale.PPC64LE.QuickCodes.quickCodes a (c :: cs) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCodes.codes",
"FStar.Range.range",
"Prims.string",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCodes.QBind",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | false | false | let va_QBind
(#a: Type0)
(#b: Type)
(#c: code)
(#cs: codes)
(r: range)
(msg: string)
(qc: quickCode b c)
(qcs: (va_state -> b -> GTot (quickCodes a cs)))
: quickCodes a (c :: cs) =
| QBind r msg qc qcs | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_block | val wp_block
(#a: Type)
(#cs: codes)
(qcs: (va_state -> GTot (quickCodes a cs)))
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 | val wp_block
(#a: Type)
(#cs: codes)
(qcs: (va_state -> GTot (quickCodes a cs)))
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 | let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 174,
"start_col": 0,
"start_line": 173
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
qcs: (_: Vale.PPC64LE.Decls.va_state -> Prims.GTot (Vale.PPC64LE.QuickCodes.quickCodes a cs)) ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.codes",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.QuickCodes.wp"
] | [] | false | false | false | false | true | let wp_block
(#a: Type)
(#cs: codes)
(qcs: (va_state -> GTot (quickCodes a cs)))
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 =
| wp cs (qcs s0) mods k s0 | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.block | val block : block: Vale.PPC64LE.Decls.va_codes -> Vale.PPC64LE.Decls.va_code | let block = va_Block | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 170,
"start_col": 7,
"start_line": 170
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | block: Vale.PPC64LE.Decls.va_codes -> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_Block"
] | [] | false | false | false | true | false | let block =
| va_Block | false |
|
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_InlineIf | val wp_InlineIf
(#a: Type)
(#c1 #c2: code)
(b: bool)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 | val wp_InlineIf
(#a: Type)
(#c1 #c2: code)
(b: bool)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 | let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 193,
"start_col": 0,
"start_line": 190
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: Prims.bool ->
qc1: Vale.PPC64LE.QuickCode.quickCode a c1 ->
qc2: Vale.PPC64LE.QuickCode.quickCode a c2 ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Prims.bool",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Prims.l_and",
"Prims.l_imp",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.mods_contains",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__wp",
"Prims.op_Negation"
] | [] | false | false | false | false | true | let wp_InlineIf
(#a: Type)
(#c1 #c2: code)
(b: bool)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 =
| (b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_While_body | val wp_While_body
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g1: a)
(s1: va_state)
(k: (va_state -> a -> Type0))
: Type0 | val wp_While_body
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g1: a)
(s1: va_state)
(k: (va_state -> a -> Type0))
: Type0 | let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1)) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 280,
"start_col": 0,
"start_line": 273
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1 | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: Vale.PPC64LE.QuickCodes.cmp ->
qc: (_: a -> Vale.PPC64LE.QuickCode.quickCode a c) ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
inv: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0) ->
dec: (_: Vale.PPC64LE.Decls.va_state -> _: a -> d) ->
g1: a ->
s1: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.valid_cmp",
"Prims.l_imp",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.eval_cmp",
"Vale.PPC64LE.QuickCodes.mods_contains",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__wp",
"Vale.PPC64LE.QuickCodes.wp_While_inv",
"Prims.op_Negation",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_cr0",
"Vale.PPC64LE.Decls.eval_cmp_cr0",
"Vale.PPC64LE.QuickCodes.cmp_to_ocmp"
] | [] | false | false | false | false | true | let wp_While_body
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g1: a)
(s1: va_state)
(k: (va_state -> a -> Type0))
: Type0 =
| valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
(eval_cmp s1 b ==>
mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1)) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_If | val wp_If
(#a: Type)
(#c1 #c2: code)
(b: cmp)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 | val wp_If
(#a: Type)
(#c1 #c2: code)
(b: cmp)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 | let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k)) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 80,
"end_line": 250,
"start_col": 0,
"start_line": 245
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2 | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: Vale.PPC64LE.QuickCodes.cmp ->
qc1: Vale.PPC64LE.QuickCode.quickCode a c1 ->
qc2: Vale.PPC64LE.QuickCode.quickCode a c2 ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.valid_cmp",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Vale.PPC64LE.QuickCode.Mod_cr0",
"Prims.l_imp",
"Vale.PPC64LE.QuickCodes.eval_cmp",
"Vale.PPC64LE.QuickCodes.mods_contains",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__wp",
"Prims.op_Negation",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_cr0",
"Vale.PPC64LE.Decls.eval_cmp_cr0",
"Vale.PPC64LE.QuickCodes.cmp_to_ocmp"
] | [] | false | false | false | false | true | let wp_If
(#a: Type)
(#c1 #c2: code)
(b: cmp)
(qc1: quickCode a c1)
(qc2: quickCode a c2)
(mods: mods_t)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 =
| valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
(eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k)) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.wp_While | val wp_While
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g0: a)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 | val wp_While
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g0: a)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 | let wp_While
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0)
: Type0 =
inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
// REVIEW: we could get a better WP with forall (...state components...) instead of forall (s1:va_state)
(forall (s1:va_state) (g1:a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 86,
"end_line": 289,
"start_col": 0,
"start_line": 283
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted:
[@va_qattr "opaque_to_smt"]
let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma
(requires label r msg b)
(ensures b)
[SMTPat (label r msg b)]
// wrap "precedes" and LexCons to avoid issues with label (precedes ...)
let precedes_wrap (#a:Type) (x y:a) : GTot Type0 = precedes x y
[@va_qattr]
let rec mods_contains1 (allowed:mods_t) (found:mod_t) : bool =
match allowed with
| [] -> mod_eq Mod_None found
| h::t -> mod_eq h found || mods_contains1 t found
[@va_qattr]
let rec mods_contains (allowed:mods_t) (found:mods_t) : bool =
match found with
| [] -> true
| h::t -> mods_contains1 allowed h && mods_contains allowed t
[@va_qattr]
let if_code (b:bool) (c1:code) (c2:code) : code = if b then c1 else c2
open FStar.Monotonic.Pure
noeq type quickCodes (a:Type0) : codes -> Type =
| QEmpty: a -> quickCodes a []
| QSeq: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> quickCodes a cs -> quickCodes a (c::cs)
| QBind: #b:Type -> #c:code -> #cs:codes -> r:range -> msg:string ->
quickCode b c -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a (c::cs)
| QGetState: #cs:codes -> (va_state -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QPURE: #cs:codes -> r:range -> msg:string -> pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre} ->
(unit -> PURE unit (as_pure_wp pre)) -> quickCodes a cs -> quickCodes a cs
//| QBindPURE: #cs:codes -> b:Type -> r:range -> msg:string -> pre:((b -> GTot Type0) -> GTot Type0) ->
// (unit -> PURE b pre) -> (va_state -> b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QLemma: #cs:codes -> r:range -> msg:string -> pre:Type0 -> post:(squash pre -> Type0) ->
(unit -> Lemma (requires pre) (ensures post ())) -> quickCodes a cs -> quickCodes a cs
| QGhost: #cs:codes -> b:Type -> r:range -> msg:string -> pre:Type0 -> post:(b -> Type0) ->
(unit -> Ghost b (requires pre) (ensures post)) -> (b -> GTot (quickCodes a cs)) -> quickCodes a ((Block [])::cs)
| QAssertBy: #cs:codes -> r:range -> msg:string -> p:Type0 ->
quickCodes unit [] -> quickCodes a cs -> quickCodes a cs
[@va_qattr] unfold let va_QBind (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:va_state -> b -> GTot (quickCodes a cs)) : quickCodes a (c::cs) = QBind r msg qc qcs
[@va_qattr] unfold let va_QEmpty (#a:Type0) (v:a) : quickCodes a [] = QEmpty v
[@va_qattr] unfold let va_QLemma (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:Type0) (post:(squash pre -> Type0)) (l:unit -> Lemma (requires pre) (ensures post ())) (qcs:quickCodes a cs) : quickCodes a cs = QLemma r msg pre post l qcs
[@va_qattr] unfold let va_QSeq (#a:Type0) (#b:Type) (#c:code) (#cs:codes) (r:range) (msg:string) (qc:quickCode b c) (qcs:quickCodes a cs) : quickCodes a (c::cs) = QSeq r msg qc qcs
[@va_qattr]
let va_qPURE
(#cs:codes) (#pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (#a:Type0) (r:range) (msg:string)
($l:unit -> PURE unit (intro_pure_wp_monotonicity pre; pre)) (qcs:quickCodes a cs)
: quickCodes a cs =
QPURE r msg pre l qcs
(* REVIEW: this might be useful, but inference of pre doesn't work as well as for va_qPURE
(need to provide pre explicitly; as a result, no need to put $ on l)
[@va_qattr]
let va_qBindPURE
(#a #b:Type0) (#cs:codes) (pre:(b -> GTot Type0) -> GTot Type0) (r:range) (msg:string)
(l:unit -> PURE b pre) (qcs:va_state -> b -> GTot (quickCodes a cs))
: quickCodes a ((Block [])::cs) =
QBindPURE b r msg pre l qcs
*)
[@va_qattr]
let wp_proc (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
match qc with
| QProc _ _ wp _ -> wp s0 k
let wp_Seq_t (a:Type0) = va_state -> a -> Type0
let wp_Bind_t (a:Type0) = va_state -> a -> Type0
let k_AssertBy (p:Type0) (_:va_state) () = p
[@va_qattr]
let va_range1 = mk_range "" 0 0 0 0
val empty_list_is_small (#a:Type) (x:list a) : Lemma
([] #a == x \/ [] #a << x)
#push-options "--z3rlimit 20"
[@va_qattr]
let rec wp (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) :
Tot Type0 (decreases %[cs; 0; qcs])
=
match qcs with
| QEmpty g -> k s0 g
| QSeq r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Seq cs qcs mods k))
| QBind r msg qc qcs ->
let c::cs = cs in
label r msg (mods_contains mods qc.mods /\ wp_proc c qc s0 (wp_Bind cs qcs mods k))
| QGetState f ->
let c::cs = cs in
wp cs (f s0) mods k s0
| QPURE r msg pre l qcs ->
// REVIEW: rather than just applying 'pre' directly to k,
// we define this in a roundabout way so that:
// - it works even if 'pre' isn't known to be monotonic
// - F*'s error reporting uses 'guard_free' to process labels inside (wp cs qcs mods k s0)
(forall (p:unit -> GTot Type0).//{:pattern (pre p)}
(forall (u:unit).{:pattern (guard_free (p u))} wp cs qcs mods k s0 ==> p ())
==>
label r msg (pre p))
(*
| QBindPURE b r msg pre l qcs ->
let c::cs = cs in
(forall (p:b -> GTot Type0).//{:pattern (pre p)}
(forall (g:b).{:pattern (guard_free (p g))} wp cs (qcs s0 g) mods k s0 ==> p g)
==>
label r msg (pre p))
*)
| QLemma r msg pre post l qcs ->
label r msg pre /\ (post () ==> wp cs qcs mods k s0)
| QGhost b r msg pre post l qcs ->
let c::cs = cs in
label r msg pre /\ (forall (g:b). post g ==> wp cs (qcs g) mods k s0)
| QAssertBy r msg p qcsBy qcs ->
empty_list_is_small cs;
wp [] qcsBy mods (k_AssertBy p) s0 /\ (p ==> wp cs qcs mods k s0)
// Hoist lambdas out of main definition to avoid issues with function equality
and wp_Seq (#a:Type0) (#b:Type0) (cs:codes) (qcs:quickCodes b cs) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Seq_t a) (decreases %[cs; 1; qcs])
=
let f s0 _ = wp cs qcs mods k s0 in f
and wp_Bind (#a:Type0) (#b:Type0) (cs:codes) (qcs:va_state -> a -> GTot (quickCodes b cs)) (mods:mods_t) (k:va_state -> b -> Type0) :
Tot (wp_Bind_t a) (decreases %[cs; 1; qcs])
=
let f s0 g = wp cs (qcs s0 g) mods k s0 in f
#pop-options
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp cs qcs mods k s0)
(ensures fun (sN, fN, gN) ->
eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN
)
///// Block
unfold let block = va_Block
[@va_qattr]
let wp_block (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
wp cs (qcs s0) mods k s0
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_block qcs mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let qblock (#a:Type) (#cs:codes) (mods:mods_t) (qcs:va_state -> GTot (quickCodes a cs)) : quickCode a (block cs) =
QProc (block cs) mods (wp_block qcs mods) (qblock_proof qcs mods)
///// If, InlineIf
[@va_qattr]
let wp_InlineIf (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
( b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s0 k) /\
(not b ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s0 k)
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qInlineIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (if_code b c1 c2) =
QProc (if_code b c1 c2) mods (wp_InlineIf b qc1 qc2 mods) (qInlineIf_proof b qc1 qc2 mods)
noeq type cmp =
| Cmp_eq : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ne : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_le : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_ge : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_lt : o1:cmp_opr -> o2:cmp_opr -> cmp
| Cmp_gt : o1:cmp_opr -> o2:cmp_opr -> cmp
[@va_qattr]
let cmp_to_ocmp (c:cmp) : ocmp =
match c with
| Cmp_eq o1 o2 -> va_cmp_eq o1 o2
| Cmp_ne o1 o2 -> va_cmp_ne o1 o2
| Cmp_le o1 o2 -> va_cmp_le o1 o2
| Cmp_ge o1 o2 -> va_cmp_ge o1 o2
| Cmp_lt o1 o2 -> va_cmp_lt o1 o2
| Cmp_gt o1 o2 -> va_cmp_gt o1 o2
[@va_qattr]
let valid_cmp (c:cmp) (s:va_state) : Type0 =
match c with
| Cmp_eq o1 _ -> valid_first_cmp_opr o1
| Cmp_ne o1 _ -> valid_first_cmp_opr o1
| Cmp_le o1 _ -> valid_first_cmp_opr o1
| Cmp_ge o1 _ -> valid_first_cmp_opr o1
| Cmp_lt o1 _ -> valid_first_cmp_opr o1
| Cmp_gt o1 _ -> valid_first_cmp_opr o1
[@va_qattr]
let eval_cmp (s:va_state) (c:cmp) : GTot bool =
match c with
| Cmp_eq o1 o2 -> va_eval_cmp_opr s o1 = va_eval_cmp_opr s o2
| Cmp_ne o1 o2 -> va_eval_cmp_opr s o1 <> va_eval_cmp_opr s o2
| Cmp_le o1 o2 -> va_eval_cmp_opr s o1 <= va_eval_cmp_opr s o2
| Cmp_ge o1 o2 -> va_eval_cmp_opr s o1 >= va_eval_cmp_opr s o2
| Cmp_lt o1 o2 -> va_eval_cmp_opr s o1 < va_eval_cmp_opr s o2
| Cmp_gt o1 o2 -> va_eval_cmp_opr s o1 > va_eval_cmp_opr s o2
[@va_qattr]
let wp_If (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Type0 =
// REVIEW: this duplicates k
valid_cmp b s0 /\ mods_contains1 mods Mod_cr0 /\
(let s1 = va_upd_cr0 (eval_cmp_cr0 s0 (cmp_to_ocmp b)) s0 in
( eval_cmp s0 b ==> mods_contains mods qc1.mods /\ QProc?.wp qc1 s1 k) /\
(not (eval_cmp s0 b) ==> mods_contains mods qc2.mods /\ QProc?.wp qc2 s1 k))
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0)
: Ghost (va_state & va_fuel & a)
(requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k)
(ensures fun (sM, f0, g) ->
eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g
)
[@"opaque_to_smt" va_qattr]
let va_qIf (#a:Type) (#c1:code) (#c2:code) (mods:mods_t) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) : quickCode a (IfElse (cmp_to_ocmp b) c1 c2) =
QProc (IfElse (cmp_to_ocmp b) c1 c2) mods (wp_If b qc1 qc2 mods) (qIf_proof b qc1 qc2 mods)
///// While
[@va_qattr]
let wp_While_inv
(#a #d:Type) (#c:code) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (s1:va_state) (g1:a) (s2:va_state) (g2:a)
: Type0 =
s2.ok /\ inv s2 g2 /\ mods_contains mods (qc g2).mods /\ dec s2 g2 << dec s1 g1
[@va_qattr]
let wp_While_body
(#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0)
(dec:va_state -> a -> d) (g1:a) (s1:va_state) (k:va_state -> a -> Type0)
: Type0 =
valid_cmp b s1 /\
(let s1' = va_upd_cr0 (eval_cmp_cr0 s1 (cmp_to_ocmp b)) s1 in
( eval_cmp s1 b ==> mods_contains mods (qc g1).mods /\ QProc?.wp (qc g1) s1' (wp_While_inv qc mods inv dec s1 g1)) /\
(not (eval_cmp s1 b) ==> k s1' g1)) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: Vale.PPC64LE.QuickCodes.cmp ->
qc: (_: a -> Vale.PPC64LE.QuickCode.quickCode a c) ->
mods: Vale.PPC64LE.QuickCode.mods_t ->
inv: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0) ->
dec: (_: Vale.PPC64LE.Decls.va_state -> _: a -> d) ->
g0: a ->
s0: Vale.PPC64LE.Decls.va_state ->
k: (_: Vale.PPC64LE.Decls.va_state -> _: a -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCodes.code",
"Vale.PPC64LE.QuickCodes.cmp",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.PPC64LE.QuickCode.mods_t",
"Vale.PPC64LE.Decls.va_state",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.QuickCodes.mods_contains",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.PPC64LE.QuickCodes.mods_contains1",
"Vale.PPC64LE.QuickCode.Mod_cr0",
"Prims.l_Forall",
"Prims.l_imp",
"Vale.PPC64LE.QuickCodes.wp_While_body"
] | [] | false | false | false | false | true | let wp_While
(#a #d: Type)
(#c: code)
(b: cmp)
(qc: (a -> quickCode a c))
(mods: mods_t)
(inv: (va_state -> a -> Type0))
(dec: (va_state -> a -> d))
(g0: a)
(s0: va_state)
(k: (va_state -> a -> Type0))
: Type0 =
| inv s0 g0 /\ mods_contains mods (qc g0).mods /\ mods_contains1 mods Mod_cr0 /\
(forall (s1: va_state) (g1: a). inv s1 g1 ==> wp_While_body b qc mods inv dec g1 s1 k) | false |
Vale.PPC64LE.QuickCodes.fsti | Vale.PPC64LE.QuickCodes.label | val label (r: range) (msg: string) (p: Type0)
: Ghost Type (requires True) (ensures fun q -> q <==> p) | val label (r: range) (msg: string) (p: Type0)
: Ghost Type (requires True) (ensures fun q -> q <==> p) | let label (r:range) (msg:string) (p:Type0) : Ghost Type (requires True) (ensures fun q -> q <==> p) =
assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.QuickCodes.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 27,
"start_col": 0,
"start_line": 25
} | module Vale.PPC64LE.QuickCodes
// Optimized weakest precondition generation for 'quick' procedures
open FStar.Mul
open FStar.Range
open Vale.Def.Prop_s
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let code = va_code
unfold let codes = va_codes
unfold let fuel = va_fuel
unfold let eval = eval_code
[@va_qattr "opaque_to_smt"]
let labeled_wrap (r:range) (msg:string) (p:Type0) : GTot Type0 = labeled r msg p
// REVIEW: when used inside a function definition, 'labeled' can show up in an SMT query
// as an uninterpreted function. Make a wrapper around labeled that is interpreted: | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Vecs.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.Regs.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.QuickCodes.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: FStar.Range.range -> msg: Prims.string -> p: Type0 -> Prims.Ghost Type0 | Prims.Ghost | [] | [] | [
"FStar.Range.range",
"Prims.string",
"Vale.PPC64LE.QuickCodes.labeled_wrap",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.l_iff",
"Prims.l_True"
] | [] | false | false | false | false | true | let label (r: range) (msg: string) (p: Type0)
: Ghost Type (requires True) (ensures fun q -> q <==> p) =
| assert_norm (labeled_wrap r msg p <==> p);
labeled_wrap r msg p | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.