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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
LowParse.SLow.List.fst | LowParse.SLow.List.size32_list_inv | val size32_list_inv
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
(input: list t)
(continue: bool)
(accu: (U32.t * list t))
: GTot Type0 | val size32_list_inv
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
(input: list t)
(continue: bool)
(accu: (U32.t * list t))
: GTot Type0 | let size32_list_inv
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit {
serialize_list_precond k
})
(input: list t)
(continue: bool)
(accu: (U32.t * list t))
: GTot Type0
= let (len, rem) = accu in
let sz = Seq.length (serialize (serialize_list p s) input) in
if continue
then
U32.v len < U32.v u32_max /\
sz == U32.v len + Seq.length (serialize (serialize_list p s) rem)
else
size32_postcond (serialize_list p s) input len | {
"file_name": "src/lowparse/LowParse.SLow.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 50,
"end_line": 387,
"start_col": 0,
"start_line": 367
} | module LowParse.SLow.List
include LowParse.Spec.List
include LowParse.SLow.Combinators
module B32 = FStar.Bytes
module U32 = FStar.UInt32
module CL = C.Loops
#set-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8"
module L = FStar.List.Tot
let rec parse_list_tailrec'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: GTot (option (list t))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
Some (L.rev aux)
else
match p32 b with
| None -> None
| Some (v, n) ->
if n = 0ul
then None (* elements cannot be empty *)
else
parse_list_tailrec' p32 (B32.slice b n (B32.len b)) (v :: aux)
let list_append_rev_cons
(#t: Type)
(v: t)
(aux l: list t)
: Lemma (L.append (L.rev (v ::aux)) l == L.append (L.rev aux) (v :: l))
= L.rev_rev' (v :: aux);
L.rev_rev' aux;
L.append_assoc (L.rev aux) [v] l
let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma
(requires True)
(ensures (
parse_list_tailrec' p32 b aux == (
match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None
)))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else begin
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') ->
list_append_rev_cons v aux l
| None -> ()
end
let parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
begin match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None
end
= parse_list_tailrec'_correct' p32 b []
let list_rev_inv
(#t: Type)
(l: list t)
(b: bool)
(x: list t * list t)
: GTot Type0
= let (rem, acc) = x in
L.rev l == L.rev_acc rem acc /\
(b == false ==> rem == [])
let list_rev
(#t: Type)
(l: list t)
: Tot (l' : list t { l' == L.rev l } )
= match l with
| [] -> []
| _ ->
let (_, l') =
CL.total_while
(fun (rem, _) -> L.length rem)
(list_rev_inv l)
(fun (rem, acc) ->
match rem with
| [] -> (false, (rem, acc))
| a :: q -> (true, (q, a :: acc))
)
(l, [])
in
l'
let parse_list_tailrec_inv
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
(b: bool)
(x: option (bytes32 * list t))
: GTot Type0
= match x with
| Some (input', accu') ->
parse_list_tailrec' p32 input [] == parse_list_tailrec' p32 input' accu' /\
(b == false ==> B32.length input' == 0)
| None ->
b == false /\ None? (parse_list_tailrec' p32 input [])
let parse_list_tailrec_measure
(#t: Type)
(x: option (bytes32 * list t))
: GTot nat
= match x with
| None -> 0
| Some (input', _) -> B32.length input'
inline_for_extraction
let parse_list_tailrec_body
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: (x: option (bytes32 * list t)) ->
Pure (bool * option (bytes32 * list t))
(requires (parse_list_tailrec_inv p32 input true x))
(ensures (fun (continue, y) ->
parse_list_tailrec_inv p32 input continue y /\
(if continue then parse_list_tailrec_measure y < parse_list_tailrec_measure x else True)
))
= fun (x: option (bytes32 * list t)) ->
let (Some (input', accu')) = x in
let len = B32.len input' in
if len = 0ul
then (false, x)
else
match p32 input' with
| Some (v, consumed) ->
if consumed = 0ul
then (false, None)
else
let input'' = B32.slice input' consumed len in
(true, Some (input'', v :: accu'))
| None -> (false, None)
inline_for_extraction
let parse_list_tailrec
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: Tot (res: option (list t) { res == parse_list_tailrec' p32 input [] } )
= let accu =
CL.total_while
(parse_list_tailrec_measure #t)
(parse_list_tailrec_inv p32 input)
(fun x -> parse_list_tailrec_body p32 input x)
(Some (input, []))
in
match accu with
| None -> None
| Some (_, accu') -> Some (list_rev accu')
inline_for_extraction
let parse32_list
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
: Tot (parser32 (parse_list p))
= fun (input: bytes32) -> ((
parse_list_tailrec'_correct p32 input;
parser_kind_prop_equiv parse_list_kind (parse_list p);
match parse_list_tailrec p32 input with
| None -> None
| Some res ->
Some (res, B32.len input)
) <: (res: option (list t * U32.t) { parser32_correct (parse_list p) input res } ))
let rec partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
serializer32_correct (serialize_list p s) input res
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
let res = B32.empty_bytes in
assert (Seq.equal (B32.reveal res) (Seq.empty));
res
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let sq = partial_serialize32_list' p s s32 q in
let res = B32.append sa sq in
res
let rec partial_serialize32_list_tailrec'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(accu: bytes32)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
B32.length accu + Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\
B32.reveal res == Seq.append (B32.reveal accu) (B32.reveal (partial_serialize32_list' p s s32 input))
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
Seq.append_empty_r (B32.reveal accu);
accu
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let accu' = B32.append accu sa in
Seq.append_assoc (B32.reveal accu) (B32.reveal sa) (B32.reveal (partial_serialize32_list' p s s32 q));
partial_serialize32_list_tailrec' p s s32 accu' q
let partial_serialize32_list'_inv
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
(continue: bool)
(x: bytes32 * list t)
: GTot Type0
= serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\ (
let (accu, input') = x in
B32.length accu + Seq.length (serialize (serialize_list p s) input') < 4294967296 /\
serializer32_correct
(serialize_list p s)
input
(partial_serialize32_list_tailrec' p s s32 accu input') /\
(continue == false ==> L.length input' == 0)
)
let partial_serialize32_list'_measure
(#t: Type)
(x: bytes32 * list t)
: GTot nat
= L.length (snd x)
inline_for_extraction
let partial_serialize32_list'_body
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: (x: (bytes32 * list t)) ->
Pure (bool * (bytes32 * list t))
(requires (partial_serialize32_list'_inv p s s32 input true x))
(ensures (fun (continue, y) ->
partial_serialize32_list'_inv p s s32 input continue y /\
(continue == true ==> partial_serialize32_list'_measure y < partial_serialize32_list'_measure x)
))
= fun (x: bytes32 * list t) ->
let (accu, input') = x in
match input' with
| [] -> (false, x)
| a :: q ->
[@inline_let]
let _ = serialize_list_cons p s a q in
let sa = s32 a in
let accu' = B32.append accu sa in
(true, (accu', q))
let partial_serialize32_list'_init
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Lemma
(requires (
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296
))
(ensures (
partial_serialize32_list'_inv p s s32 input true (B32.empty_bytes, input)
))
= assert (Seq.equal (B32.reveal B32.empty_bytes) Seq.empty);
Seq.append_empty_l (B32.reveal (partial_serialize32_list' p s s32 input));
assert (B32.reveal (partial_serialize32_list' p s s32 input) == B32.reveal (partial_serialize32_list_tailrec' p s s32 B32.empty_bytes input));
assert (serializer32_correct (serialize_list p s) input (partial_serialize32_list_tailrec' p s s32 B32.empty_bytes input))
inline_for_extraction
let partial_serialize32_list
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(u: unit {
serialize_list_precond k
})
: Tot (partial_serializer32 (serialize_list p s))
= fun (input: list t { Seq.length (serialize (serialize_list p s) input) < 4294967296 } ) -> ((
let (res, _) =
partial_serialize32_list'_init p s s32 input;
CL.total_while
partial_serialize32_list'_measure
(partial_serialize32_list'_inv p s s32 input)
(fun x -> partial_serialize32_list'_body p s s32 input x)
(B32.empty_bytes, input)
in
res
) <: (res: bytes32 { serializer32_correct (serialize_list p s) input res })) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Bytes.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "C.Loops",
"short_module": "CL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 8,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s32: LowParse.SLow.Base.size32 s ->
u224: u228: Prims.unit{LowParse.Spec.List.serialize_list_precond k} ->
input: Prims.list t ->
continue: Prims.bool ->
accu: (FStar.UInt32.t * Prims.list t)
-> Prims.GTot Type0 | Prims.GTot | [
"sometrivial"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.size32",
"Prims.unit",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.list",
"Prims.bool",
"FStar.Pervasives.Native.tuple2",
"FStar.UInt32.t",
"Prims.l_and",
"Prims.op_LessThan",
"FStar.UInt32.v",
"LowParse.SLow.Base.u32_max",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list",
"LowParse.SLow.Base.size32_postcond",
"Prims.nat"
] | [] | false | false | false | false | true | let size32_list_inv
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
(input: list t)
(continue: bool)
(accu: (U32.t * list t))
: GTot Type0 =
| let len, rem = accu in
let sz = Seq.length (serialize (serialize_list p s) input) in
if continue
then U32.v len < U32.v u32_max /\ sz == U32.v len + Seq.length (serialize (serialize_list p s) rem)
else size32_postcond (serialize_list p s) input len | false |
LowParse.SLow.List.fst | LowParse.SLow.List.partial_serialize32_list | val partial_serialize32_list
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(u: unit{serialize_list_precond k})
: Tot (partial_serializer32 (serialize_list p s)) | val partial_serialize32_list
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(u: unit{serialize_list_precond k})
: Tot (partial_serializer32 (serialize_list p s)) | let partial_serialize32_list
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(u: unit {
serialize_list_precond k
})
: Tot (partial_serializer32 (serialize_list p s))
= fun (input: list t { Seq.length (serialize (serialize_list p s) input) < 4294967296 } ) -> ((
let (res, _) =
partial_serialize32_list'_init p s s32 input;
CL.total_while
partial_serialize32_list'_measure
(partial_serialize32_list'_inv p s s32 input)
(fun x -> partial_serialize32_list'_body p s s32 input x)
(B32.empty_bytes, input)
in
res
) <: (res: bytes32 { serializer32_correct (serialize_list p s) input res })) | {
"file_name": "src/lowparse/LowParse.SLow.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 78,
"end_line": 365,
"start_col": 0,
"start_line": 345
} | module LowParse.SLow.List
include LowParse.Spec.List
include LowParse.SLow.Combinators
module B32 = FStar.Bytes
module U32 = FStar.UInt32
module CL = C.Loops
#set-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8"
module L = FStar.List.Tot
let rec parse_list_tailrec'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: GTot (option (list t))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
Some (L.rev aux)
else
match p32 b with
| None -> None
| Some (v, n) ->
if n = 0ul
then None (* elements cannot be empty *)
else
parse_list_tailrec' p32 (B32.slice b n (B32.len b)) (v :: aux)
let list_append_rev_cons
(#t: Type)
(v: t)
(aux l: list t)
: Lemma (L.append (L.rev (v ::aux)) l == L.append (L.rev aux) (v :: l))
= L.rev_rev' (v :: aux);
L.rev_rev' aux;
L.append_assoc (L.rev aux) [v] l
let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma
(requires True)
(ensures (
parse_list_tailrec' p32 b aux == (
match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None
)))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else begin
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') ->
list_append_rev_cons v aux l
| None -> ()
end
let parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
begin match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None
end
= parse_list_tailrec'_correct' p32 b []
let list_rev_inv
(#t: Type)
(l: list t)
(b: bool)
(x: list t * list t)
: GTot Type0
= let (rem, acc) = x in
L.rev l == L.rev_acc rem acc /\
(b == false ==> rem == [])
let list_rev
(#t: Type)
(l: list t)
: Tot (l' : list t { l' == L.rev l } )
= match l with
| [] -> []
| _ ->
let (_, l') =
CL.total_while
(fun (rem, _) -> L.length rem)
(list_rev_inv l)
(fun (rem, acc) ->
match rem with
| [] -> (false, (rem, acc))
| a :: q -> (true, (q, a :: acc))
)
(l, [])
in
l'
let parse_list_tailrec_inv
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
(b: bool)
(x: option (bytes32 * list t))
: GTot Type0
= match x with
| Some (input', accu') ->
parse_list_tailrec' p32 input [] == parse_list_tailrec' p32 input' accu' /\
(b == false ==> B32.length input' == 0)
| None ->
b == false /\ None? (parse_list_tailrec' p32 input [])
let parse_list_tailrec_measure
(#t: Type)
(x: option (bytes32 * list t))
: GTot nat
= match x with
| None -> 0
| Some (input', _) -> B32.length input'
inline_for_extraction
let parse_list_tailrec_body
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: (x: option (bytes32 * list t)) ->
Pure (bool * option (bytes32 * list t))
(requires (parse_list_tailrec_inv p32 input true x))
(ensures (fun (continue, y) ->
parse_list_tailrec_inv p32 input continue y /\
(if continue then parse_list_tailrec_measure y < parse_list_tailrec_measure x else True)
))
= fun (x: option (bytes32 * list t)) ->
let (Some (input', accu')) = x in
let len = B32.len input' in
if len = 0ul
then (false, x)
else
match p32 input' with
| Some (v, consumed) ->
if consumed = 0ul
then (false, None)
else
let input'' = B32.slice input' consumed len in
(true, Some (input'', v :: accu'))
| None -> (false, None)
inline_for_extraction
let parse_list_tailrec
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: Tot (res: option (list t) { res == parse_list_tailrec' p32 input [] } )
= let accu =
CL.total_while
(parse_list_tailrec_measure #t)
(parse_list_tailrec_inv p32 input)
(fun x -> parse_list_tailrec_body p32 input x)
(Some (input, []))
in
match accu with
| None -> None
| Some (_, accu') -> Some (list_rev accu')
inline_for_extraction
let parse32_list
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
: Tot (parser32 (parse_list p))
= fun (input: bytes32) -> ((
parse_list_tailrec'_correct p32 input;
parser_kind_prop_equiv parse_list_kind (parse_list p);
match parse_list_tailrec p32 input with
| None -> None
| Some res ->
Some (res, B32.len input)
) <: (res: option (list t * U32.t) { parser32_correct (parse_list p) input res } ))
let rec partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
serializer32_correct (serialize_list p s) input res
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
let res = B32.empty_bytes in
assert (Seq.equal (B32.reveal res) (Seq.empty));
res
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let sq = partial_serialize32_list' p s s32 q in
let res = B32.append sa sq in
res
let rec partial_serialize32_list_tailrec'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(accu: bytes32)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
B32.length accu + Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\
B32.reveal res == Seq.append (B32.reveal accu) (B32.reveal (partial_serialize32_list' p s s32 input))
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
Seq.append_empty_r (B32.reveal accu);
accu
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let accu' = B32.append accu sa in
Seq.append_assoc (B32.reveal accu) (B32.reveal sa) (B32.reveal (partial_serialize32_list' p s s32 q));
partial_serialize32_list_tailrec' p s s32 accu' q
let partial_serialize32_list'_inv
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
(continue: bool)
(x: bytes32 * list t)
: GTot Type0
= serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\ (
let (accu, input') = x in
B32.length accu + Seq.length (serialize (serialize_list p s) input') < 4294967296 /\
serializer32_correct
(serialize_list p s)
input
(partial_serialize32_list_tailrec' p s s32 accu input') /\
(continue == false ==> L.length input' == 0)
)
let partial_serialize32_list'_measure
(#t: Type)
(x: bytes32 * list t)
: GTot nat
= L.length (snd x)
inline_for_extraction
let partial_serialize32_list'_body
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: (x: (bytes32 * list t)) ->
Pure (bool * (bytes32 * list t))
(requires (partial_serialize32_list'_inv p s s32 input true x))
(ensures (fun (continue, y) ->
partial_serialize32_list'_inv p s s32 input continue y /\
(continue == true ==> partial_serialize32_list'_measure y < partial_serialize32_list'_measure x)
))
= fun (x: bytes32 * list t) ->
let (accu, input') = x in
match input' with
| [] -> (false, x)
| a :: q ->
[@inline_let]
let _ = serialize_list_cons p s a q in
let sa = s32 a in
let accu' = B32.append accu sa in
(true, (accu', q))
let partial_serialize32_list'_init
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Lemma
(requires (
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296
))
(ensures (
partial_serialize32_list'_inv p s s32 input true (B32.empty_bytes, input)
))
= assert (Seq.equal (B32.reveal B32.empty_bytes) Seq.empty);
Seq.append_empty_l (B32.reveal (partial_serialize32_list' p s s32 input));
assert (B32.reveal (partial_serialize32_list' p s s32 input) == B32.reveal (partial_serialize32_list_tailrec' p s s32 B32.empty_bytes input));
assert (serializer32_correct (serialize_list p s) input (partial_serialize32_list_tailrec' p s s32 B32.empty_bytes input)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Bytes.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "C.Loops",
"short_module": "CL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 8,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: LowParse.Spec.Base.parser k t ->
s: LowParse.Spec.Base.serializer p ->
s32: LowParse.SLow.Base.partial_serializer32 s ->
u206: u207: Prims.unit{LowParse.Spec.List.serialize_list_precond k}
-> LowParse.SLow.Base.partial_serializer32 (LowParse.Spec.List.serialize_list p s) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.partial_serializer32",
"Prims.unit",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.list",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"FStar.Pervasives.Native.tuple2",
"C.Loops.total_while",
"LowParse.SLow.List.partial_serialize32_list'_measure",
"LowParse.SLow.List.partial_serialize32_list'_inv",
"LowParse.SLow.List.partial_serialize32_list'_body",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Bytes.empty_bytes",
"LowParse.SLow.List.partial_serialize32_list'_init"
] | [] | false | false | false | false | false | let partial_serialize32_list
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(u: unit{serialize_list_precond k})
: Tot (partial_serializer32 (serialize_list p s)) =
| fun (input: list t {Seq.length (serialize (serialize_list p s) input) < 4294967296}) ->
((let res, _ =
partial_serialize32_list'_init p s s32 input;
CL.total_while partial_serialize32_list'_measure
(partial_serialize32_list'_inv p s s32 input)
(fun x -> partial_serialize32_list'_body p s s32 input x)
(B32.empty_bytes, input)
in
res)
<:
(res: bytes32{serializer32_correct (serialize_list p s) input res})) | false |
LowParse.SLow.List.fst | LowParse.SLow.List.partial_serialize32_list_tailrec' | val partial_serialize32_list_tailrec'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(accu: bytes32)
(input: list t)
: Ghost bytes32
(requires
(serialize_list_precond k /\
(B32.length accu + Seq.length (serialize (serialize_list p s) input) < 4294967296)))
(ensures
(fun (res: bytes32) ->
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\
B32.reveal res ==
Seq.append (B32.reveal accu) (B32.reveal (partial_serialize32_list' p s s32 input))))
(decreases input) | val partial_serialize32_list_tailrec'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(accu: bytes32)
(input: list t)
: Ghost bytes32
(requires
(serialize_list_precond k /\
(B32.length accu + Seq.length (serialize (serialize_list p s) input) < 4294967296)))
(ensures
(fun (res: bytes32) ->
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\
B32.reveal res ==
Seq.append (B32.reveal accu) (B32.reveal (partial_serialize32_list' p s s32 input))))
(decreases input) | let rec partial_serialize32_list_tailrec'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(accu: bytes32)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
B32.length accu + Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\
B32.reveal res == Seq.append (B32.reveal accu) (B32.reveal (partial_serialize32_list' p s s32 input))
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
Seq.append_empty_r (B32.reveal accu);
accu
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let accu' = B32.append accu sa in
Seq.append_assoc (B32.reveal accu) (B32.reveal sa) (B32.reveal (partial_serialize32_list' p s s32 q));
partial_serialize32_list_tailrec' p s s32 accu' q | {
"file_name": "src/lowparse/LowParse.SLow.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 53,
"end_line": 269,
"start_col": 0,
"start_line": 240
} | module LowParse.SLow.List
include LowParse.Spec.List
include LowParse.SLow.Combinators
module B32 = FStar.Bytes
module U32 = FStar.UInt32
module CL = C.Loops
#set-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8"
module L = FStar.List.Tot
let rec parse_list_tailrec'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: GTot (option (list t))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
Some (L.rev aux)
else
match p32 b with
| None -> None
| Some (v, n) ->
if n = 0ul
then None (* elements cannot be empty *)
else
parse_list_tailrec' p32 (B32.slice b n (B32.len b)) (v :: aux)
let list_append_rev_cons
(#t: Type)
(v: t)
(aux l: list t)
: Lemma (L.append (L.rev (v ::aux)) l == L.append (L.rev aux) (v :: l))
= L.rev_rev' (v :: aux);
L.rev_rev' aux;
L.append_assoc (L.rev aux) [v] l
let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma
(requires True)
(ensures (
parse_list_tailrec' p32 b aux == (
match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None
)))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else begin
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') ->
list_append_rev_cons v aux l
| None -> ()
end
let parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
begin match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None
end
= parse_list_tailrec'_correct' p32 b []
let list_rev_inv
(#t: Type)
(l: list t)
(b: bool)
(x: list t * list t)
: GTot Type0
= let (rem, acc) = x in
L.rev l == L.rev_acc rem acc /\
(b == false ==> rem == [])
let list_rev
(#t: Type)
(l: list t)
: Tot (l' : list t { l' == L.rev l } )
= match l with
| [] -> []
| _ ->
let (_, l') =
CL.total_while
(fun (rem, _) -> L.length rem)
(list_rev_inv l)
(fun (rem, acc) ->
match rem with
| [] -> (false, (rem, acc))
| a :: q -> (true, (q, a :: acc))
)
(l, [])
in
l'
let parse_list_tailrec_inv
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
(b: bool)
(x: option (bytes32 * list t))
: GTot Type0
= match x with
| Some (input', accu') ->
parse_list_tailrec' p32 input [] == parse_list_tailrec' p32 input' accu' /\
(b == false ==> B32.length input' == 0)
| None ->
b == false /\ None? (parse_list_tailrec' p32 input [])
let parse_list_tailrec_measure
(#t: Type)
(x: option (bytes32 * list t))
: GTot nat
= match x with
| None -> 0
| Some (input', _) -> B32.length input'
inline_for_extraction
let parse_list_tailrec_body
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: (x: option (bytes32 * list t)) ->
Pure (bool * option (bytes32 * list t))
(requires (parse_list_tailrec_inv p32 input true x))
(ensures (fun (continue, y) ->
parse_list_tailrec_inv p32 input continue y /\
(if continue then parse_list_tailrec_measure y < parse_list_tailrec_measure x else True)
))
= fun (x: option (bytes32 * list t)) ->
let (Some (input', accu')) = x in
let len = B32.len input' in
if len = 0ul
then (false, x)
else
match p32 input' with
| Some (v, consumed) ->
if consumed = 0ul
then (false, None)
else
let input'' = B32.slice input' consumed len in
(true, Some (input'', v :: accu'))
| None -> (false, None)
inline_for_extraction
let parse_list_tailrec
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: Tot (res: option (list t) { res == parse_list_tailrec' p32 input [] } )
= let accu =
CL.total_while
(parse_list_tailrec_measure #t)
(parse_list_tailrec_inv p32 input)
(fun x -> parse_list_tailrec_body p32 input x)
(Some (input, []))
in
match accu with
| None -> None
| Some (_, accu') -> Some (list_rev accu')
inline_for_extraction
let parse32_list
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
: Tot (parser32 (parse_list p))
= fun (input: bytes32) -> ((
parse_list_tailrec'_correct p32 input;
parser_kind_prop_equiv parse_list_kind (parse_list p);
match parse_list_tailrec p32 input with
| None -> None
| Some res ->
Some (res, B32.len input)
) <: (res: option (list t * U32.t) { parser32_correct (parse_list p) input res } ))
let rec partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
serializer32_correct (serialize_list p s) input res
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
let res = B32.empty_bytes in
assert (Seq.equal (B32.reveal res) (Seq.empty));
res
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let sq = partial_serialize32_list' p s s32 q in
let res = B32.append sa sq in
res | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Bytes.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "C.Loops",
"short_module": "CL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 8,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: LowParse.Spec.Base.parser k t ->
s: LowParse.Spec.Base.serializer p ->
s32: LowParse.SLow.Base.partial_serializer32 s ->
accu: LowParse.SLow.Base.bytes32 ->
input: Prims.list t
-> Prims.Ghost LowParse.SLow.Base.bytes32 | Prims.Ghost | [
""
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.partial_serializer32",
"LowParse.SLow.Base.bytes32",
"Prims.list",
"Prims.unit",
"FStar.Seq.Base.append_empty_r",
"FStar.Bytes.byte",
"FStar.Bytes.reveal",
"LowParse.Spec.List.serialize_list_nil",
"LowParse.SLow.List.partial_serialize32_list_tailrec'",
"FStar.Seq.Base.append_assoc",
"LowParse.SLow.List.partial_serialize32_list'",
"FStar.Bytes.bytes",
"FStar.Bytes.append",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.List.serialize_list_cons",
"Prims.l_and",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Bytes.length",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.append"
] | [
"recursion"
] | false | false | false | false | false | let rec partial_serialize32_list_tailrec'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(accu: bytes32)
(input: list t)
: Ghost bytes32
(requires
(serialize_list_precond k /\
(B32.length accu + Seq.length (serialize (serialize_list p s) input) < 4294967296)))
(ensures
(fun (res: bytes32) ->
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\
B32.reveal res ==
Seq.append (B32.reveal accu) (B32.reveal (partial_serialize32_list' p s s32 input))))
(decreases input) =
| match input with
| [] ->
serialize_list_nil p s;
Seq.append_empty_r (B32.reveal accu);
accu
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let accu' = B32.append accu sa in
Seq.append_assoc (B32.reveal accu)
(B32.reveal sa)
(B32.reveal (partial_serialize32_list' p s s32 q));
partial_serialize32_list_tailrec' p s s32 accu' q | false |
LowParse.SLow.List.fst | LowParse.SLow.List.parse_list_tailrec'_correct | val parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
(match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None) | val parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
(match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None) | let parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
begin match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None
end
= parse_list_tailrec'_correct' p32 b [] | {
"file_name": "src/lowparse/LowParse.SLow.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 39,
"end_line": 90,
"start_col": 0,
"start_line": 79
} | module LowParse.SLow.List
include LowParse.Spec.List
include LowParse.SLow.Combinators
module B32 = FStar.Bytes
module U32 = FStar.UInt32
module CL = C.Loops
#set-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8"
module L = FStar.List.Tot
let rec parse_list_tailrec'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: GTot (option (list t))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
Some (L.rev aux)
else
match p32 b with
| None -> None
| Some (v, n) ->
if n = 0ul
then None (* elements cannot be empty *)
else
parse_list_tailrec' p32 (B32.slice b n (B32.len b)) (v :: aux)
let list_append_rev_cons
(#t: Type)
(v: t)
(aux l: list t)
: Lemma (L.append (L.rev (v ::aux)) l == L.append (L.rev aux) (v :: l))
= L.rev_rev' (v :: aux);
L.rev_rev' aux;
L.append_assoc (L.rev aux) [v] l
let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma
(requires True)
(ensures (
parse_list_tailrec' p32 b aux == (
match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None
)))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else begin
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') ->
list_append_rev_cons v aux l
| None -> ()
end | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Bytes.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "C.Loops",
"short_module": "CL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 8,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p32: LowParse.SLow.Base.parser32 p -> b: LowParse.SLow.Base.bytes32
-> FStar.Pervasives.Lemma
(ensures
((match LowParse.Spec.Base.parse (LowParse.Spec.List.parse_list p) (FStar.Bytes.reveal b) with
| FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ l _) ->
LowParse.SLow.List.parse_list_tailrec' p32 b [] == FStar.Pervasives.Native.Some l
| FStar.Pervasives.Native.None #_ ->
LowParse.SLow.List.parse_list_tailrec' p32 b [] == FStar.Pervasives.Native.None)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.SLow.Base.parser32",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.List.parse_list_tailrec'_correct'",
"Prims.Nil",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"LowParse.Spec.Base.parse",
"Prims.list",
"LowParse.Spec.List.parse_list",
"FStar.Bytes.reveal",
"LowParse.Spec.Base.consumed_length",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.SLow.List.parse_list_tailrec'",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
(match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None) =
| parse_list_tailrec'_correct' p32 b [] | false |
LowParse.SLow.List.fst | LowParse.SLow.List.size32_list_body | val size32_list_body
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
(input: list t)
(x: (U32.t * list t))
: Pure (bool * (U32.t * list t))
(requires (size32_list_inv s32 u input true x))
(ensures
(fun (continue, y) ->
size32_list_inv s32 u input continue y /\
(continue == true ==> size32_list_measure y < size32_list_measure x))) | val size32_list_body
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
(input: list t)
(x: (U32.t * list t))
: Pure (bool * (U32.t * list t))
(requires (size32_list_inv s32 u input true x))
(ensures
(fun (continue, y) ->
size32_list_inv s32 u input continue y /\
(continue == true ==> size32_list_measure y < size32_list_measure x))) | let size32_list_body
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit {
serialize_list_precond k
})
(input: list t)
: (x: (U32.t * list t)) ->
Pure (bool * (U32.t * list t))
(requires (size32_list_inv s32 u input true x))
(ensures (fun (continue, y) ->
size32_list_inv s32 u input continue y /\
(continue == true ==> size32_list_measure y < size32_list_measure x)
))
= fun accu ->
let (len, rem) = accu in
match rem with
| [] ->
[@inline_let]
let _ = serialize_list_nil p s in
(false, accu)
| a :: q ->
[@inline_let]
let _ = serialize_list_cons p s a q in
let sza = s32 a in
let len' = add_overflow len sza in
if len' = u32_max
then (false, (u32_max, []))
else (true, (len', q)) | {
"file_name": "src/lowparse/LowParse.SLow.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 28,
"end_line": 428,
"start_col": 0,
"start_line": 397
} | module LowParse.SLow.List
include LowParse.Spec.List
include LowParse.SLow.Combinators
module B32 = FStar.Bytes
module U32 = FStar.UInt32
module CL = C.Loops
#set-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8"
module L = FStar.List.Tot
let rec parse_list_tailrec'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: GTot (option (list t))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
Some (L.rev aux)
else
match p32 b with
| None -> None
| Some (v, n) ->
if n = 0ul
then None (* elements cannot be empty *)
else
parse_list_tailrec' p32 (B32.slice b n (B32.len b)) (v :: aux)
let list_append_rev_cons
(#t: Type)
(v: t)
(aux l: list t)
: Lemma (L.append (L.rev (v ::aux)) l == L.append (L.rev aux) (v :: l))
= L.rev_rev' (v :: aux);
L.rev_rev' aux;
L.append_assoc (L.rev aux) [v] l
let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma
(requires True)
(ensures (
parse_list_tailrec' p32 b aux == (
match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None
)))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else begin
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') ->
list_append_rev_cons v aux l
| None -> ()
end
let parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
begin match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None
end
= parse_list_tailrec'_correct' p32 b []
let list_rev_inv
(#t: Type)
(l: list t)
(b: bool)
(x: list t * list t)
: GTot Type0
= let (rem, acc) = x in
L.rev l == L.rev_acc rem acc /\
(b == false ==> rem == [])
let list_rev
(#t: Type)
(l: list t)
: Tot (l' : list t { l' == L.rev l } )
= match l with
| [] -> []
| _ ->
let (_, l') =
CL.total_while
(fun (rem, _) -> L.length rem)
(list_rev_inv l)
(fun (rem, acc) ->
match rem with
| [] -> (false, (rem, acc))
| a :: q -> (true, (q, a :: acc))
)
(l, [])
in
l'
let parse_list_tailrec_inv
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
(b: bool)
(x: option (bytes32 * list t))
: GTot Type0
= match x with
| Some (input', accu') ->
parse_list_tailrec' p32 input [] == parse_list_tailrec' p32 input' accu' /\
(b == false ==> B32.length input' == 0)
| None ->
b == false /\ None? (parse_list_tailrec' p32 input [])
let parse_list_tailrec_measure
(#t: Type)
(x: option (bytes32 * list t))
: GTot nat
= match x with
| None -> 0
| Some (input', _) -> B32.length input'
inline_for_extraction
let parse_list_tailrec_body
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: (x: option (bytes32 * list t)) ->
Pure (bool * option (bytes32 * list t))
(requires (parse_list_tailrec_inv p32 input true x))
(ensures (fun (continue, y) ->
parse_list_tailrec_inv p32 input continue y /\
(if continue then parse_list_tailrec_measure y < parse_list_tailrec_measure x else True)
))
= fun (x: option (bytes32 * list t)) ->
let (Some (input', accu')) = x in
let len = B32.len input' in
if len = 0ul
then (false, x)
else
match p32 input' with
| Some (v, consumed) ->
if consumed = 0ul
then (false, None)
else
let input'' = B32.slice input' consumed len in
(true, Some (input'', v :: accu'))
| None -> (false, None)
inline_for_extraction
let parse_list_tailrec
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: Tot (res: option (list t) { res == parse_list_tailrec' p32 input [] } )
= let accu =
CL.total_while
(parse_list_tailrec_measure #t)
(parse_list_tailrec_inv p32 input)
(fun x -> parse_list_tailrec_body p32 input x)
(Some (input, []))
in
match accu with
| None -> None
| Some (_, accu') -> Some (list_rev accu')
inline_for_extraction
let parse32_list
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
: Tot (parser32 (parse_list p))
= fun (input: bytes32) -> ((
parse_list_tailrec'_correct p32 input;
parser_kind_prop_equiv parse_list_kind (parse_list p);
match parse_list_tailrec p32 input with
| None -> None
| Some res ->
Some (res, B32.len input)
) <: (res: option (list t * U32.t) { parser32_correct (parse_list p) input res } ))
let rec partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
serializer32_correct (serialize_list p s) input res
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
let res = B32.empty_bytes in
assert (Seq.equal (B32.reveal res) (Seq.empty));
res
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let sq = partial_serialize32_list' p s s32 q in
let res = B32.append sa sq in
res
let rec partial_serialize32_list_tailrec'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(accu: bytes32)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
B32.length accu + Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\
B32.reveal res == Seq.append (B32.reveal accu) (B32.reveal (partial_serialize32_list' p s s32 input))
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
Seq.append_empty_r (B32.reveal accu);
accu
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let accu' = B32.append accu sa in
Seq.append_assoc (B32.reveal accu) (B32.reveal sa) (B32.reveal (partial_serialize32_list' p s s32 q));
partial_serialize32_list_tailrec' p s s32 accu' q
let partial_serialize32_list'_inv
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
(continue: bool)
(x: bytes32 * list t)
: GTot Type0
= serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\ (
let (accu, input') = x in
B32.length accu + Seq.length (serialize (serialize_list p s) input') < 4294967296 /\
serializer32_correct
(serialize_list p s)
input
(partial_serialize32_list_tailrec' p s s32 accu input') /\
(continue == false ==> L.length input' == 0)
)
let partial_serialize32_list'_measure
(#t: Type)
(x: bytes32 * list t)
: GTot nat
= L.length (snd x)
inline_for_extraction
let partial_serialize32_list'_body
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: (x: (bytes32 * list t)) ->
Pure (bool * (bytes32 * list t))
(requires (partial_serialize32_list'_inv p s s32 input true x))
(ensures (fun (continue, y) ->
partial_serialize32_list'_inv p s s32 input continue y /\
(continue == true ==> partial_serialize32_list'_measure y < partial_serialize32_list'_measure x)
))
= fun (x: bytes32 * list t) ->
let (accu, input') = x in
match input' with
| [] -> (false, x)
| a :: q ->
[@inline_let]
let _ = serialize_list_cons p s a q in
let sa = s32 a in
let accu' = B32.append accu sa in
(true, (accu', q))
let partial_serialize32_list'_init
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Lemma
(requires (
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296
))
(ensures (
partial_serialize32_list'_inv p s s32 input true (B32.empty_bytes, input)
))
= assert (Seq.equal (B32.reveal B32.empty_bytes) Seq.empty);
Seq.append_empty_l (B32.reveal (partial_serialize32_list' p s s32 input));
assert (B32.reveal (partial_serialize32_list' p s s32 input) == B32.reveal (partial_serialize32_list_tailrec' p s s32 B32.empty_bytes input));
assert (serializer32_correct (serialize_list p s) input (partial_serialize32_list_tailrec' p s s32 B32.empty_bytes input))
inline_for_extraction
let partial_serialize32_list
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(u: unit {
serialize_list_precond k
})
: Tot (partial_serializer32 (serialize_list p s))
= fun (input: list t { Seq.length (serialize (serialize_list p s) input) < 4294967296 } ) -> ((
let (res, _) =
partial_serialize32_list'_init p s s32 input;
CL.total_while
partial_serialize32_list'_measure
(partial_serialize32_list'_inv p s s32 input)
(fun x -> partial_serialize32_list'_body p s s32 input x)
(B32.empty_bytes, input)
in
res
) <: (res: bytes32 { serializer32_correct (serialize_list p s) input res }))
let size32_list_inv
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit {
serialize_list_precond k
})
(input: list t)
(continue: bool)
(accu: (U32.t * list t))
: GTot Type0
= let (len, rem) = accu in
let sz = Seq.length (serialize (serialize_list p s) input) in
if continue
then
U32.v len < U32.v u32_max /\
sz == U32.v len + Seq.length (serialize (serialize_list p s) rem)
else
size32_postcond (serialize_list p s) input len
let size32_list_measure
(#t: Type)
(accu: (U32.t * list t))
: GTot nat
= let (_, rem) = accu in
L.length rem | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Bytes.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "C.Loops",
"short_module": "CL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 8,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s32: LowParse.SLow.Base.size32 s ->
u244: u247: Prims.unit{LowParse.Spec.List.serialize_list_precond k} ->
input: Prims.list t ->
x: (FStar.UInt32.t * Prims.list t)
-> Prims.Pure (Prims.bool * (FStar.UInt32.t * Prims.list t)) | Prims.Pure | [] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.size32",
"Prims.unit",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.UInt32.t",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"LowParse.Spec.List.serialize_list_nil",
"Prims.op_Equality",
"LowParse.SLow.Base.u32_max",
"Prims.Nil",
"LowParse.SLow.Base.add_overflow",
"LowParse.SLow.Base.size32_postcond",
"LowParse.Spec.List.serialize_list_cons",
"LowParse.SLow.List.size32_list_inv",
"Prims.l_and",
"Prims.l_imp",
"Prims.eq2",
"Prims.op_LessThan",
"LowParse.SLow.List.size32_list_measure"
] | [] | false | false | false | false | false | let size32_list_body
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
(input: list t)
(x: (U32.t * list t))
: Pure (bool * (U32.t * list t))
(requires (size32_list_inv s32 u input true x))
(ensures
(fun (continue, y) ->
size32_list_inv s32 u input continue y /\
(continue == true ==> size32_list_measure y < size32_list_measure x))) =
| fun accu ->
let len, rem = accu in
match rem with
| [] ->
[@@ inline_let ]let _ = serialize_list_nil p s in
(false, accu)
| a :: q ->
[@@ inline_let ]let _ = serialize_list_cons p s a q in
let sza = s32 a in
let len' = add_overflow len sza in
if len' = u32_max then (false, (u32_max, [])) else (true, (len', q)) | false |
LowParse.SLow.List.fst | LowParse.SLow.List.partial_serialize32_list' | val partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires
(serialize_list_precond k /\
(Seq.length (serialize (serialize_list p s) input) < 4294967296)))
(ensures
(fun (res: bytes32) ->
serialize_list_precond k /\ serializer32_correct (serialize_list p s) input res))
(decreases input) | val partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires
(serialize_list_precond k /\
(Seq.length (serialize (serialize_list p s) input) < 4294967296)))
(ensures
(fun (res: bytes32) ->
serialize_list_precond k /\ serializer32_correct (serialize_list p s) input res))
(decreases input) | let rec partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
serializer32_correct (serialize_list p s) input res
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
let res = B32.empty_bytes in
assert (Seq.equal (B32.reveal res) (Seq.empty));
res
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let sq = partial_serialize32_list' p s s32 q in
let res = B32.append sa sq in
res | {
"file_name": "src/lowparse/LowParse.SLow.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 7,
"end_line": 238,
"start_col": 0,
"start_line": 210
} | module LowParse.SLow.List
include LowParse.Spec.List
include LowParse.SLow.Combinators
module B32 = FStar.Bytes
module U32 = FStar.UInt32
module CL = C.Loops
#set-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8"
module L = FStar.List.Tot
let rec parse_list_tailrec'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: GTot (option (list t))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
Some (L.rev aux)
else
match p32 b with
| None -> None
| Some (v, n) ->
if n = 0ul
then None (* elements cannot be empty *)
else
parse_list_tailrec' p32 (B32.slice b n (B32.len b)) (v :: aux)
let list_append_rev_cons
(#t: Type)
(v: t)
(aux l: list t)
: Lemma (L.append (L.rev (v ::aux)) l == L.append (L.rev aux) (v :: l))
= L.rev_rev' (v :: aux);
L.rev_rev' aux;
L.append_assoc (L.rev aux) [v] l
let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma
(requires True)
(ensures (
parse_list_tailrec' p32 b aux == (
match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None
)))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else begin
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') ->
list_append_rev_cons v aux l
| None -> ()
end
let parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
begin match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None
end
= parse_list_tailrec'_correct' p32 b []
let list_rev_inv
(#t: Type)
(l: list t)
(b: bool)
(x: list t * list t)
: GTot Type0
= let (rem, acc) = x in
L.rev l == L.rev_acc rem acc /\
(b == false ==> rem == [])
let list_rev
(#t: Type)
(l: list t)
: Tot (l' : list t { l' == L.rev l } )
= match l with
| [] -> []
| _ ->
let (_, l') =
CL.total_while
(fun (rem, _) -> L.length rem)
(list_rev_inv l)
(fun (rem, acc) ->
match rem with
| [] -> (false, (rem, acc))
| a :: q -> (true, (q, a :: acc))
)
(l, [])
in
l'
let parse_list_tailrec_inv
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
(b: bool)
(x: option (bytes32 * list t))
: GTot Type0
= match x with
| Some (input', accu') ->
parse_list_tailrec' p32 input [] == parse_list_tailrec' p32 input' accu' /\
(b == false ==> B32.length input' == 0)
| None ->
b == false /\ None? (parse_list_tailrec' p32 input [])
let parse_list_tailrec_measure
(#t: Type)
(x: option (bytes32 * list t))
: GTot nat
= match x with
| None -> 0
| Some (input', _) -> B32.length input'
inline_for_extraction
let parse_list_tailrec_body
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: (x: option (bytes32 * list t)) ->
Pure (bool * option (bytes32 * list t))
(requires (parse_list_tailrec_inv p32 input true x))
(ensures (fun (continue, y) ->
parse_list_tailrec_inv p32 input continue y /\
(if continue then parse_list_tailrec_measure y < parse_list_tailrec_measure x else True)
))
= fun (x: option (bytes32 * list t)) ->
let (Some (input', accu')) = x in
let len = B32.len input' in
if len = 0ul
then (false, x)
else
match p32 input' with
| Some (v, consumed) ->
if consumed = 0ul
then (false, None)
else
let input'' = B32.slice input' consumed len in
(true, Some (input'', v :: accu'))
| None -> (false, None)
inline_for_extraction
let parse_list_tailrec
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: Tot (res: option (list t) { res == parse_list_tailrec' p32 input [] } )
= let accu =
CL.total_while
(parse_list_tailrec_measure #t)
(parse_list_tailrec_inv p32 input)
(fun x -> parse_list_tailrec_body p32 input x)
(Some (input, []))
in
match accu with
| None -> None
| Some (_, accu') -> Some (list_rev accu')
inline_for_extraction
let parse32_list
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
: Tot (parser32 (parse_list p))
= fun (input: bytes32) -> ((
parse_list_tailrec'_correct p32 input;
parser_kind_prop_equiv parse_list_kind (parse_list p);
match parse_list_tailrec p32 input with
| None -> None
| Some res ->
Some (res, B32.len input)
) <: (res: option (list t * U32.t) { parser32_correct (parse_list p) input res } )) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Bytes.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "C.Loops",
"short_module": "CL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 8,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: LowParse.Spec.Base.parser k t ->
s: LowParse.Spec.Base.serializer p ->
s32: LowParse.SLow.Base.partial_serializer32 s ->
input: Prims.list t
-> Prims.Ghost LowParse.SLow.Base.bytes32 | Prims.Ghost | [
""
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.partial_serializer32",
"Prims.list",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Bytes.byte",
"FStar.Bytes.reveal",
"FStar.Seq.Base.empty",
"FStar.Bytes.lbytes",
"FStar.Bytes.empty_bytes",
"LowParse.Spec.List.serialize_list_nil",
"FStar.Bytes.bytes",
"FStar.Bytes.append",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.List.partial_serialize32_list'",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.List.serialize_list_cons",
"Prims.l_and",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list"
] | [
"recursion"
] | false | false | false | false | false | let rec partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires
(serialize_list_precond k /\
(Seq.length (serialize (serialize_list p s) input) < 4294967296)))
(ensures
(fun (res: bytes32) ->
serialize_list_precond k /\ serializer32_correct (serialize_list p s) input res))
(decreases input) =
| match input with
| [] ->
serialize_list_nil p s;
let res = B32.empty_bytes in
assert (Seq.equal (B32.reveal res) (Seq.empty));
res
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let sq = partial_serialize32_list' p s s32 q in
let res = B32.append sa sq in
res | false |
MerkleTree.New.High.Correct.Flushing.fst | MerkleTree.New.High.Correct.Flushing.mt_flush_to_inv_preserved_ | val mt_flush_to_inv_preserved_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires (mt_olds_hs_inv #_ #f lv pi j olds hs))
(ensures (mt_olds_hs_inv #_ #f lv i j
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j))) | val mt_flush_to_inv_preserved_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires (mt_olds_hs_inv #_ #f lv pi j olds hs))
(ensures (mt_olds_hs_inv #_ #f lv i j
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j))) | let mt_flush_to_inv_preserved_ #_ #f lv pi i j olds hs =
mt_flush_to_merge_preserved #_ #f lv pi i j olds hs;
mt_olds_hs_lth_inv_ok #_ #f lv pi j olds hs;
mt_hashes_lth_inv_equiv #_ #f lv j
(merge_hs #_ #f olds hs)
(merge_hs #_ #f (mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j));
mt_hashes_inv_equiv #_ #f lv j
(merge_hs #_ #f olds hs)
(merge_hs #_ #f (mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j)) | {
"file_name": "src/MerkleTree.New.High.Correct.Flushing.fst",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 48,
"end_line": 137,
"start_col": 0,
"start_line": 127
} | module MerkleTree.New.High.Correct.Flushing
open EverCrypt
open EverCrypt.Helpers
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module List = FStar.List.Tot
module S = FStar.Seq
module U32 = FStar.UInt32
module U8 = FStar.UInt8
type uint32_t = U32.t
type uint8_t = U8.t
module EHS = EverCrypt.Hash
module MTS = MerkleTree.Spec
open MerkleTree.New.High
open MerkleTree.New.High.Correct.Base
/// Correctness of flushing
val mt_flush_to_olds:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
GTot (folds:hashess #hsz {
S.length folds = 32 /\
S.equal (S.slice olds 0 lv) (S.slice folds 0 lv) /\
mt_olds_inv #hsz lv i folds})
(decreases i)
let rec mt_flush_to_olds #_ #f lv pi i j olds hs =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then olds (* no updates *)
else (let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs)
val mt_flush_to_olds_hs_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs1:hashess #hsz {S.length hs1 = 32 /\ hs_wf_elts lv hs1 pi j} ->
hs2:hashess #hsz {S.length hs2 = 32 /\ hs_wf_elts lv hs2 pi j} ->
Lemma (requires (S.equal (S.slice hs1 lv 32) (S.slice hs2 lv 32)))
(ensures (S.equal (mt_flush_to_olds #_ #f lv pi i j olds hs1)
(mt_flush_to_olds #_ #f lv pi i j olds hs2)))
(decreases i)
let rec mt_flush_to_olds_hs_equiv #_ #f lv pi i j olds hs1 hs2 =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then ()
else (assert (S.index hs1 lv == S.index hs2 lv);
let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs1 lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds_hs_equiv #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs1 hs2)
val mt_flush_to_merge_preserved:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires True)
(ensures (S.equal (merge_hs #_ #f olds hs)
(merge_hs #_ #f
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j))))
(decreases i)
#reset-options "--z3rlimit 40 --max_fuel 2"
let rec mt_flush_to_merge_preserved #_ #f lv pi i j olds hs =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then ()
else begin
let nolds = S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs lv) 0 (oi - opi))) in
let nhs = S.upd hs lv
(S.slice (S.index hs lv) (oi - opi) (j - opi)) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
hs_wf_elts_equal (lv + 1) hs nhs (pi / 2) (j / 2);
mt_flush_to_merge_preserved #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds nhs;
mt_flush_to_olds_hs_equiv #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs nhs;
assert (S.equal (merge_hs #_ #f nolds nhs)
(merge_hs #_ #f
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j)));
merge_hs_upd #_ #f olds hs lv
(S.append (S.index olds lv) (S.slice (S.index hs lv) 0 (oi - opi)))
(S.slice (S.index hs lv) (oi - opi) (j - opi));
assert (S.equal (merge_hs #_ #f olds hs) (merge_hs #_ #f nolds nhs))
end
#reset-options
val mt_flush_to_inv_preserved_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires (mt_olds_hs_inv #_ #f lv pi j olds hs))
(ensures (mt_olds_hs_inv #_ #f lv i j
(mt_flush_to_olds #_ #f lv pi i j olds hs) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.Correct.Base.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Flushing.fst"
} | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
lv: Prims.nat{lv < 32} ->
pi: Prims.nat ->
i: Prims.nat{i >= pi} ->
j: Prims.nat{j >= i /\ j < Prims.pow2 (32 - lv)} ->
olds:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length olds = 32 /\ MerkleTree.New.High.Correct.Base.mt_olds_inv lv pi olds} ->
hs:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length hs = 32 /\ MerkleTree.New.High.hs_wf_elts lv hs pi j}
-> FStar.Pervasives.Lemma
(requires MerkleTree.New.High.Correct.Base.mt_olds_hs_inv lv pi j olds hs)
(ensures
MerkleTree.New.High.Correct.Base.mt_olds_hs_inv lv
i
j
(MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds lv pi i j olds hs)
(MerkleTree.New.High.mt_flush_to_ lv hs pi i j)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Prims.l_and",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.hs_wf_elts",
"MerkleTree.New.High.Correct.Base.mt_hashes_inv_equiv",
"MerkleTree.New.High.Correct.Base.merge_hs",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds",
"MerkleTree.New.High.mt_flush_to_",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_equiv",
"MerkleTree.New.High.Correct.Base.mt_olds_hs_lth_inv_ok",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_merge_preserved"
] | [] | true | false | true | false | false | let mt_flush_to_inv_preserved_ #_ #f lv pi i j olds hs =
| mt_flush_to_merge_preserved #_ #f lv pi i j olds hs;
mt_olds_hs_lth_inv_ok #_ #f lv pi j olds hs;
mt_hashes_lth_inv_equiv #_
#f
lv
j
(merge_hs #_ #f olds hs)
(merge_hs #_ #f (mt_flush_to_olds #_ #f lv pi i j olds hs) (mt_flush_to_ lv hs pi i j));
mt_hashes_inv_equiv #_
#f
lv
j
(merge_hs #_ #f olds hs)
(merge_hs #_ #f (mt_flush_to_olds #_ #f lv pi i j olds hs) (mt_flush_to_ lv hs pi i j)) | false |
Hacl.Impl.SHA2.Core.fst | Hacl.Impl.SHA2.Core.emit8 | val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8}
-> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a)
-> result:multibuf (lanes a m) (HD.hash_len a) ->
Stack unit
(requires fun h -> live_multi h result /\ live h hbuf /\
internally_disjoint result /\ disjoint_multi result hbuf)
(ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\
as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) | val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8}
-> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a)
-> result:multibuf (lanes a m) (HD.hash_len a) ->
Stack unit
(requires fun h -> live_multi h result /\ live h hbuf /\
internally_disjoint result /\ disjoint_multi result hbuf)
(ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\
as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) | let emit8 #a #m hbuf result =
let h0 = ST.get() in
let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in
assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7);
copy b0 (sub hbuf 0ul (HD.hash_len a));
copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a));
copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a));
copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a));
let h1 = ST.get() in
assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1);
copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a));
copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a));
copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a));
copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a));
let h1 = ST.get() in
assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a));
assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a));
assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a));
assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a));
assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a));
assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a));
assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a));
assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a));
NTup.eq_intro (as_seq_multi h1 result)
(NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7))))))));
assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1);
assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf));
emit8_lemma #a #m (as_seq h0 hbuf);
loc_multi8 result;
assert (modifies_multi result h0 h1);
() | {
"file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 758,
"start_col": 0,
"start_line": 728
} | module Hacl.Impl.SHA2.Core
open FStar.Mul
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.IntVector
open Lib.MultiBuffer
open Spec.Hash.Definitions
//open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq
open Hacl.Spec.SHA2.Vec
module ST = FStar.HyperStack.ST
module NTup = Lib.NTuple
module SpecVec = Hacl.Spec.SHA2.Vec
module VecTranspose = Lib.IntVector.Transpose
module LSeq = Lib.Sequence
module HD = Hacl.Hash.Definitions
(* Force ordering in dependency analysis so that monomorphizations are inserted
into the Types module first. *)
let _ = Hacl.Impl.SHA2.Types.uint8_8p
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let state_t (a:sha2_alg) (m:m_spec) =
lbuffer (element_t a m) 8ul
unfold
let block_t (a:sha2_alg) =
lbuffer uint8 (HD.block_len a)
inline_for_extraction noextract
let ws_t (a:sha2_alg) (m:m_spec) =
lbuffer (element_t a m) 16ul
inline_for_extraction noextract
val set_wsi: #a:sha2_alg -> #m:m_spec
-> ws:ws_t a m
-> i:size_t{v i < 16}
-> b:lbuffer uint8 (HD.block_len a)
-> bi:size_t{v bi < 16 / (lanes a m)} ->
Stack unit
(requires fun h -> live h b /\ live h ws /\ disjoint b ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi)))
let set_wsi #a #m ws i b bi =
[@inline_let]
let l = lanes a m in
ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a))
noextract
let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m =
let b = b.(|0|) in
let ws0 = SpecVec.load_elementi b 0 in
let ws1 = SpecVec.load_elementi b 1 in
let ws2 = SpecVec.load_elementi b 2 in
let ws3 = SpecVec.load_elementi b 3 in
let ws4 = SpecVec.load_elementi b 4 in
let ws5 = SpecVec.load_elementi b 5 in
let ws6 = SpecVec.load_elementi b 6 in
let ws7 = SpecVec.load_elementi b 7 in
let ws8 = SpecVec.load_elementi b 8 in
let ws9 = SpecVec.load_elementi b 9 in
let ws10 = SpecVec.load_elementi b 10 in
let ws11 = SpecVec.load_elementi b 11 in
let ws12 = SpecVec.load_elementi b 12 in
let ws13 = SpecVec.load_elementi b 13 in
let ws14 = SpecVec.load_elementi b 14 in
let ws15 = SpecVec.load_elementi b 15 in
LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7
ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
noextract
let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) :
Lemma (SpecVec.load_blocks b == load_blocks_spec1 b)
=
LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b)
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1}
-> b:multibuf (lanes a m) (HD.block_len a)
-> ws:ws_t a m ->
Stack unit
(requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
let load_blocks1 #a #m ib ws =
let h0 = ST.get() in
let b = ib.(|0|) in
set_wsi ws 0ul b 0ul;
set_wsi ws 1ul b 1ul;
set_wsi ws 2ul b 2ul;
set_wsi ws 3ul b 3ul;
set_wsi ws 4ul b 4ul;
set_wsi ws 5ul b 5ul;
set_wsi ws 6ul b 6ul;
let h1 = ST.get() in
assert (modifies (loc ws) h0 h1);
set_wsi ws 7ul b 7ul;
set_wsi ws 8ul b 8ul;
set_wsi ws 9ul b 9ul;
set_wsi ws 10ul b 10ul;
set_wsi ws 11ul b 11ul;
set_wsi ws 12ul b 12ul;
set_wsi ws 13ul b 13ul;
set_wsi ws 14ul b 14ul;
set_wsi ws 15ul b 15ul;
let h1 = ST.get() in
assert (modifies (loc ws) h0 h1);
LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib));
load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib);
assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib));
assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib))
#pop-options
noextract
let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m =
let b0 = b.(|0|) in
let b1 = b.(|1|) in
let b2 = b.(|2|) in
let b3 = b.(|3|) in
let ws0 = SpecVec.load_elementi b0 0 in
let ws1 = SpecVec.load_elementi b1 0 in
let ws2 = SpecVec.load_elementi b2 0 in
let ws3 = SpecVec.load_elementi b3 0 in
let ws4 = SpecVec.load_elementi b0 1 in
let ws5 = SpecVec.load_elementi b1 1 in
let ws6 = SpecVec.load_elementi b2 1 in
let ws7 = SpecVec.load_elementi b3 1 in
let ws8 = SpecVec.load_elementi b0 2 in
let ws9 = SpecVec.load_elementi b1 2 in
let ws10 = SpecVec.load_elementi b2 2 in
let ws11 = SpecVec.load_elementi b3 2 in
let ws12 = SpecVec.load_elementi b0 3 in
let ws13 = SpecVec.load_elementi b1 3 in
let ws14 = SpecVec.load_elementi b2 3 in
let ws15 = SpecVec.load_elementi b3 3 in
LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7
ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
noextract
let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) :
Lemma (SpecVec.load_blocks b == load_blocks_spec4 b)
=
LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b)
inline_for_extraction noextract
val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4}
-> b:multibuf (lanes a m) (HD.block_len a)
-> ws:ws_t a m ->
Stack unit
(requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
#push-options "--z3rlimit 150"
let load_blocks4 #a #m ib ws =
let h0 = ST.get() in
let (b0,(b1,(b2,b3))) = NTup.tup4 ib in
set_wsi ws 0ul b0 0ul;
set_wsi ws 1ul b1 0ul;
set_wsi ws 2ul b2 0ul;
set_wsi ws 3ul b3 0ul;
set_wsi ws 4ul b0 1ul;
set_wsi ws 5ul b1 1ul;
set_wsi ws 6ul b2 1ul;
let h1 = ST.get() in
assert (modifies (loc ws) h0 h1);
set_wsi ws 7ul b3 1ul;
set_wsi ws 8ul b0 2ul;
set_wsi ws 9ul b1 2ul;
set_wsi ws 10ul b2 2ul;
set_wsi ws 11ul b3 2ul;
set_wsi ws 12ul b0 3ul;
set_wsi ws 13ul b1 3ul;
set_wsi ws 14ul b2 3ul;
set_wsi ws 15ul b3 3ul;
let h1 = ST.get() in
assert (modifies (loc ws) h0 h1);
LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib));
load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib);
assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib));
assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib));
()
#pop-options
noextract
let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m =
let b0 = b.(|0|) in
let b1 = b.(|1|) in
let b2 = b.(|2|) in
let b3 = b.(|3|) in
let b4 = b.(|4|) in
let b5 = b.(|5|) in
let b6 = b.(|6|) in
let b7 = b.(|7|) in
let ws0 = SpecVec.load_elementi b0 0 in
let ws1 = SpecVec.load_elementi b1 0 in
let ws2 = SpecVec.load_elementi b2 0 in
let ws3 = SpecVec.load_elementi b3 0 in
let ws4 = SpecVec.load_elementi b4 0 in
let ws5 = SpecVec.load_elementi b5 0 in
let ws6 = SpecVec.load_elementi b6 0 in
let ws7 = SpecVec.load_elementi b7 0 in
let ws8 = SpecVec.load_elementi b0 1 in
let ws9 = SpecVec.load_elementi b1 1 in
let ws10 = SpecVec.load_elementi b2 1 in
let ws11 = SpecVec.load_elementi b3 1 in
let ws12 = SpecVec.load_elementi b4 1 in
let ws13 = SpecVec.load_elementi b5 1 in
let ws14 = SpecVec.load_elementi b6 1 in
let ws15 = SpecVec.load_elementi b7 1 in
LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7
ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
noextract
let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) :
Lemma (SpecVec.load_blocks b == load_blocks_spec8 b)
=
LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b)
inline_for_extraction noextract
val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8}
-> b:multibuf (lanes a m) (HD.block_len a)
-> ws:ws_t a m ->
Stack unit
(requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
#push-options "--z3rlimit 150"
let load_blocks8 #a #m ib ws =
let h0 = ST.get() in
let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in
set_wsi ws 0ul b0 0ul;
set_wsi ws 1ul b1 0ul;
set_wsi ws 2ul b2 0ul;
set_wsi ws 3ul b3 0ul;
set_wsi ws 4ul b4 0ul;
set_wsi ws 5ul b5 0ul;
set_wsi ws 6ul b6 0ul;
let h1 = ST.get() in
assert (modifies (loc ws) h0 h1);
set_wsi ws 7ul b7 0ul;
set_wsi ws 8ul b0 1ul;
set_wsi ws 9ul b1 1ul;
set_wsi ws 10ul b2 1ul;
set_wsi ws 11ul b3 1ul;
set_wsi ws 12ul b4 1ul;
set_wsi ws 13ul b5 1ul;
set_wsi ws 14ul b6 1ul;
set_wsi ws 15ul b7 1ul;
let h1 = ST.get() in
assert (modifies (loc ws) h0 h1);
LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib));
load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib);
assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib));
assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib));
()
#pop-options
inline_for_extraction noextract
val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m}
-> b:multibuf (lanes a m) (HD.block_len a)
-> ws:ws_t a m ->
Stack unit
(requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
let load_blocks #a #m b ws =
match lanes a m with
| 1 -> load_blocks1 b ws
| 4 -> load_blocks4 b ws
| 8 -> load_blocks8 b ws
inline_for_extraction noextract
val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m ->
Stack unit
(requires fun h -> live h ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
let transpose_ws4 #a #m ws =
let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in
let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in
let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in
let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in
create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
inline_for_extraction noextract
val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m ->
Stack unit
(requires fun h -> live h ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
let transpose_ws8 #a #m ws =
let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in
let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in
create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
inline_for_extraction noextract
val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m ->
Stack unit
(requires fun h -> live h ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
let transpose_ws #a #m ws =
match lanes a m with
| 1 -> ()
| 4 -> transpose_ws4 ws
| 8 -> transpose_ws8 ws
inline_for_extraction noextract
val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m}
-> b:multibuf (lanes a m) (HD.block_len a)
-> ws:ws_t a m ->
Stack unit
(requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b))
let load_ws #a #m b ws =
load_blocks b ws;
transpose_ws ws
inline_for_extraction noextract
let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) :
n:size_t{v n == SpecVec.padded_blocks a (v len)}
=
if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul
inline_for_extraction noextract
val load_last_blocks: #a:sha2_alg
-> totlen_buf:lbuffer uint8 (len_len a)
-> len:size_t{v len <= block_length a}
-> b:lbuffer uint8 len
-> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a}
-> last:lbuffer uint8 (2ul *! HD.block_len a) ->
Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a))
(requires fun h -> live h totlen_buf /\ live h b /\ live h last /\
disjoint b last /\ disjoint last totlen_buf /\
as_seq h last == LSeq.create (2 * block_length a) (u8 0))
(ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\
live h1 l0 /\ live h1 l1 /\
(forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\
(as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b)))
#push-options "--z3rlimit 200"
let load_last_blocks #a totlen_buf len b fin last =
let h0 = ST.get() in
update_sub last 0ul len b;
last.(len) <- u8 0x80;
update_sub last (fin -. len_len a) (len_len a) totlen_buf;
let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in
let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in
let h1 = ST.get() in
assert (modifies (loc last) h0 h1);
(last0,last1)
#pop-options
noextract
let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') =
(forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x)
inline_for_extraction noextract
let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) =
totlen_buf:lbuffer uint8 (len_len a)
-> len:size_t{v len <= block_length a}
-> b:multibuf (lanes a m) len
-> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a}
-> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) ->
Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a))
(requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\
disjoint_multi b last /\ disjoint last totlen_buf /\
as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0))
(ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\
live_multi h1 l0 /\ live_multi h1 l1 /\
preserves_sub_disjoint_multi last l0 /\
preserves_sub_disjoint_multi last l1 /\
(as_seq_multi h1 l0, as_seq_multi h1 l1) ==
SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b))
inline_for_extraction noextract
val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m
#push-options "--z3rlimit 250"
let load_last1 #a #m totlen_buf len b fin last =
let h0 = ST.get() in
let b0 = b.(|0|) in
let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in
let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in
let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in
let h1 = ST.get() in
assert (modifies (loc last) h0 h1);
NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0));
NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0));
NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1));
assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) ==
SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b));
reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m);
(lb0,lb1)
#pop-options
inline_for_extraction noextract
val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m
#push-options "--z3rlimit 350"
let load_last4 #a #m totlen_buf len b fin last =
let h0 = ST.get() in
let (b0,(b1,(b2,b3))) = NTup.tup4 b in
let last0 = sub last 0ul (2ul *! HD.block_len a) in
let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in
let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in
let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in
let h1 = ST.get() in
assert (disjoint last0 last1);
LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0));
let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in
let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in
let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in
let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in
let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in
let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in
let h1 = ST.get() in
assert ((as_seq h1 l00, as_seq h1 l01) ==
SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0));
assert ((as_seq h1 l10, as_seq h1 l11) ==
SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1));
assert ((as_seq h1 l20, as_seq h1 l21) ==
SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2));
assert ((as_seq h1 l30, as_seq h1 l31) ==
SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3));
NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30)))));
NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31)))));
assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1);
assert (modifies (loc last) h0 h1);
assert (live_multi h1 mb0);
assert (live_multi h1 mb1);
reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m);
(mb0, mb1)
#pop-options
inline_for_extraction noextract
val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m
#push-options "--z3rlimit 600"
let load_last8 #a #m totlen_buf len b fin last =
let h0 = ST.get() in
let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in
let last0 = sub last 0ul (2ul *! HD.block_len a) in
let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in
let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in
let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in
let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in
let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in
let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in
let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in
assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7);
let h1 = ST.get() in
assert (h0 == h1);
LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0));
LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0));
let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in
let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in
let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2);
let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in
let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in
let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2);
let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in
let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in
let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2);
let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in
let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in
let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3);
assert (modifies (loc last) h0 h3);
let mb0:multibuf (lanes a m) (HD.block_len a) =
ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in
let mb1:multibuf (lanes a m) (HD.block_len a) =
ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in
ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70)))))));
ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71)))))));
assert (live_multi h3 mb0);
assert (live_multi h3 mb1);
NTup.eq_intro (as_seq_multi h3 mb0)
(ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30,
(as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70)))))))));
NTup.eq_intro (as_seq_multi h3 mb1)
(ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31,
(as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71)))))))));
assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) ==
SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b));
reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m);
(mb0, mb1)
#pop-options
inline_for_extraction noextract
val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m
let load_last #a #m totlen_buf len b fin last =
match lanes a m with
| 1 -> load_last1 #a #m totlen_buf len b fin last
| 4 -> load_last4 #a #m totlen_buf len b fin last
| 8 -> load_last8 #a #m totlen_buf len b fin last
inline_for_extraction noextract
val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st))
let transpose_state4 #a #m st =
let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in
let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in
create8 st st0' st4' st1' st5' st2' st6' st3' st7'
inline_for_extraction noextract
val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st))
let transpose_state8 #a #m st =
let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in
create8 st st0' st1' st2' st3' st4' st5' st6' st7'
inline_for_extraction noextract
val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\
as_seq h1 st == SpecVec.transpose_state (as_seq h0 st))
let transpose_state #a #m st =
match lanes a m with
| 1 -> ()
| 4 -> transpose_state4 st
| 8 -> transpose_state8 st
inline_for_extraction noextract
val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m}
-> st:state_t a m
-> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) ->
Stack unit
(requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\
as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0))
(ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\
as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st))
let store_state #a #m st hbuf =
transpose_state st;
Lib.IntVector.Serialize.vecs_store_be hbuf st
noextract
let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) :
multiseq (lanes a m) (hash_length a)
=
let hsub = LSeq.sub hseq 0 (hash_length a) in
ntup1 hsub
noextract
let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) :
Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq)
=
Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq)
inline_for_extraction noextract
val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1}
-> hbuf:lbuffer uint8 (8ul *! HD.word_len a)
-> result:multibuf (lanes a m) (HD.hash_len a) ->
Stack unit
(requires fun h -> live_multi h result /\ live h hbuf /\
internally_disjoint result /\ disjoint_multi result hbuf)
(ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\
as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
let emit1 #a #m hbuf result =
let h0 = ST.get() in
copy result.(|0|) (sub hbuf 0ul (HD.hash_len a));
let h1 = ST.get() in
Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf));
emit1_lemma #a #m (as_seq h0 hbuf);
assert (modifies_multi result h0 h1)
noextract
let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) :
multiseq (lanes a m) (hash_length a)
=
let open Lib.Sequence in
let h0 = sub hseq 0 (hash_length a) in
let h1 = sub hseq (8 * word_length a) (hash_length a) in
let h2 = sub hseq (16 * word_length a) (hash_length a) in
let h3 = sub hseq (24 * word_length a) (hash_length a) in
let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in
hsub
noextract
let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) :
Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq)
=
Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq)
inline_for_extraction noextract
val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4}
-> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a)
-> result:multibuf (lanes a m) (HD.hash_len a) ->
Stack unit
(requires fun h -> live_multi h result /\ live h hbuf /\
internally_disjoint result /\ disjoint_multi result hbuf)
(ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\
as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
#push-options "--z3rlimit 200"
let emit4 #a #m hbuf result =
let h0 = ST.get() in
let (b0,(b1,(b2,b3))) = NTup.tup4 result in
assert (disjoint b0 b1);
assert (disjoint b0 b2);
assert (disjoint b0 b3);
assert (disjoint b1 b2);
assert (disjoint b1 b3);
assert (disjoint b2 b3);
copy b0 (sub hbuf 0ul (HD.hash_len a));
copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a));
copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a));
copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a));
let h1 = ST.get() in
assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a));
assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a));
assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a));
assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a));
NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3))));
assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1);
assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf));
emit4_lemma #a #m (as_seq h0 hbuf);
loc_multi4 result;
assert (modifies_multi result h0 h1);
()
#pop-options
noextract
let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) :
multiseq (lanes a m) (hash_length a)
=
let open Lib.Sequence in
let h0 = sub hseq 0 (hash_length a) in
let h1 = sub hseq (8 * word_length a) (hash_length a) in
let h2 = sub hseq (16 * word_length a) (hash_length a) in
let h3 = sub hseq (24 * word_length a) (hash_length a) in
let h4 = sub hseq (32 * word_length a) (hash_length a) in
let h5 = sub hseq (40 * word_length a) (hash_length a) in
let h6 = sub hseq (48 * word_length a) (hash_length a) in
let h7 = sub hseq (56 * word_length a) (hash_length a) in
let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in
hsub
noextract
let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) :
Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq)
=
Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq)
inline_for_extraction noextract
val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8}
-> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a)
-> result:multibuf (lanes a m) (HD.hash_len a) ->
Stack unit
(requires fun h -> live_multi h result /\ live h hbuf /\
internally_disjoint result /\ disjoint_multi result hbuf)
(ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\
as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntVector.Transpose.fsti.checked",
"Lib.IntVector.Serialize.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Impl.SHA2.Types.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SHA2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "HD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.IntVector.Transpose",
"short_module": "VecTranspose"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Lib.NTuple",
"short_module": "NTup"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 700,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
hbuf:
Lib.Buffer.lbuffer Lib.IntTypes.uint8
(Lib.IntTypes.size (Hacl.Spec.SHA2.Vec.lanes a m) *! 8ul *! Hacl.Hash.Definitions.word_len a
) ->
result:
Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.hash_len a)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.Vec.m_spec",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Hacl.Spec.SHA2.Vec.lanes",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"FStar.UInt32.__uint_to_t",
"Hacl.Hash.Definitions.word_len",
"Lib.MultiBuffer.multibuf",
"Hacl.Hash.Definitions.hash_len",
"Prims.unit",
"Prims._assert",
"Lib.MultiBuffer.modifies_multi",
"Lib.MultiBuffer.loc_multi8",
"Hacl.Impl.SHA2.Core.emit8_lemma",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.eq2",
"Lib.NTuple.ntuple",
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.hash_length",
"Lib.MultiBuffer.as_seq_multi",
"Hacl.Impl.SHA2.Core.emit8_spec",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Lib.NTuple.eq_intro",
"Lib.IntTypes.v",
"Lib.NTuple.ntup8",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.l_and",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"FStar.Mul.op_Star",
"Spec.Hash.Definitions.word_length",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.copy",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"Lib.MultiBuffer.internally_disjoint8",
"Lib.NTuple.tup8"
] | [] | false | true | false | false | false | let emit8 #a #m hbuf result =
| let h0 = ST.get () in
let b0, (b1, (b2, (b3, (b4, (b5, (b6, b7)))))) = NTup.tup8 result in
assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7);
copy b0 (sub hbuf 0ul (HD.hash_len a));
copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a));
copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a));
copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a));
let h1 = ST.get () in
assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1);
copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a));
copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a));
copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a));
copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a));
let h1 = ST.get () in
assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a));
assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a));
assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a));
assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a));
assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a));
assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a));
assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a));
assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a));
NTup.eq_intro (as_seq_multi h1 result)
(NTup.ntup8 (as_seq h1 b0,
(as_seq h1 b1,
(as_seq h1 b2,
(as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7))))))));
assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+|
loc b7)
h0
h1);
assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf));
emit8_lemma #a #m (as_seq h0 hbuf);
loc_multi8 result;
assert (modifies_multi result h0 h1);
() | false |
LowParse.SLow.List.fst | LowParse.SLow.List.size32_list | val size32_list
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
: Tot (size32 (serialize_list p s)) | val size32_list
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
: Tot (size32 (serialize_list p s)) | let size32_list
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit {
serialize_list_precond k
})
: Tot (size32 (serialize_list p s))
= fun input ->
[@inline_let]
let (len, _) =
CL.total_while
size32_list_measure
(size32_list_inv s32 u input)
(fun x -> size32_list_body s32 u input x)
(0ul, input)
in
(len <: (len : U32.t { size32_postcond (serialize_list p s) input len } )) | {
"file_name": "src/lowparse/LowParse.SLow.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 76,
"end_line": 450,
"start_col": 0,
"start_line": 431
} | module LowParse.SLow.List
include LowParse.Spec.List
include LowParse.SLow.Combinators
module B32 = FStar.Bytes
module U32 = FStar.UInt32
module CL = C.Loops
#set-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8"
module L = FStar.List.Tot
let rec parse_list_tailrec'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: GTot (option (list t))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
Some (L.rev aux)
else
match p32 b with
| None -> None
| Some (v, n) ->
if n = 0ul
then None (* elements cannot be empty *)
else
parse_list_tailrec' p32 (B32.slice b n (B32.len b)) (v :: aux)
let list_append_rev_cons
(#t: Type)
(v: t)
(aux l: list t)
: Lemma (L.append (L.rev (v ::aux)) l == L.append (L.rev aux) (v :: l))
= L.rev_rev' (v :: aux);
L.rev_rev' aux;
L.append_assoc (L.rev aux) [v] l
let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma
(requires True)
(ensures (
parse_list_tailrec' p32 b aux == (
match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None
)))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else begin
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') ->
list_append_rev_cons v aux l
| None -> ()
end
let parse_list_tailrec'_correct
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
: Lemma
begin match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> parse_list_tailrec' p32 b [] == Some l
| None -> parse_list_tailrec' p32 b [] == None
end
= parse_list_tailrec'_correct' p32 b []
let list_rev_inv
(#t: Type)
(l: list t)
(b: bool)
(x: list t * list t)
: GTot Type0
= let (rem, acc) = x in
L.rev l == L.rev_acc rem acc /\
(b == false ==> rem == [])
let list_rev
(#t: Type)
(l: list t)
: Tot (l' : list t { l' == L.rev l } )
= match l with
| [] -> []
| _ ->
let (_, l') =
CL.total_while
(fun (rem, _) -> L.length rem)
(list_rev_inv l)
(fun (rem, acc) ->
match rem with
| [] -> (false, (rem, acc))
| a :: q -> (true, (q, a :: acc))
)
(l, [])
in
l'
let parse_list_tailrec_inv
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
(b: bool)
(x: option (bytes32 * list t))
: GTot Type0
= match x with
| Some (input', accu') ->
parse_list_tailrec' p32 input [] == parse_list_tailrec' p32 input' accu' /\
(b == false ==> B32.length input' == 0)
| None ->
b == false /\ None? (parse_list_tailrec' p32 input [])
let parse_list_tailrec_measure
(#t: Type)
(x: option (bytes32 * list t))
: GTot nat
= match x with
| None -> 0
| Some (input', _) -> B32.length input'
inline_for_extraction
let parse_list_tailrec_body
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: (x: option (bytes32 * list t)) ->
Pure (bool * option (bytes32 * list t))
(requires (parse_list_tailrec_inv p32 input true x))
(ensures (fun (continue, y) ->
parse_list_tailrec_inv p32 input continue y /\
(if continue then parse_list_tailrec_measure y < parse_list_tailrec_measure x else True)
))
= fun (x: option (bytes32 * list t)) ->
let (Some (input', accu')) = x in
let len = B32.len input' in
if len = 0ul
then (false, x)
else
match p32 input' with
| Some (v, consumed) ->
if consumed = 0ul
then (false, None)
else
let input'' = B32.slice input' consumed len in
(true, Some (input'', v :: accu'))
| None -> (false, None)
inline_for_extraction
let parse_list_tailrec
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(input: bytes32)
: Tot (res: option (list t) { res == parse_list_tailrec' p32 input [] } )
= let accu =
CL.total_while
(parse_list_tailrec_measure #t)
(parse_list_tailrec_inv p32 input)
(fun x -> parse_list_tailrec_body p32 input x)
(Some (input, []))
in
match accu with
| None -> None
| Some (_, accu') -> Some (list_rev accu')
inline_for_extraction
let parse32_list
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
: Tot (parser32 (parse_list p))
= fun (input: bytes32) -> ((
parse_list_tailrec'_correct p32 input;
parser_kind_prop_equiv parse_list_kind (parse_list p);
match parse_list_tailrec p32 input with
| None -> None
| Some res ->
Some (res, B32.len input)
) <: (res: option (list t * U32.t) { parser32_correct (parse_list p) input res } ))
let rec partial_serialize32_list'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
serializer32_correct (serialize_list p s) input res
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
let res = B32.empty_bytes in
assert (Seq.equal (B32.reveal res) (Seq.empty));
res
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let sq = partial_serialize32_list' p s s32 q in
let res = B32.append sa sq in
res
let rec partial_serialize32_list_tailrec'
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(accu: bytes32)
(input: list t)
: Ghost bytes32
(requires (
serialize_list_precond k /\ (
B32.length accu + Seq.length (serialize (serialize_list p s) input) < 4294967296
)))
(ensures (fun (res: bytes32) ->
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\
B32.reveal res == Seq.append (B32.reveal accu) (B32.reveal (partial_serialize32_list' p s s32 input))
))
(decreases input)
= match input with
| [] ->
serialize_list_nil p s;
Seq.append_empty_r (B32.reveal accu);
accu
| a :: q ->
serialize_list_cons p s a q;
let sa = s32 a in
let accu' = B32.append accu sa in
Seq.append_assoc (B32.reveal accu) (B32.reveal sa) (B32.reveal (partial_serialize32_list' p s s32 q));
partial_serialize32_list_tailrec' p s s32 accu' q
let partial_serialize32_list'_inv
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
(continue: bool)
(x: bytes32 * list t)
: GTot Type0
= serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296 /\ (
let (accu, input') = x in
B32.length accu + Seq.length (serialize (serialize_list p s) input') < 4294967296 /\
serializer32_correct
(serialize_list p s)
input
(partial_serialize32_list_tailrec' p s s32 accu input') /\
(continue == false ==> L.length input' == 0)
)
let partial_serialize32_list'_measure
(#t: Type)
(x: bytes32 * list t)
: GTot nat
= L.length (snd x)
inline_for_extraction
let partial_serialize32_list'_body
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: (x: (bytes32 * list t)) ->
Pure (bool * (bytes32 * list t))
(requires (partial_serialize32_list'_inv p s s32 input true x))
(ensures (fun (continue, y) ->
partial_serialize32_list'_inv p s s32 input continue y /\
(continue == true ==> partial_serialize32_list'_measure y < partial_serialize32_list'_measure x)
))
= fun (x: bytes32 * list t) ->
let (accu, input') = x in
match input' with
| [] -> (false, x)
| a :: q ->
[@inline_let]
let _ = serialize_list_cons p s a q in
let sa = s32 a in
let accu' = B32.append accu sa in
(true, (accu', q))
let partial_serialize32_list'_init
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(input: list t)
: Lemma
(requires (
serialize_list_precond k /\
Seq.length (serialize (serialize_list p s) input) < 4294967296
))
(ensures (
partial_serialize32_list'_inv p s s32 input true (B32.empty_bytes, input)
))
= assert (Seq.equal (B32.reveal B32.empty_bytes) Seq.empty);
Seq.append_empty_l (B32.reveal (partial_serialize32_list' p s s32 input));
assert (B32.reveal (partial_serialize32_list' p s s32 input) == B32.reveal (partial_serialize32_list_tailrec' p s s32 B32.empty_bytes input));
assert (serializer32_correct (serialize_list p s) input (partial_serialize32_list_tailrec' p s s32 B32.empty_bytes input))
inline_for_extraction
let partial_serialize32_list
(#t: Type)
(#k: parser_kind)
(p: parser k t)
(s: serializer p)
(s32: partial_serializer32 s)
(u: unit {
serialize_list_precond k
})
: Tot (partial_serializer32 (serialize_list p s))
= fun (input: list t { Seq.length (serialize (serialize_list p s) input) < 4294967296 } ) -> ((
let (res, _) =
partial_serialize32_list'_init p s s32 input;
CL.total_while
partial_serialize32_list'_measure
(partial_serialize32_list'_inv p s s32 input)
(fun x -> partial_serialize32_list'_body p s s32 input x)
(B32.empty_bytes, input)
in
res
) <: (res: bytes32 { serializer32_correct (serialize_list p s) input res }))
let size32_list_inv
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit {
serialize_list_precond k
})
(input: list t)
(continue: bool)
(accu: (U32.t * list t))
: GTot Type0
= let (len, rem) = accu in
let sz = Seq.length (serialize (serialize_list p s) input) in
if continue
then
U32.v len < U32.v u32_max /\
sz == U32.v len + Seq.length (serialize (serialize_list p s) rem)
else
size32_postcond (serialize_list p s) input len
let size32_list_measure
(#t: Type)
(accu: (U32.t * list t))
: GTot nat
= let (_, rem) = accu in
L.length rem
inline_for_extraction
let size32_list_body
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit {
serialize_list_precond k
})
(input: list t)
: (x: (U32.t * list t)) ->
Pure (bool * (U32.t * list t))
(requires (size32_list_inv s32 u input true x))
(ensures (fun (continue, y) ->
size32_list_inv s32 u input continue y /\
(continue == true ==> size32_list_measure y < size32_list_measure x)
))
= fun accu ->
let (len, rem) = accu in
match rem with
| [] ->
[@inline_let]
let _ = serialize_list_nil p s in
(false, accu)
| a :: q ->
[@inline_let]
let _ = serialize_list_cons p s a q in
let sza = s32 a in
let len' = add_overflow len sza in
if len' = u32_max
then (false, (u32_max, []))
else (true, (len', q)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Bytes.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "C.Loops",
"short_module": "CL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 8,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s32: LowParse.SLow.Base.size32 s ->
u256: u257: Prims.unit{LowParse.Spec.List.serialize_list_precond k}
-> LowParse.SLow.Base.size32 (LowParse.Spec.List.serialize_list p s) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.size32",
"Prims.unit",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.list",
"FStar.UInt32.t",
"LowParse.SLow.Base.size32_postcond",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list",
"FStar.Pervasives.Native.tuple2",
"C.Loops.total_while",
"LowParse.SLow.List.size32_list_measure",
"LowParse.SLow.List.size32_list_inv",
"LowParse.SLow.List.size32_list_body",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | false | let size32_list
(#t: Type)
(#k: parser_kind)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s)
(u: unit{serialize_list_precond k})
: Tot (size32 (serialize_list p s)) =
| fun input ->
[@@ inline_let ]let len, _ =
CL.total_while size32_list_measure
(size32_list_inv s32 u input)
(fun x -> size32_list_body s32 u input x)
(0ul, input)
in
(len <: (len: U32.t{size32_postcond (serialize_list p s) input len})) | false |
LowParse.SLow.List.fst | LowParse.SLow.List.parse_list_tailrec'_correct' | val parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma (requires True)
(ensures
(parse_list_tailrec' p32 b aux ==
(match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None)))
(decreases (B32.length b)) | val parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma (requires True)
(ensures
(parse_list_tailrec' p32 b aux ==
(match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None)))
(decreases (B32.length b)) | let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma
(requires True)
(ensures (
parse_list_tailrec' p32 b aux == (
match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None
)))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else begin
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') ->
list_append_rev_cons v aux l
| None -> ()
end | {
"file_name": "src/lowparse/LowParse.SLow.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 9,
"end_line": 77,
"start_col": 0,
"start_line": 44
} | module LowParse.SLow.List
include LowParse.Spec.List
include LowParse.SLow.Combinators
module B32 = FStar.Bytes
module U32 = FStar.UInt32
module CL = C.Loops
#set-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8"
module L = FStar.List.Tot
let rec parse_list_tailrec'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: GTot (option (list t))
(decreases (B32.length b))
= parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then
Some (L.rev aux)
else
match p32 b with
| None -> None
| Some (v, n) ->
if n = 0ul
then None (* elements cannot be empty *)
else
parse_list_tailrec' p32 (B32.slice b n (B32.len b)) (v :: aux)
let list_append_rev_cons
(#t: Type)
(v: t)
(aux l: list t)
: Lemma (L.append (L.rev (v ::aux)) l == L.append (L.rev aux) (v :: l))
= L.rev_rev' (v :: aux);
L.rev_rev' aux;
L.append_assoc (L.rev aux) [v] l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Bytes.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "C.Loops",
"short_module": "CL"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 8,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p32: LowParse.SLow.Base.parser32 p -> b: LowParse.SLow.Base.bytes32 -> aux: Prims.list t
-> FStar.Pervasives.Lemma
(ensures
LowParse.SLow.List.parse_list_tailrec' p32 b aux ==
(match
LowParse.Spec.Base.parse (LowParse.Spec.List.parse_list p) (FStar.Bytes.reveal b)
with
| FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ l _) ->
FStar.Pervasives.Native.Some (FStar.List.Tot.Base.rev aux @ l)
| FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None))
(decreases FStar.Bytes.length b) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.SLow.Base.parser32",
"LowParse.SLow.Base.bytes32",
"Prims.list",
"Prims.op_Equality",
"FStar.UInt32.t",
"FStar.Bytes.len",
"FStar.UInt32.__uint_to_t",
"FStar.List.Tot.Properties.append_l_nil",
"FStar.List.Tot.Base.rev",
"Prims.bool",
"LowParse.Spec.Base.parse",
"LowParse.Spec.List.parse_list",
"FStar.Bytes.reveal",
"LowParse.Spec.Base.consumed_length",
"LowParse.SLow.List.list_append_rev_cons",
"Prims.unit",
"LowParse.SLow.List.parse_list_tailrec'_correct'",
"Prims.Cons",
"FStar.Bytes.bytes",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"FStar.Seq.Base.slice",
"FStar.UInt32.v",
"FStar.Bytes.slice",
"LowParse.Spec.List.parse_list_eq",
"Prims.l_True",
"Prims.squash",
"FStar.Pervasives.Native.option",
"LowParse.SLow.List.parse_list_tailrec'",
"FStar.Pervasives.Native.Some",
"FStar.List.Tot.Base.append",
"FStar.Pervasives.Native.None",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec parse_list_tailrec'_correct'
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(b: bytes32)
(aux: list t)
: Lemma (requires True)
(ensures
(parse_list_tailrec' p32 b aux ==
(match parse (parse_list p) (B32.reveal b) with
| Some (l, n) -> Some (L.append (L.rev aux) l)
| None -> None)))
(decreases (B32.length b)) =
| parse_list_eq p (B32.reveal b);
if B32.len b = 0ul
then L.append_l_nil (L.rev aux)
else
match p32 b with
| None -> ()
| Some (v, n) ->
if n = 0ul
then ()
else
let s = B32.slice b n (B32.len b) in
parse_list_tailrec'_correct' p32 s (v :: aux);
match parse (parse_list p) (B32.reveal s) with
| Some (l, n') -> list_append_rev_cons v aux l
| None -> () | false |
MerkleTree.New.High.Correct.Flushing.fst | MerkleTree.New.High.Correct.Flushing.mt_flush_to_inv_preserved | val mt_flush_to_inv_preserved:
#hsz:pos ->
mt:merkle_tree{mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
idx:nat{idx >= MT?.i mt /\ idx < MT?.j mt} ->
Lemma (requires (mt_inv mt olds))
(ensures (mt_inv (mt_flush_to mt idx)
(mt_flush_to_olds #_ #(MT?.hash_fun mt) 0 (MT?.i mt) idx (MT?.j mt) olds (MT?.hs mt)))) | val mt_flush_to_inv_preserved:
#hsz:pos ->
mt:merkle_tree{mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
idx:nat{idx >= MT?.i mt /\ idx < MT?.j mt} ->
Lemma (requires (mt_inv mt olds))
(ensures (mt_inv (mt_flush_to mt idx)
(mt_flush_to_olds #_ #(MT?.hash_fun mt) 0 (MT?.i mt) idx (MT?.j mt) olds (MT?.hs mt)))) | let mt_flush_to_inv_preserved #hsz mt olds idx =
mt_flush_to_inv_preserved_ #_ #(MT?.hash_fun mt) 0 (MT?.i mt) idx (MT?.j mt) olds (MT?.hs mt);
mt_flush_to_merge_preserved #_ #(MT?.hash_fun mt) 0 (MT?.i mt) idx (MT?.j mt) olds (MT?.hs mt) | {
"file_name": "src/MerkleTree.New.High.Correct.Flushing.fst",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 96,
"end_line": 149,
"start_col": 0,
"start_line": 147
} | module MerkleTree.New.High.Correct.Flushing
open EverCrypt
open EverCrypt.Helpers
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module List = FStar.List.Tot
module S = FStar.Seq
module U32 = FStar.UInt32
module U8 = FStar.UInt8
type uint32_t = U32.t
type uint8_t = U8.t
module EHS = EverCrypt.Hash
module MTS = MerkleTree.Spec
open MerkleTree.New.High
open MerkleTree.New.High.Correct.Base
/// Correctness of flushing
val mt_flush_to_olds:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
GTot (folds:hashess #hsz {
S.length folds = 32 /\
S.equal (S.slice olds 0 lv) (S.slice folds 0 lv) /\
mt_olds_inv #hsz lv i folds})
(decreases i)
let rec mt_flush_to_olds #_ #f lv pi i j olds hs =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then olds (* no updates *)
else (let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs)
val mt_flush_to_olds_hs_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs1:hashess #hsz {S.length hs1 = 32 /\ hs_wf_elts lv hs1 pi j} ->
hs2:hashess #hsz {S.length hs2 = 32 /\ hs_wf_elts lv hs2 pi j} ->
Lemma (requires (S.equal (S.slice hs1 lv 32) (S.slice hs2 lv 32)))
(ensures (S.equal (mt_flush_to_olds #_ #f lv pi i j olds hs1)
(mt_flush_to_olds #_ #f lv pi i j olds hs2)))
(decreases i)
let rec mt_flush_to_olds_hs_equiv #_ #f lv pi i j olds hs1 hs2 =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then ()
else (assert (S.index hs1 lv == S.index hs2 lv);
let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs1 lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds_hs_equiv #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs1 hs2)
val mt_flush_to_merge_preserved:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires True)
(ensures (S.equal (merge_hs #_ #f olds hs)
(merge_hs #_ #f
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j))))
(decreases i)
#reset-options "--z3rlimit 40 --max_fuel 2"
let rec mt_flush_to_merge_preserved #_ #f lv pi i j olds hs =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then ()
else begin
let nolds = S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs lv) 0 (oi - opi))) in
let nhs = S.upd hs lv
(S.slice (S.index hs lv) (oi - opi) (j - opi)) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
hs_wf_elts_equal (lv + 1) hs nhs (pi / 2) (j / 2);
mt_flush_to_merge_preserved #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds nhs;
mt_flush_to_olds_hs_equiv #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs nhs;
assert (S.equal (merge_hs #_ #f nolds nhs)
(merge_hs #_ #f
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j)));
merge_hs_upd #_ #f olds hs lv
(S.append (S.index olds lv) (S.slice (S.index hs lv) 0 (oi - opi)))
(S.slice (S.index hs lv) (oi - opi) (j - opi));
assert (S.equal (merge_hs #_ #f olds hs) (merge_hs #_ #f nolds nhs))
end
#reset-options
val mt_flush_to_inv_preserved_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires (mt_olds_hs_inv #_ #f lv pi j olds hs))
(ensures (mt_olds_hs_inv #_ #f lv i j
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j)))
let mt_flush_to_inv_preserved_ #_ #f lv pi i j olds hs =
mt_flush_to_merge_preserved #_ #f lv pi i j olds hs;
mt_olds_hs_lth_inv_ok #_ #f lv pi j olds hs;
mt_hashes_lth_inv_equiv #_ #f lv j
(merge_hs #_ #f olds hs)
(merge_hs #_ #f (mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j));
mt_hashes_inv_equiv #_ #f lv j
(merge_hs #_ #f olds hs)
(merge_hs #_ #f (mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j))
val mt_flush_to_inv_preserved:
#hsz:pos ->
mt:merkle_tree{mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
idx:nat{idx >= MT?.i mt /\ idx < MT?.j mt} ->
Lemma (requires (mt_inv mt olds))
(ensures (mt_inv (mt_flush_to mt idx) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.Correct.Base.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Flushing.fst"
} | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
mt: MerkleTree.New.High.merkle_tree{MerkleTree.New.High.mt_wf_elts mt} ->
olds:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length olds = 32 /\
MerkleTree.New.High.Correct.Base.mt_olds_inv 0 (MT?.i mt) olds } ->
idx: Prims.nat{idx >= MT?.i mt /\ idx < MT?.j mt}
-> FStar.Pervasives.Lemma (requires MerkleTree.New.High.Correct.Base.mt_inv mt olds)
(ensures
MerkleTree.New.High.Correct.Base.mt_inv (MerkleTree.New.High.mt_flush_to mt idx)
(MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds 0
(MT?.i mt)
idx
(MT?.j mt)
olds
(MT?.hs mt))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.pos",
"MerkleTree.New.High.merkle_tree",
"MerkleTree.New.High.mt_wf_elts",
"MerkleTree.New.High.hashess",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.__proj__MT__item__i",
"Prims.nat",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"MerkleTree.New.High.__proj__MT__item__j",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_merge_preserved",
"MerkleTree.New.High.__proj__MT__item__hash_fun",
"MerkleTree.New.High.__proj__MT__item__hs",
"Prims.unit",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_inv_preserved_"
] | [] | true | false | true | false | false | let mt_flush_to_inv_preserved #hsz mt olds idx =
| mt_flush_to_inv_preserved_ #_ #(MT?.hash_fun mt) 0 (MT?.i mt) idx (MT?.j mt) olds (MT?.hs mt);
mt_flush_to_merge_preserved #_ #(MT?.hash_fun mt) 0 (MT?.i mt) idx (MT?.j mt) olds (MT?.hs mt) | false |
Hacl.Impl.P256.Compression.fst | Hacl.Impl.P256.Compression.raw_to_uncompressed | val raw_to_uncompressed: pk_raw:lbuffer uint8 64ul -> pk:lbuffer uint8 65ul -> Stack unit
(requires fun h -> live h pk /\ live h pk_raw /\ disjoint pk pk_raw)
(ensures fun h0 _ h1 -> modifies (loc pk) h0 h1 /\
as_seq h1 pk == S.pk_uncompressed_from_raw (as_seq h0 pk_raw)) | val raw_to_uncompressed: pk_raw:lbuffer uint8 64ul -> pk:lbuffer uint8 65ul -> Stack unit
(requires fun h -> live h pk /\ live h pk_raw /\ disjoint pk pk_raw)
(ensures fun h0 _ h1 -> modifies (loc pk) h0 h1 /\
as_seq h1 pk == S.pk_uncompressed_from_raw (as_seq h0 pk_raw)) | let raw_to_uncompressed pk_raw pk =
let h0 = ST.get () in
pk.(0ul) <- u8 0x04;
update_sub pk 1ul 64ul pk_raw;
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 pk) (S.pk_uncompressed_from_raw (as_seq h0 pk_raw)) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Compression.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 55,
"start_col": 0,
"start_line": 50
} | module Hacl.Impl.P256.Compression
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
module P = Hacl.Impl.P256.Point
module S = Spec.P256
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
let uncompressed_to_raw pk pk_raw =
let pk0 = pk.(0ul) in
if Lib.RawIntTypes.u8_to_UInt8 pk0 <> 0x04uy then false
else begin
copy pk_raw (sub pk 1ul 64ul);
true end
let compressed_to_raw pk pk_raw =
push_frame ();
let xa = create_felem () in
let ya = create_felem () in
let pk_xb = sub pk 1ul 32ul in
let b = P.aff_point_decompress_vartime xa ya pk in
if b then begin
let h0 = ST.get () in
update_sub pk_raw 0ul 32ul pk_xb;
let h1 = ST.get () in
update_sub_f h1 pk_raw 32ul 32ul
(fun h -> BSeq.nat_to_bytes_be 32 (as_nat h1 ya))
(fun _ -> bn_to_bytes_be4 (sub pk_raw 32ul 32ul) ya);
let h2 = ST.get () in
LSeq.eq_intro (as_seq h2 pk_raw)
(LSeq.concat #_ #32 #32 (as_seq h0 pk_xb) (BSeq.nat_to_bytes_be 32 (as_nat h0 ya))) end;
pop_frame ();
b | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt8.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.Compression.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Point",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"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": 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 | pk_raw: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 65ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Spec.P256.pk_uncompressed_from_raw",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.u8"
] | [] | false | true | false | false | false | let raw_to_uncompressed pk_raw pk =
| let h0 = ST.get () in
pk.(0ul) <- u8 0x04;
update_sub pk 1ul 64ul pk_raw;
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 pk) (S.pk_uncompressed_from_raw (as_seq h0 pk_raw)) | false |
MerkleTree.New.High.Correct.Flushing.fst | MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds_hs_equiv | val mt_flush_to_olds_hs_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs1:hashess #hsz {S.length hs1 = 32 /\ hs_wf_elts lv hs1 pi j} ->
hs2:hashess #hsz {S.length hs2 = 32 /\ hs_wf_elts lv hs2 pi j} ->
Lemma (requires (S.equal (S.slice hs1 lv 32) (S.slice hs2 lv 32)))
(ensures (S.equal (mt_flush_to_olds #_ #f lv pi i j olds hs1)
(mt_flush_to_olds #_ #f lv pi i j olds hs2)))
(decreases i) | val mt_flush_to_olds_hs_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs1:hashess #hsz {S.length hs1 = 32 /\ hs_wf_elts lv hs1 pi j} ->
hs2:hashess #hsz {S.length hs2 = 32 /\ hs_wf_elts lv hs2 pi j} ->
Lemma (requires (S.equal (S.slice hs1 lv 32) (S.slice hs2 lv 32)))
(ensures (S.equal (mt_flush_to_olds #_ #f lv pi i j olds hs1)
(mt_flush_to_olds #_ #f lv pi i j olds hs2)))
(decreases i) | let rec mt_flush_to_olds_hs_equiv #_ #f lv pi i j olds hs1 hs2 =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then ()
else (assert (S.index hs1 lv == S.index hs2 lv);
let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs1 lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds_hs_equiv #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs1 hs2) | {
"file_name": "src/MerkleTree.New.High.Correct.Flushing.fst",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 57,
"end_line": 73,
"start_col": 0,
"start_line": 62
} | module MerkleTree.New.High.Correct.Flushing
open EverCrypt
open EverCrypt.Helpers
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module List = FStar.List.Tot
module S = FStar.Seq
module U32 = FStar.UInt32
module U8 = FStar.UInt8
type uint32_t = U32.t
type uint8_t = U8.t
module EHS = EverCrypt.Hash
module MTS = MerkleTree.Spec
open MerkleTree.New.High
open MerkleTree.New.High.Correct.Base
/// Correctness of flushing
val mt_flush_to_olds:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
GTot (folds:hashess #hsz {
S.length folds = 32 /\
S.equal (S.slice olds 0 lv) (S.slice folds 0 lv) /\
mt_olds_inv #hsz lv i folds})
(decreases i)
let rec mt_flush_to_olds #_ #f lv pi i j olds hs =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then olds (* no updates *)
else (let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs)
val mt_flush_to_olds_hs_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs1:hashess #hsz {S.length hs1 = 32 /\ hs_wf_elts lv hs1 pi j} ->
hs2:hashess #hsz {S.length hs2 = 32 /\ hs_wf_elts lv hs2 pi j} ->
Lemma (requires (S.equal (S.slice hs1 lv 32) (S.slice hs2 lv 32)))
(ensures (S.equal (mt_flush_to_olds #_ #f lv pi i j olds hs1)
(mt_flush_to_olds #_ #f lv pi i j olds hs2))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.Correct.Base.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Flushing.fst"
} | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
lv: Prims.nat{lv < 32} ->
pi: Prims.nat ->
i: Prims.nat{i >= pi} ->
j: Prims.nat{j >= i /\ j < Prims.pow2 (32 - lv)} ->
olds:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length olds = 32 /\ MerkleTree.New.High.Correct.Base.mt_olds_inv lv pi olds} ->
hs1:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length hs1 = 32 /\ MerkleTree.New.High.hs_wf_elts lv hs1 pi j} ->
hs2:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length hs2 = 32 /\ MerkleTree.New.High.hs_wf_elts lv hs2 pi j}
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.equal (FStar.Seq.Base.slice hs1 lv 32) (FStar.Seq.Base.slice hs2 lv 32))
(ensures
FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds lv
pi
i
j
olds
hs1)
(MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds lv pi i j olds hs2))
(decreases i) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Prims.l_and",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.hs_wf_elts",
"Prims.bool",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds_hs_equiv",
"Prims.op_Addition",
"Prims.op_Division",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.mt_olds_inv_equiv",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.upd",
"FStar.Seq.Base.append",
"MerkleTree.New.High.hash",
"FStar.Seq.Base.index",
"FStar.Seq.Base.slice",
"Prims._assert",
"Prims.eq2",
"MerkleTree.New.High.offset_of"
] | [
"recursion"
] | false | false | true | false | false | let rec mt_flush_to_olds_hs_equiv #_ #f lv pi i j olds hs1 hs2 =
| let oi = offset_of i in
let opi = offset_of pi in
if oi = opi
then ()
else
(assert (S.index hs1 lv == S.index hs2 lv);
let nolds =
S.upd olds lv (S.append (S.index olds lv) (S.slice (S.index hs1 lv) 0 (oi - opi)))
in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds_hs_equiv #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs1 hs2) | false |
MerkleTree.New.High.Correct.Flushing.fst | MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds | val mt_flush_to_olds:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
GTot (folds:hashess #hsz {
S.length folds = 32 /\
S.equal (S.slice olds 0 lv) (S.slice folds 0 lv) /\
mt_olds_inv #hsz lv i folds})
(decreases i) | val mt_flush_to_olds:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
GTot (folds:hashess #hsz {
S.length folds = 32 /\
S.equal (S.slice olds 0 lv) (S.slice folds 0 lv) /\
mt_olds_inv #hsz lv i folds})
(decreases i) | let rec mt_flush_to_olds #_ #f lv pi i j olds hs =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then olds (* no updates *)
else (let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs) | {
"file_name": "src/MerkleTree.New.High.Correct.Flushing.fst",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 73,
"end_line": 47,
"start_col": 0,
"start_line": 38
} | module MerkleTree.New.High.Correct.Flushing
open EverCrypt
open EverCrypt.Helpers
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module List = FStar.List.Tot
module S = FStar.Seq
module U32 = FStar.UInt32
module U8 = FStar.UInt8
type uint32_t = U32.t
type uint8_t = U8.t
module EHS = EverCrypt.Hash
module MTS = MerkleTree.Spec
open MerkleTree.New.High
open MerkleTree.New.High.Correct.Base
/// Correctness of flushing
val mt_flush_to_olds:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
GTot (folds:hashess #hsz {
S.length folds = 32 /\
S.equal (S.slice olds 0 lv) (S.slice folds 0 lv) /\
mt_olds_inv #hsz lv i folds}) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.Correct.Base.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Flushing.fst"
} | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
lv: Prims.nat{lv < 32} ->
pi: Prims.nat ->
i: Prims.nat{i >= pi} ->
j: Prims.nat{j >= i /\ j < Prims.pow2 (32 - lv)} ->
olds:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length olds = 32 /\ MerkleTree.New.High.Correct.Base.mt_olds_inv lv pi olds} ->
hs:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length hs = 32 /\ MerkleTree.New.High.hs_wf_elts lv hs pi j}
-> Prims.GTot
(folds:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length folds = 32 /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice olds 0 lv) (FStar.Seq.Base.slice folds 0 lv) /\
MerkleTree.New.High.Correct.Base.mt_olds_inv lv i folds }) | Prims.GTot | [
"sometrivial",
""
] | [] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Prims.l_and",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.hs_wf_elts",
"Prims.bool",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds",
"Prims.op_Addition",
"Prims.op_Division",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.mt_olds_inv_equiv",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.upd",
"FStar.Seq.Base.append",
"MerkleTree.New.High.hash",
"FStar.Seq.Base.index",
"FStar.Seq.Base.slice",
"FStar.Seq.Base.equal",
"MerkleTree.New.High.offset_of"
] | [
"recursion"
] | false | false | false | false | false | let rec mt_flush_to_olds #_ #f lv pi i j olds hs =
| let oi = offset_of i in
let opi = offset_of pi in
if oi = opi
then olds
else
(let nolds = S.upd olds lv (S.append (S.index olds lv) (S.slice (S.index hs lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs) | false |
Hacl.Impl.P256.Compression.fst | Hacl.Impl.P256.Compression.uncompressed_to_raw | val uncompressed_to_raw: pk:lbuffer uint8 65ul -> pk_raw:lbuffer uint8 64ul -> Stack bool
(requires fun h -> live h pk /\ live h pk_raw /\ disjoint pk pk_raw)
(ensures fun h0 b h1 -> modifies (loc pk_raw) h0 h1 /\
(b <==> Some? (S.pk_uncompressed_to_raw (as_seq h0 pk))) /\
(b ==> (as_seq h1 pk_raw == Some?.v (S.pk_uncompressed_to_raw (as_seq h0 pk))))) | val uncompressed_to_raw: pk:lbuffer uint8 65ul -> pk_raw:lbuffer uint8 64ul -> Stack bool
(requires fun h -> live h pk /\ live h pk_raw /\ disjoint pk pk_raw)
(ensures fun h0 b h1 -> modifies (loc pk_raw) h0 h1 /\
(b <==> Some? (S.pk_uncompressed_to_raw (as_seq h0 pk))) /\
(b ==> (as_seq h1 pk_raw == Some?.v (S.pk_uncompressed_to_raw (as_seq h0 pk))))) | let uncompressed_to_raw pk pk_raw =
let pk0 = pk.(0ul) in
if Lib.RawIntTypes.u8_to_UInt8 pk0 <> 0x04uy then false
else begin
copy pk_raw (sub pk 1ul 64ul);
true end | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Compression.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 26,
"start_col": 0,
"start_line": 21
} | module Hacl.Impl.P256.Compression
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
module P = Hacl.Impl.P256.Point
module S = Spec.P256
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt8.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.Compression.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Point",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"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": 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 | pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 65ul -> pk_raw: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.op_disEquality",
"FStar.UInt8.t",
"Lib.RawIntTypes.u8_to_UInt8",
"FStar.UInt8.__uint_to_t",
"Prims.bool",
"Prims.unit",
"Lib.Buffer.copy",
"Lib.Buffer.MUT",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"Lib.Buffer.sub",
"Lib.Buffer.op_Array_Access"
] | [] | false | true | false | false | false | let uncompressed_to_raw pk pk_raw =
| let pk0 = pk.(0ul) in
if Lib.RawIntTypes.u8_to_UInt8 pk0 <> 0x04uy
then false
else
(copy pk_raw (sub pk 1ul 64ul);
true) | false |
Hacl.Impl.P256.Compression.fst | Hacl.Impl.P256.Compression.raw_to_compressed_get_pk0 | val raw_to_compressed_get_pk0: f:lbuffer uint8 32ul -> Stack uint8
(requires fun h -> live h f)
(ensures fun h0 b h1 -> modifies0 h0 h1 /\
v b == (if (BSeq.nat_from_bytes_be (as_seq h0 f) % 2 = 1) then 0x03 else 0x02)) | val raw_to_compressed_get_pk0: f:lbuffer uint8 32ul -> Stack uint8
(requires fun h -> live h f)
(ensures fun h0 b h1 -> modifies0 h0 h1 /\
v b == (if (BSeq.nat_from_bytes_be (as_seq h0 f) % 2 = 1) then 0x03 else 0x02)) | let raw_to_compressed_get_pk0 f =
push_frame ();
let bn_f = create_felem () in
bn_from_bytes_be4 bn_f f;
let is_odd_f = bn_is_odd4 bn_f in
pop_frame ();
to_u8 is_odd_f +! u8 0x02 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Compression.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 70,
"start_col": 0,
"start_line": 64
} | module Hacl.Impl.P256.Compression
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
module P = Hacl.Impl.P256.Point
module S = Spec.P256
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
let uncompressed_to_raw pk pk_raw =
let pk0 = pk.(0ul) in
if Lib.RawIntTypes.u8_to_UInt8 pk0 <> 0x04uy then false
else begin
copy pk_raw (sub pk 1ul 64ul);
true end
let compressed_to_raw pk pk_raw =
push_frame ();
let xa = create_felem () in
let ya = create_felem () in
let pk_xb = sub pk 1ul 32ul in
let b = P.aff_point_decompress_vartime xa ya pk in
if b then begin
let h0 = ST.get () in
update_sub pk_raw 0ul 32ul pk_xb;
let h1 = ST.get () in
update_sub_f h1 pk_raw 32ul 32ul
(fun h -> BSeq.nat_to_bytes_be 32 (as_nat h1 ya))
(fun _ -> bn_to_bytes_be4 (sub pk_raw 32ul 32ul) ya);
let h2 = ST.get () in
LSeq.eq_intro (as_seq h2 pk_raw)
(LSeq.concat #_ #32 #32 (as_seq h0 pk_xb) (BSeq.nat_to_bytes_be 32 (as_nat h0 ya))) end;
pop_frame ();
b
let raw_to_uncompressed pk_raw pk =
let h0 = ST.get () in
pk.(0ul) <- u8 0x04;
update_sub pk 1ul 64ul pk_raw;
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 pk) (S.pk_uncompressed_from_raw (as_seq h0 pk_raw))
inline_for_extraction noextract
val raw_to_compressed_get_pk0: f:lbuffer uint8 32ul -> Stack uint8
(requires fun h -> live h f)
(ensures fun h0 b h1 -> modifies0 h0 h1 /\
v b == (if (BSeq.nat_from_bytes_be (as_seq h0 f) % 2 = 1) then 0x03 else 0x02)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt8.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.Compression.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Point",
"short_module": "P"
},
{
"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": "Spec.P256",
"short_module": "S"
},
{
"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": 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 | f: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint8 | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.to_u8",
"Lib.IntTypes.U64",
"Lib.IntTypes.u8",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.int_t",
"Hacl.Impl.P256.Bignum.bn_is_odd4",
"Lib.IntTypes.uint64",
"Hacl.Impl.P256.Bignum.bn_from_bytes_be4",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let raw_to_compressed_get_pk0 f =
| push_frame ();
let bn_f = create_felem () in
bn_from_bytes_be4 bn_f f;
let is_odd_f = bn_is_odd4 bn_f in
pop_frame ();
to_u8 is_odd_f +! u8 0x02 | false |
Hacl.Impl.P256.Compression.fst | Hacl.Impl.P256.Compression.raw_to_compressed | val raw_to_compressed: pk_raw:lbuffer uint8 64ul -> pk:lbuffer uint8 33ul -> Stack unit
(requires fun h -> live h pk /\ live h pk_raw /\ disjoint pk pk_raw)
(ensures fun h0 _ h1 -> modifies (loc pk) h0 h1 /\
as_seq h1 pk == S.pk_compressed_from_raw (as_seq h0 pk_raw)) | val raw_to_compressed: pk_raw:lbuffer uint8 64ul -> pk:lbuffer uint8 33ul -> Stack unit
(requires fun h -> live h pk /\ live h pk_raw /\ disjoint pk pk_raw)
(ensures fun h0 _ h1 -> modifies (loc pk) h0 h1 /\
as_seq h1 pk == S.pk_compressed_from_raw (as_seq h0 pk_raw)) | let raw_to_compressed pk_raw pk =
let h0 = ST.get () in
let pk_x = sub pk_raw 0ul 32ul in
let pk_y = sub pk_raw 32ul 32ul in
pk.(0ul) <- raw_to_compressed_get_pk0 pk_y;
update_sub pk 1ul 32ul pk_x;
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 pk) (S.pk_compressed_from_raw (as_seq h0 pk_raw)) | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Compression.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 76,
"end_line": 80,
"start_col": 0,
"start_line": 73
} | module Hacl.Impl.P256.Compression
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
module P = Hacl.Impl.P256.Point
module S = Spec.P256
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
let uncompressed_to_raw pk pk_raw =
let pk0 = pk.(0ul) in
if Lib.RawIntTypes.u8_to_UInt8 pk0 <> 0x04uy then false
else begin
copy pk_raw (sub pk 1ul 64ul);
true end
let compressed_to_raw pk pk_raw =
push_frame ();
let xa = create_felem () in
let ya = create_felem () in
let pk_xb = sub pk 1ul 32ul in
let b = P.aff_point_decompress_vartime xa ya pk in
if b then begin
let h0 = ST.get () in
update_sub pk_raw 0ul 32ul pk_xb;
let h1 = ST.get () in
update_sub_f h1 pk_raw 32ul 32ul
(fun h -> BSeq.nat_to_bytes_be 32 (as_nat h1 ya))
(fun _ -> bn_to_bytes_be4 (sub pk_raw 32ul 32ul) ya);
let h2 = ST.get () in
LSeq.eq_intro (as_seq h2 pk_raw)
(LSeq.concat #_ #32 #32 (as_seq h0 pk_xb) (BSeq.nat_to_bytes_be 32 (as_nat h0 ya))) end;
pop_frame ();
b
let raw_to_uncompressed pk_raw pk =
let h0 = ST.get () in
pk.(0ul) <- u8 0x04;
update_sub pk 1ul 64ul pk_raw;
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 pk) (S.pk_uncompressed_from_raw (as_seq h0 pk_raw))
inline_for_extraction noextract
val raw_to_compressed_get_pk0: f:lbuffer uint8 32ul -> Stack uint8
(requires fun h -> live h f)
(ensures fun h0 b h1 -> modifies0 h0 h1 /\
v b == (if (BSeq.nat_from_bytes_be (as_seq h0 f) % 2 = 1) then 0x03 else 0x02))
let raw_to_compressed_get_pk0 f =
push_frame ();
let bn_f = create_felem () in
bn_from_bytes_be4 bn_f f;
let is_odd_f = bn_is_odd4 bn_f in
pop_frame ();
to_u8 is_odd_f +! u8 0x02 | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt8.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.Compression.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Point",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"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": 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 | pk_raw: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 33ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Spec.P256.pk_compressed_from_raw",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Hacl.Impl.P256.Compression.raw_to_compressed_get_pk0",
"Lib.Buffer.lbuffer_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub"
] | [] | false | true | false | false | false | let raw_to_compressed pk_raw pk =
| let h0 = ST.get () in
let pk_x = sub pk_raw 0ul 32ul in
let pk_y = sub pk_raw 32ul 32ul in
pk.(0ul) <- raw_to_compressed_get_pk0 pk_y;
update_sub pk 1ul 32ul pk_x;
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 pk) (S.pk_compressed_from_raw (as_seq h0 pk_raw)) | false |
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.k384_512 | val k384_512 : s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.k384_512_l == FStar.Seq.Base.length s} | let k384_512 = Seq.seq_of_list k384_512_l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 62,
"start_col": 0,
"start_line": 62
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.k384_512_l == FStar.Seq.Base.length s} | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.SHA2.Constants.k384_512_l"
] | [] | false | false | false | false | false | let k384_512 =
| Seq.seq_of_list k384_512_l | false |
|
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.k224_256 | val k224_256 : s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.k224_256_l == FStar.Seq.Base.length s} | let k224_256 = Seq.seq_of_list k224_256_l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.k224_256_l == FStar.Seq.Base.length s} | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Spec.SHA2.Constants.k224_256_l"
] | [] | false | false | false | false | false | let k224_256 =
| Seq.seq_of_list k224_256_l | false |
|
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.h224 | val h224 : s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.h224_l == FStar.Seq.Base.length s} | let h224 = Seq.seq_of_list h224_l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 77,
"start_col": 0,
"start_line": 77
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l
let k384_512 = Seq.seq_of_list k384_512_l
// H0 vectors, i.e. initial values of the accumulator
[@"opaque_to_smt"]
inline_for_extraction
let h224_l: List.llist uint32 8 =
[@inline_let]
let l = [
u32 0xc1059ed8; u32 0x367cd507; u32 0x3070dd17; u32 0xf70e5939;
u32 0xffc00b31; u32 0x68581511; u32 0x64f98fa7; u32 0xbefa4fa4
] in
assert_norm (List.length l = 8);
l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.h224_l == FStar.Seq.Base.length s} | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Spec.SHA2.Constants.h224_l"
] | [] | false | false | false | false | false | let h224 =
| Seq.seq_of_list h224_l | false |
|
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.h256 | val h256 : s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.h256_l == FStar.Seq.Base.length s} | let h256 = Seq.seq_of_list h256_l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 90,
"start_col": 0,
"start_line": 90
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l
let k384_512 = Seq.seq_of_list k384_512_l
// H0 vectors, i.e. initial values of the accumulator
[@"opaque_to_smt"]
inline_for_extraction
let h224_l: List.llist uint32 8 =
[@inline_let]
let l = [
u32 0xc1059ed8; u32 0x367cd507; u32 0x3070dd17; u32 0xf70e5939;
u32 0xffc00b31; u32 0x68581511; u32 0x64f98fa7; u32 0xbefa4fa4
] in
assert_norm (List.length l = 8);
l
let h224 = Seq.seq_of_list h224_l
[@"opaque_to_smt"]
inline_for_extraction
let h256_l: List.llist uint32 8 =
[@inline_let]
let l =
[u32 0x6a09e667; u32 0xbb67ae85; u32 0x3c6ef372; u32 0xa54ff53a;
u32 0x510e527f; u32 0x9b05688c; u32 0x1f83d9ab; u32 0x5be0cd19]
in
assert_norm (List.length l = 8);
l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.h256_l == FStar.Seq.Base.length s} | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Spec.SHA2.Constants.h256_l"
] | [] | false | false | false | false | false | let h256 =
| Seq.seq_of_list h256_l | false |
|
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.h384 | val h384 : s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.h384_l == FStar.Seq.Base.length s} | let h384 = Seq.seq_of_list h384_l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 103,
"start_col": 0,
"start_line": 103
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l
let k384_512 = Seq.seq_of_list k384_512_l
// H0 vectors, i.e. initial values of the accumulator
[@"opaque_to_smt"]
inline_for_extraction
let h224_l: List.llist uint32 8 =
[@inline_let]
let l = [
u32 0xc1059ed8; u32 0x367cd507; u32 0x3070dd17; u32 0xf70e5939;
u32 0xffc00b31; u32 0x68581511; u32 0x64f98fa7; u32 0xbefa4fa4
] in
assert_norm (List.length l = 8);
l
let h224 = Seq.seq_of_list h224_l
[@"opaque_to_smt"]
inline_for_extraction
let h256_l: List.llist uint32 8 =
[@inline_let]
let l =
[u32 0x6a09e667; u32 0xbb67ae85; u32 0x3c6ef372; u32 0xa54ff53a;
u32 0x510e527f; u32 0x9b05688c; u32 0x1f83d9ab; u32 0x5be0cd19]
in
assert_norm (List.length l = 8);
l
let h256 = Seq.seq_of_list h256_l
[@"opaque_to_smt"]
inline_for_extraction
let h384_l: List.llist uint64 8 =
[@inline_let]
let l = [
u64 0xcbbb9d5dc1059ed8; u64 0x629a292a367cd507; u64 0x9159015a3070dd17; u64 0x152fecd8f70e5939;
u64 0x67332667ffc00b31; u64 0x8eb44a8768581511; u64 0xdb0c2e0d64f98fa7; u64 0x47b5481dbefa4fa4
] in
assert_norm (List.length l = 8);
l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.h384_l == FStar.Seq.Base.length s} | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.SHA2.Constants.h384_l"
] | [] | false | false | false | false | false | let h384 =
| Seq.seq_of_list h384_l | false |
|
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.h512 | val h512 : s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.h512_l == FStar.Seq.Base.length s} | let h512 = Seq.seq_of_list h512_l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 116,
"start_col": 0,
"start_line": 116
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l
let k384_512 = Seq.seq_of_list k384_512_l
// H0 vectors, i.e. initial values of the accumulator
[@"opaque_to_smt"]
inline_for_extraction
let h224_l: List.llist uint32 8 =
[@inline_let]
let l = [
u32 0xc1059ed8; u32 0x367cd507; u32 0x3070dd17; u32 0xf70e5939;
u32 0xffc00b31; u32 0x68581511; u32 0x64f98fa7; u32 0xbefa4fa4
] in
assert_norm (List.length l = 8);
l
let h224 = Seq.seq_of_list h224_l
[@"opaque_to_smt"]
inline_for_extraction
let h256_l: List.llist uint32 8 =
[@inline_let]
let l =
[u32 0x6a09e667; u32 0xbb67ae85; u32 0x3c6ef372; u32 0xa54ff53a;
u32 0x510e527f; u32 0x9b05688c; u32 0x1f83d9ab; u32 0x5be0cd19]
in
assert_norm (List.length l = 8);
l
let h256 = Seq.seq_of_list h256_l
[@"opaque_to_smt"]
inline_for_extraction
let h384_l: List.llist uint64 8 =
[@inline_let]
let l = [
u64 0xcbbb9d5dc1059ed8; u64 0x629a292a367cd507; u64 0x9159015a3070dd17; u64 0x152fecd8f70e5939;
u64 0x67332667ffc00b31; u64 0x8eb44a8768581511; u64 0xdb0c2e0d64f98fa7; u64 0x47b5481dbefa4fa4
] in
assert_norm (List.length l = 8);
l
let h384 = Seq.seq_of_list h384_l
[@"opaque_to_smt"]
inline_for_extraction
let h512_l: List.llist uint64 8 =
[@inline_let]
let l = [
u64 0x6a09e667f3bcc908; u64 0xbb67ae8584caa73b; u64 0x3c6ef372fe94f82b; u64 0xa54ff53a5f1d36f1;
u64 0x510e527fade682d1; u64 0x9b05688c2b3e6c1f; u64 0x1f83d9abfb41bd6b; u64 0x5be0cd19137e2179
] in
assert_norm (List.length l = 8);
l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s:
FStar.Seq.Base.seq (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC)
{FStar.List.Tot.Base.length Spec.SHA2.Constants.h512_l == FStar.Seq.Base.length s} | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.SHA2.Constants.h512_l"
] | [] | false | false | false | false | false | let h512 =
| Seq.seq_of_list h512_l | false |
|
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.h224_l | val h224_l:List.llist uint32 8 | val h224_l:List.llist uint32 8 | let h224_l: List.llist uint32 8 =
[@inline_let]
let l = [
u32 0xc1059ed8; u32 0x367cd507; u32 0x3070dd17; u32 0xf70e5939;
u32 0xffc00b31; u32 0x68581511; u32 0x64f98fa7; u32 0xbefa4fa4
] in
assert_norm (List.length l = 8);
l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 75,
"start_col": 0,
"start_line": 68
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l
let k384_512 = Seq.seq_of_list k384_512_l
// H0 vectors, i.e. initial values of the accumulator
[@"opaque_to_smt"] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.List.Tot.Properties.llist (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC) 8 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u32",
"Prims.Nil"
] | [] | false | false | false | false | false | let h224_l:List.llist uint32 8 =
| [@@ inline_let ]let l =
[
u32 0xc1059ed8;
u32 0x367cd507;
u32 0x3070dd17;
u32 0xf70e5939;
u32 0xffc00b31;
u32 0x68581511;
u32 0x64f98fa7;
u32 0xbefa4fa4
]
in
assert_norm (List.length l = 8);
l | false |
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.h384_l | val h384_l:List.llist uint64 8 | val h384_l:List.llist uint64 8 | let h384_l: List.llist uint64 8 =
[@inline_let]
let l = [
u64 0xcbbb9d5dc1059ed8; u64 0x629a292a367cd507; u64 0x9159015a3070dd17; u64 0x152fecd8f70e5939;
u64 0x67332667ffc00b31; u64 0x8eb44a8768581511; u64 0xdb0c2e0d64f98fa7; u64 0x47b5481dbefa4fa4
] in
assert_norm (List.length l = 8);
l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 101,
"start_col": 0,
"start_line": 94
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l
let k384_512 = Seq.seq_of_list k384_512_l
// H0 vectors, i.e. initial values of the accumulator
[@"opaque_to_smt"]
inline_for_extraction
let h224_l: List.llist uint32 8 =
[@inline_let]
let l = [
u32 0xc1059ed8; u32 0x367cd507; u32 0x3070dd17; u32 0xf70e5939;
u32 0xffc00b31; u32 0x68581511; u32 0x64f98fa7; u32 0xbefa4fa4
] in
assert_norm (List.length l = 8);
l
let h224 = Seq.seq_of_list h224_l
[@"opaque_to_smt"]
inline_for_extraction
let h256_l: List.llist uint32 8 =
[@inline_let]
let l =
[u32 0x6a09e667; u32 0xbb67ae85; u32 0x3c6ef372; u32 0xa54ff53a;
u32 0x510e527f; u32 0x9b05688c; u32 0x1f83d9ab; u32 0x5be0cd19]
in
assert_norm (List.length l = 8);
l
let h256 = Seq.seq_of_list h256_l
[@"opaque_to_smt"] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.List.Tot.Properties.llist (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) 8 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u64",
"Prims.Nil"
] | [] | false | false | false | false | false | let h384_l:List.llist uint64 8 =
| [@@ inline_let ]let l =
[
u64 0xcbbb9d5dc1059ed8;
u64 0x629a292a367cd507;
u64 0x9159015a3070dd17;
u64 0x152fecd8f70e5939;
u64 0x67332667ffc00b31;
u64 0x8eb44a8768581511;
u64 0xdb0c2e0d64f98fa7;
u64 0x47b5481dbefa4fa4
]
in
assert_norm (List.length l = 8);
l | false |
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.h256_l | val h256_l:List.llist uint32 8 | val h256_l:List.llist uint32 8 | let h256_l: List.llist uint32 8 =
[@inline_let]
let l =
[u32 0x6a09e667; u32 0xbb67ae85; u32 0x3c6ef372; u32 0xa54ff53a;
u32 0x510e527f; u32 0x9b05688c; u32 0x1f83d9ab; u32 0x5be0cd19]
in
assert_norm (List.length l = 8);
l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 88,
"start_col": 0,
"start_line": 81
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l
let k384_512 = Seq.seq_of_list k384_512_l
// H0 vectors, i.e. initial values of the accumulator
[@"opaque_to_smt"]
inline_for_extraction
let h224_l: List.llist uint32 8 =
[@inline_let]
let l = [
u32 0xc1059ed8; u32 0x367cd507; u32 0x3070dd17; u32 0xf70e5939;
u32 0xffc00b31; u32 0x68581511; u32 0x64f98fa7; u32 0xbefa4fa4
] in
assert_norm (List.length l = 8);
l
let h224 = Seq.seq_of_list h224_l
[@"opaque_to_smt"] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.List.Tot.Properties.llist (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC) 8 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u32",
"Prims.Nil"
] | [] | false | false | false | false | false | let h256_l:List.llist uint32 8 =
| [@@ inline_let ]let l =
[
u32 0x6a09e667;
u32 0xbb67ae85;
u32 0x3c6ef372;
u32 0xa54ff53a;
u32 0x510e527f;
u32 0x9b05688c;
u32 0x1f83d9ab;
u32 0x5be0cd19
]
in
assert_norm (List.length l = 8);
l | false |
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.h512_l | val h512_l:List.llist uint64 8 | val h512_l:List.llist uint64 8 | let h512_l: List.llist uint64 8 =
[@inline_let]
let l = [
u64 0x6a09e667f3bcc908; u64 0xbb67ae8584caa73b; u64 0x3c6ef372fe94f82b; u64 0xa54ff53a5f1d36f1;
u64 0x510e527fade682d1; u64 0x9b05688c2b3e6c1f; u64 0x1f83d9abfb41bd6b; u64 0x5be0cd19137e2179
] in
assert_norm (List.length l = 8);
l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 114,
"start_col": 0,
"start_line": 107
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"]
inline_for_extraction
let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l
let k384_512 = Seq.seq_of_list k384_512_l
// H0 vectors, i.e. initial values of the accumulator
[@"opaque_to_smt"]
inline_for_extraction
let h224_l: List.llist uint32 8 =
[@inline_let]
let l = [
u32 0xc1059ed8; u32 0x367cd507; u32 0x3070dd17; u32 0xf70e5939;
u32 0xffc00b31; u32 0x68581511; u32 0x64f98fa7; u32 0xbefa4fa4
] in
assert_norm (List.length l = 8);
l
let h224 = Seq.seq_of_list h224_l
[@"opaque_to_smt"]
inline_for_extraction
let h256_l: List.llist uint32 8 =
[@inline_let]
let l =
[u32 0x6a09e667; u32 0xbb67ae85; u32 0x3c6ef372; u32 0xa54ff53a;
u32 0x510e527f; u32 0x9b05688c; u32 0x1f83d9ab; u32 0x5be0cd19]
in
assert_norm (List.length l = 8);
l
let h256 = Seq.seq_of_list h256_l
[@"opaque_to_smt"]
inline_for_extraction
let h384_l: List.llist uint64 8 =
[@inline_let]
let l = [
u64 0xcbbb9d5dc1059ed8; u64 0x629a292a367cd507; u64 0x9159015a3070dd17; u64 0x152fecd8f70e5939;
u64 0x67332667ffc00b31; u64 0x8eb44a8768581511; u64 0xdb0c2e0d64f98fa7; u64 0x47b5481dbefa4fa4
] in
assert_norm (List.length l = 8);
l
let h384 = Seq.seq_of_list h384_l
[@"opaque_to_smt"] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.List.Tot.Properties.llist (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) 8 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u64",
"Prims.Nil"
] | [] | false | false | false | false | false | let h512_l:List.llist uint64 8 =
| [@@ inline_let ]let l =
[
u64 0x6a09e667f3bcc908;
u64 0xbb67ae8584caa73b;
u64 0x3c6ef372fe94f82b;
u64 0xa54ff53a5f1d36f1;
u64 0x510e527fade682d1;
u64 0x9b05688c2b3e6c1f;
u64 0x1f83d9abfb41bd6b;
u64 0x5be0cd19137e2179
]
in
assert_norm (List.length l = 8);
l | false |
MerkleTree.New.High.Correct.Flushing.fst | MerkleTree.New.High.Correct.Flushing.mt_flush_to_merge_preserved | val mt_flush_to_merge_preserved:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires True)
(ensures (S.equal (merge_hs #_ #f olds hs)
(merge_hs #_ #f
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j))))
(decreases i) | val mt_flush_to_merge_preserved:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires True)
(ensures (S.equal (merge_hs #_ #f olds hs)
(merge_hs #_ #f
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j))))
(decreases i) | let rec mt_flush_to_merge_preserved #_ #f lv pi i j olds hs =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then ()
else begin
let nolds = S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs lv) 0 (oi - opi))) in
let nhs = S.upd hs lv
(S.slice (S.index hs lv) (oi - opi) (j - opi)) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
hs_wf_elts_equal (lv + 1) hs nhs (pi / 2) (j / 2);
mt_flush_to_merge_preserved #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds nhs;
mt_flush_to_olds_hs_equiv #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs nhs;
assert (S.equal (merge_hs #_ #f nolds nhs)
(merge_hs #_ #f
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j)));
merge_hs_upd #_ #f olds hs lv
(S.append (S.index olds lv) (S.slice (S.index hs lv) 0 (oi - opi)))
(S.slice (S.index hs lv) (oi - opi) (j - opi));
assert (S.equal (merge_hs #_ #f olds hs) (merge_hs #_ #f nolds nhs))
end | {
"file_name": "src/MerkleTree.New.High.Correct.Flushing.fst",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 5,
"end_line": 113,
"start_col": 0,
"start_line": 89
} | module MerkleTree.New.High.Correct.Flushing
open EverCrypt
open EverCrypt.Helpers
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module List = FStar.List.Tot
module S = FStar.Seq
module U32 = FStar.UInt32
module U8 = FStar.UInt8
type uint32_t = U32.t
type uint8_t = U8.t
module EHS = EverCrypt.Hash
module MTS = MerkleTree.Spec
open MerkleTree.New.High
open MerkleTree.New.High.Correct.Base
/// Correctness of flushing
val mt_flush_to_olds:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
GTot (folds:hashess #hsz {
S.length folds = 32 /\
S.equal (S.slice olds 0 lv) (S.slice folds 0 lv) /\
mt_olds_inv #hsz lv i folds})
(decreases i)
let rec mt_flush_to_olds #_ #f lv pi i j olds hs =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then olds (* no updates *)
else (let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs)
val mt_flush_to_olds_hs_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat ->
i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs1:hashess #hsz {S.length hs1 = 32 /\ hs_wf_elts lv hs1 pi j} ->
hs2:hashess #hsz {S.length hs2 = 32 /\ hs_wf_elts lv hs2 pi j} ->
Lemma (requires (S.equal (S.slice hs1 lv 32) (S.slice hs2 lv 32)))
(ensures (S.equal (mt_flush_to_olds #_ #f lv pi i j olds hs1)
(mt_flush_to_olds #_ #f lv pi i j olds hs2)))
(decreases i)
let rec mt_flush_to_olds_hs_equiv #_ #f lv pi i j olds hs1 hs2 =
let oi = offset_of i in
let opi = offset_of pi in
if oi = opi then ()
else (assert (S.index hs1 lv == S.index hs2 lv);
let nolds =
S.upd olds lv
(S.append (S.index olds lv)
(S.slice (S.index hs1 lv) 0 (oi - opi))) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
mt_flush_to_olds_hs_equiv #_ #f
(lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs1 hs2)
val mt_flush_to_merge_preserved:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
pi:nat -> i:nat{i >= pi} ->
j:nat{j >= i /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv pi olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts lv hs pi j} ->
Lemma (requires True)
(ensures (S.equal (merge_hs #_ #f olds hs)
(merge_hs #_ #f
(mt_flush_to_olds #_ #f lv pi i j olds hs)
(mt_flush_to_ lv hs pi i j))))
(decreases i) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.Correct.Base.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"EverCrypt.Helpers.fsti.checked",
"EverCrypt.Hash.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Flushing.fst"
} | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "EHS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
lv: Prims.nat{lv < 32} ->
pi: Prims.nat ->
i: Prims.nat{i >= pi} ->
j: Prims.nat{j >= i /\ j < Prims.pow2 (32 - lv)} ->
olds:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length olds = 32 /\ MerkleTree.New.High.Correct.Base.mt_olds_inv lv pi olds} ->
hs:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length hs = 32 /\ MerkleTree.New.High.hs_wf_elts lv hs pi j}
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Base.merge_hs olds hs)
(MerkleTree.New.High.Correct.Base.merge_hs (MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds
lv
pi
i
j
olds
hs)
(MerkleTree.New.High.mt_flush_to_ lv hs pi i j))) (decreases i) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Prims.l_and",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.hs_wf_elts",
"Prims.bool",
"Prims._assert",
"FStar.Seq.Base.equal",
"MerkleTree.New.High.Correct.Base.merge_hs",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.merge_hs_upd",
"FStar.Seq.Base.append",
"MerkleTree.New.High.hash",
"FStar.Seq.Base.index",
"FStar.Seq.Base.slice",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds",
"MerkleTree.New.High.mt_flush_to_",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_olds_hs_equiv",
"Prims.op_Addition",
"Prims.op_Division",
"MerkleTree.New.High.Correct.Flushing.mt_flush_to_merge_preserved",
"MerkleTree.New.High.hs_wf_elts_equal",
"MerkleTree.New.High.Correct.Base.mt_olds_inv_equiv",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.upd",
"MerkleTree.New.High.offset_of"
] | [
"recursion"
] | false | false | true | false | false | let rec mt_flush_to_merge_preserved #_ #f lv pi i j olds hs =
| let oi = offset_of i in
let opi = offset_of pi in
if oi = opi
then ()
else
let nolds = S.upd olds lv (S.append (S.index olds lv) (S.slice (S.index hs lv) 0 (oi - opi))) in
let nhs = S.upd hs lv (S.slice (S.index hs lv) (oi - opi) (j - opi)) in
mt_olds_inv_equiv #_ #f (lv + 1) (pi / 2) olds nolds;
hs_wf_elts_equal (lv + 1) hs nhs (pi / 2) (j / 2);
mt_flush_to_merge_preserved #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds nhs;
mt_flush_to_olds_hs_equiv #_ #f (lv + 1) (pi / 2) (i / 2) (j / 2) nolds hs nhs;
assert (S.equal (merge_hs #_ #f nolds nhs)
(merge_hs #_ #f (mt_flush_to_olds #_ #f lv pi i j olds hs) (mt_flush_to_ lv hs pi i j)));
merge_hs_upd #_
#f
olds
hs
lv
(S.append (S.index olds lv) (S.slice (S.index hs lv) 0 (oi - opi)))
(S.slice (S.index hs lv) (oi - opi) (j - opi));
assert (S.equal (merge_hs #_ #f olds hs) (merge_hs #_ #f nolds nhs)) | false |
Hacl.Impl.P256.Compression.fst | Hacl.Impl.P256.Compression.compressed_to_raw | val compressed_to_raw: pk:lbuffer uint8 33ul -> pk_raw:lbuffer uint8 64ul -> Stack bool
(requires fun h -> live h pk /\ live h pk_raw /\ disjoint pk pk_raw)
(ensures fun h0 b h1 -> modifies (loc pk_raw) h0 h1 /\
(b <==> Some? (S.pk_compressed_to_raw (as_seq h0 pk))) /\
(b ==> (as_seq h1 pk_raw == Some?.v (S.pk_compressed_to_raw (as_seq h0 pk))))) | val compressed_to_raw: pk:lbuffer uint8 33ul -> pk_raw:lbuffer uint8 64ul -> Stack bool
(requires fun h -> live h pk /\ live h pk_raw /\ disjoint pk pk_raw)
(ensures fun h0 b h1 -> modifies (loc pk_raw) h0 h1 /\
(b <==> Some? (S.pk_compressed_to_raw (as_seq h0 pk))) /\
(b ==> (as_seq h1 pk_raw == Some?.v (S.pk_compressed_to_raw (as_seq h0 pk))))) | let compressed_to_raw pk pk_raw =
push_frame ();
let xa = create_felem () in
let ya = create_felem () in
let pk_xb = sub pk 1ul 32ul in
let b = P.aff_point_decompress_vartime xa ya pk in
if b then begin
let h0 = ST.get () in
update_sub pk_raw 0ul 32ul pk_xb;
let h1 = ST.get () in
update_sub_f h1 pk_raw 32ul 32ul
(fun h -> BSeq.nat_to_bytes_be 32 (as_nat h1 ya))
(fun _ -> bn_to_bytes_be4 (sub pk_raw 32ul 32ul) ya);
let h2 = ST.get () in
LSeq.eq_intro (as_seq h2 pk_raw)
(LSeq.concat #_ #32 #32 (as_seq h0 pk_xb) (BSeq.nat_to_bytes_be 32 (as_nat h0 ya))) end;
pop_frame ();
b | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Compression.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 47,
"start_col": 0,
"start_line": 29
} | module Hacl.Impl.P256.Compression
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
module P = Hacl.Impl.P256.Point
module S = Spec.P256
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
let uncompressed_to_raw pk pk_raw =
let pk0 = pk.(0ul) in
if Lib.RawIntTypes.u8_to_UInt8 pk0 <> 0x04uy then false
else begin
copy pk_raw (sub pk 1ul 64ul);
true end | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt8.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.Compression.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.P256.Point",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"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": 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 | pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 33ul -> pk_raw: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Sequence.concat",
"Lib.ByteSequence.nat_to_bytes_be",
"Lib.IntTypes.SEC",
"Hacl.Impl.P256.Bignum.as_nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub_f",
"Lib.Sequence.lseq",
"Hacl.Impl.P256.Bignum.bn_to_bytes_be4",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Lib.Buffer.update_sub",
"Hacl.Impl.P256.Point.aff_point_decompress_vartime",
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let compressed_to_raw pk pk_raw =
| push_frame ();
let xa = create_felem () in
let ya = create_felem () in
let pk_xb = sub pk 1ul 32ul in
let b = P.aff_point_decompress_vartime xa ya pk in
if b
then
(let h0 = ST.get () in
update_sub pk_raw 0ul 32ul pk_xb;
let h1 = ST.get () in
update_sub_f h1
pk_raw
32ul
32ul
(fun h -> BSeq.nat_to_bytes_be 32 (as_nat h1 ya))
(fun _ -> bn_to_bytes_be4 (sub pk_raw 32ul 32ul) ya);
let h2 = ST.get () in
LSeq.eq_intro (as_seq h2 pk_raw)
(LSeq.concat #_ #32 #32 (as_seq h0 pk_xb) (BSeq.nat_to_bytes_be 32 (as_nat h0 ya))));
pop_frame ();
b | false |
Steel.ST.OnRange.fst | Steel.ST.OnRange.on_range | val on_range (p: (nat -> vprop)) (i j: nat) : vprop | val on_range (p: (nat -> vprop)) (i j: nat) : vprop | let rec on_range
(p: (nat -> vprop))
(i j: nat)
: Tot vprop
(decreases (if j <= i then 0 else j - i))
= if j < i
then pure False
else if j = i
then emp
else p i `star` on_range p (i + 1) j | {
"file_name": "lib/steel/Steel.ST.OnRange.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 38,
"end_line": 13,
"start_col": 0,
"start_line": 4
} | module Steel.ST.OnRange
open Steel.ST.GenElim | {
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.OnRange.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat
-> Prims.Tot Steel.Effect.Common.vprop | Prims.Tot | [
"",
"total"
] | [] | [
"Prims.nat",
"Steel.Effect.Common.vprop",
"Prims.op_LessThan",
"Steel.ST.Util.pure",
"Prims.l_False",
"Prims.bool",
"Prims.op_Equality",
"Steel.Effect.Common.emp",
"Steel.Effect.Common.star",
"Steel.ST.OnRange.on_range",
"Prims.op_Addition"
] | [
"recursion"
] | false | false | false | true | false | let rec on_range (p: (nat -> vprop)) (i j: nat)
: Tot vprop (decreases (if j <= i then 0 else j - i)) =
| if j < i then pure False else if j = i then emp else (p i) `star` (on_range p (i + 1) j) | false |
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.k224_256_l | val k224_256_l:List.llist uint32 64 | val k224_256_l:List.llist uint32 64 | let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 29,
"start_col": 0,
"start_line": 9
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.List.Tot.Properties.llist (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC) 64 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u32",
"Prims.Nil"
] | [] | false | false | false | false | false | let k224_256_l:List.llist uint32 64 =
| [@@ inline_let ]let l =
[
u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5; u32 0x3956c25b; u32 0x59f111f1;
u32 0x923f82a4; u32 0xab1c5ed5; u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174; u32 0xe49b69c1; u32 0xefbe4786;
u32 0x0fc19dc6; u32 0x240ca1cc; u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7; u32 0xc6e00bf3; u32 0xd5a79147;
u32 0x06ca6351; u32 0x14292967; u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85; u32 0xa2bfe8a1; u32 0xa81a664b;
u32 0xc24b8b70; u32 0xc76c51a3; u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5; u32 0x391c0cb3; u32 0x4ed8aa4a;
u32 0x5b9cca4f; u32 0x682e6ff3; u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2
]
in
assert_norm (List.length l = 64);
l | false |
Steel.ST.OnRange.fst | Steel.ST.OnRange.on_range_empty | val on_range_empty
(#opened: _)
(p: (nat -> vprop))
(i: nat)
(j: nat)
: STGhost unit opened
emp
(fun _ -> on_range p i j)
(i == j)
(fun _ -> True) | val on_range_empty
(#opened: _)
(p: (nat -> vprop))
(i: nat)
(j: nat)
: STGhost unit opened
emp
(fun _ -> on_range p i j)
(i == j)
(fun _ -> True) | let on_range_empty
p i j
= rewrite emp (on_range p i j) | {
"file_name": "lib/steel/Steel.ST.OnRange.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 30,
"end_line": 28,
"start_col": 0,
"start_line": 26
} | module Steel.ST.OnRange
open Steel.ST.GenElim
let rec on_range
(p: (nat -> vprop))
(i j: nat)
: Tot vprop
(decreases (if j <= i then 0 else j - i))
= if j < i
then pure False
else if j = i
then emp
else p i `star` on_range p (i + 1) j
let on_range_le
p i j
= if i <= j
then noop ()
else begin
rewrite (on_range p i j) (pure False);
let _ = gen_elim () in
rewrite emp (on_range p i j); // by contradiction
noop ()
end | {
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.OnRange.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat
-> Steel.ST.Effect.Ghost.STGhost Prims.unit | Steel.ST.Effect.Ghost.STGhost | [] | [] | [
"Steel.Memory.inames",
"Prims.nat",
"Steel.Effect.Common.vprop",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.emp",
"Steel.ST.OnRange.on_range",
"Prims.unit"
] | [] | false | true | false | false | false | let on_range_empty p i j =
| rewrite emp (on_range p i j) | false |
Steel.ST.OnRange.fst | Steel.ST.OnRange.on_range_singleton_elim | val on_range_singleton_elim
(#opened: _)
(p: (nat -> vprop))
(i j: nat)
: STGhost unit opened
(on_range p i j)
(fun _ -> p i)
(j == i + 1)
(fun _ -> True) | val on_range_singleton_elim
(#opened: _)
(p: (nat -> vprop))
(i j: nat)
: STGhost unit opened
(on_range p i j)
(fun _ -> p i)
(j == i + 1)
(fun _ -> True) | let on_range_singleton_elim
p i j
= rewrite (on_range p i j) (p i `star` emp) | {
"file_name": "lib/steel/Steel.ST.OnRange.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 43,
"end_line": 36,
"start_col": 0,
"start_line": 34
} | module Steel.ST.OnRange
open Steel.ST.GenElim
let rec on_range
(p: (nat -> vprop))
(i j: nat)
: Tot vprop
(decreases (if j <= i then 0 else j - i))
= if j < i
then pure False
else if j = i
then emp
else p i `star` on_range p (i + 1) j
let on_range_le
p i j
= if i <= j
then noop ()
else begin
rewrite (on_range p i j) (pure False);
let _ = gen_elim () in
rewrite emp (on_range p i j); // by contradiction
noop ()
end
let on_range_empty
p i j
= rewrite emp (on_range p i j)
let on_range_singleton_intro
p i j
= rewrite (p i `star` emp) (on_range p i j) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.OnRange.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat
-> Steel.ST.Effect.Ghost.STGhost Prims.unit | Steel.ST.Effect.Ghost.STGhost | [] | [] | [
"Steel.Memory.inames",
"Prims.nat",
"Steel.Effect.Common.vprop",
"Steel.ST.Util.rewrite",
"Steel.ST.OnRange.on_range",
"Steel.Effect.Common.star",
"Steel.Effect.Common.emp",
"Prims.unit"
] | [] | false | true | false | false | false | let on_range_singleton_elim p i j =
| rewrite (on_range p i j) ((p i) `star` emp) | false |
Steel.ST.OnRange.fst | Steel.ST.OnRange.on_range_singleton_intro | val on_range_singleton_intro
(#opened: _)
(p: (nat -> vprop))
(i: nat)
(j: nat)
: STGhost unit opened
(p i)
(fun _ -> on_range p i j)
(j == i + 1)
(fun _ -> True) | val on_range_singleton_intro
(#opened: _)
(p: (nat -> vprop))
(i: nat)
(j: nat)
: STGhost unit opened
(p i)
(fun _ -> on_range p i j)
(j == i + 1)
(fun _ -> True) | let on_range_singleton_intro
p i j
= rewrite (p i `star` emp) (on_range p i j) | {
"file_name": "lib/steel/Steel.ST.OnRange.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 43,
"end_line": 32,
"start_col": 0,
"start_line": 30
} | module Steel.ST.OnRange
open Steel.ST.GenElim
let rec on_range
(p: (nat -> vprop))
(i j: nat)
: Tot vprop
(decreases (if j <= i then 0 else j - i))
= if j < i
then pure False
else if j = i
then emp
else p i `star` on_range p (i + 1) j
let on_range_le
p i j
= if i <= j
then noop ()
else begin
rewrite (on_range p i j) (pure False);
let _ = gen_elim () in
rewrite emp (on_range p i j); // by contradiction
noop ()
end
let on_range_empty
p i j
= rewrite emp (on_range p i j) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.OnRange.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: (_: Prims.nat -> Steel.Effect.Common.vprop) -> i: Prims.nat -> j: Prims.nat
-> Steel.ST.Effect.Ghost.STGhost Prims.unit | Steel.ST.Effect.Ghost.STGhost | [] | [] | [
"Steel.Memory.inames",
"Prims.nat",
"Steel.Effect.Common.vprop",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.star",
"Steel.Effect.Common.emp",
"Steel.ST.OnRange.on_range",
"Prims.unit"
] | [] | false | true | false | false | false | let on_range_singleton_intro p i j =
| rewrite ((p i) `star` emp) (on_range p i j) | false |
FStar.UInt64.fst | FStar.UInt64.v | val v (x:t) : Tot (uint_t n) | val v (x:t) : Tot (uint_t n) | let v x = x.v | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 28,
"start_col": 0,
"start_line": 28
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt64.t -> FStar.UInt.uint_t FStar.UInt64.n | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.__proj__Mk__item__v",
"FStar.UInt.uint_t",
"FStar.UInt64.n"
] | [] | false | false | false | true | false | let v x =
| x.v | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_check_modulus_u32 | val bn_check_modulus_u32 (len: BN.meta_len U32) : bn_check_modulus_st U32 len | val bn_check_modulus_u32 (len: BN.meta_len U32) : bn_check_modulus_st U32 len | let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 182,
"start_col": 0,
"start_line": 181
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U32
-> Hacl.Bignum.Montgomery.bn_check_modulus_st Lib.IntTypes.U32 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U32",
"Hacl.Bignum.Montgomery.bn_check_modulus",
"Hacl.Bignum.Montgomery.bn_check_modulus_st"
] | [] | false | false | false | false | false | let bn_check_modulus_u32 (len: BN.meta_len U32) : bn_check_modulus_st U32 len =
| bn_check_modulus #U32 #len | false |
FStar.UInt64.fst | FStar.UInt64.uint_to_t | val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x)) | val uint_to_t (x:uint_t n) : Pure t
(requires True)
(ensures (fun y -> v y = x)) | let uint_to_t x = Mk x | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 22,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt.uint_t FStar.UInt64.n -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt.uint_t",
"FStar.UInt64.n",
"FStar.UInt64.Mk",
"FStar.UInt64.t"
] | [] | false | false | false | false | false | let uint_to_t x =
| Mk x | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_check_modulus_u64 | val bn_check_modulus_u64 (len: BN.meta_len U64) : bn_check_modulus_st U64 len | val bn_check_modulus_u64 (len: BN.meta_len U64) : bn_check_modulus_st U64 len | let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 210,
"start_col": 0,
"start_line": 209
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U64
-> Hacl.Bignum.Montgomery.bn_check_modulus_st Lib.IntTypes.U64 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U64",
"Hacl.Bignum.Montgomery.bn_check_modulus",
"Hacl.Bignum.Montgomery.bn_check_modulus_st"
] | [] | false | false | false | false | false | let bn_check_modulus_u64 (len: BN.meta_len U64) : bn_check_modulus_st U64 len =
| bn_check_modulus #U64 #len | false |
FStar.UInt64.fst | FStar.UInt64.add_underspec | val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c)) | val add_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a + v b) n ==> v a + v b = v c)) | let add_underspec a b = Mk (add_underspec (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 45,
"start_col": 0,
"start_line": 45
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.add_underspec",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let add_underspec a b =
| Mk (add_underspec (v a) (v b)) | false |
FStar.UInt64.fst | FStar.UInt64.one | val one : x:t{v x = 1} | val one : x:t{v x = 1} | let one = uint_to_t 1 | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 21,
"end_line": 41,
"start_col": 0,
"start_line": 41
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt64.t{FStar.UInt64.v x = 1} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt64.uint_to_t"
] | [] | false | false | false | false | false | let one =
| uint_to_t 1 | false |
FStar.UInt64.fst | FStar.UInt64.zero | val zero : x:t{v x = 0} | val zero : x:t{v x = 0} | let zero = uint_to_t 0 | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 22,
"end_line": 39,
"start_col": 0,
"start_line": 39
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt64.t{FStar.UInt64.v x = 0} | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt64.uint_to_t"
] | [] | false | false | false | false | false | let zero =
| uint_to_t 0 | false |
FStar.UInt64.fst | FStar.UInt64.add | val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c)) | val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c)) | let add a b = Mk (add (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 43,
"start_col": 0,
"start_line": 43
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.add",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let add a b =
| Mk (add (v a) (v b)) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_reduction_loop_div_r_st | val bn_mont_reduction_loop_div_r_st : t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v len /\
Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t }
-> Type0 | let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 89,
"end_line": 104,
"start_col": 0,
"start_line": 94
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v len /\
Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t }
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.Montgomery.bn_mont_reduction_loop_div_r"
] | [] | false | false | false | false | true | let bn_mont_reduction_loop_div_r_st
(t: limb_t)
(len: size_t{0 < v len /\ v len + v len <= max_size_t})
=
| n: lbignum t len -> mu: limb t -> c: lbignum t (len +! len) -> res: lbignum t len
-> Stack (carry t)
(requires
fun h ->
live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures
fun h0 c0 h1 ->
modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) | false |
|
FStar.UInt64.fst | FStar.UInt64.add_mod | val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) | val add_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) | let add_mod a b = Mk (add_mod (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 47,
"start_col": 0,
"start_line": 47
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.add_mod",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let add_mod a b =
| Mk (add_mod (v a) (v b)) | false |
FStar.UInt64.fst | FStar.UInt64.sub | val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c)) | val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c)) | let sub a b = Mk (sub (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 49,
"start_col": 0,
"start_line": 49
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.sub",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let sub a b =
| Mk (sub (v a) (v b)) | false |
FStar.UInt64.fst | FStar.UInt64.sub_underspec | val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c)) | val sub_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a - v b) n ==> v a - v b = v c)) | let sub_underspec a b = Mk (sub_underspec (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 51,
"start_col": 0,
"start_line": 51
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.sub_underspec",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let sub_underspec a b =
| Mk (sub_underspec (v a) (v b)) | false |
FStar.UInt64.fst | FStar.UInt64.sub_mod | val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) | val sub_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) | let sub_mod a b = Mk (sub_mod (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 53,
"start_col": 0,
"start_line": 53
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.sub_mod",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let sub_mod a b =
| Mk (sub_mod (v a) (v b)) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_precomp | val bn_mont_precomp:
#t:limb_t
-> len:BN.meta_len t
-> precompr2:bn_precomp_r2_mod_n_st t len ->
bn_mont_precomp_st t len | val bn_mont_precomp:
#t:limb_t
-> len:BN.meta_len t
-> precompr2:bn_precomp_r2_mod_n_st t len ->
bn_mont_precomp_st t len | let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 56,
"start_col": 0,
"start_line": 54
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len t -> precompr2: Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st t len
-> Hacl.Bignum.Montgomery.bn_mont_precomp_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.ModInvLimb.mod_inv_limb",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"FStar.UInt32.__uint_to_t",
"Prims.unit"
] | [] | false | false | false | false | false | let bn_mont_precomp #t len precompr2 nBits n r2 =
| precompr2 nBits n r2;
mod_inv_limb n.(0ul) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_u32 | val bn_precomp_r2_mod_n_u32 (len: BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len | val bn_precomp_r2_mod_n_u32 (len: BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len | let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 184,
"start_col": 0,
"start_line": 183
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U32
-> Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st Lib.IntTypes.U32 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U32",
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st"
] | [] | false | false | false | false | false | let bn_precomp_r2_mod_n_u32 (len: BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
| bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) | false |
FStar.UInt64.fst | FStar.UInt64.mul_underspec | val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c)) | val mul_underspec (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c ->
size (v a * v b) n ==> v a * v b = v c)) | let mul_underspec a b = Mk (mul_underspec (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 57,
"start_col": 0,
"start_line": 57
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.mul_underspec",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let mul_underspec a b =
| Mk (mul_underspec (v a) (v b)) | false |
FStar.UInt64.fst | FStar.UInt64.mul | val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c)) | val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c)) | let mul a b = Mk (mul (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 55,
"start_col": 0,
"start_line": 55
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.mul",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let mul a b =
| Mk (mul (v a) (v b)) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_check_modulus | val bn_check_modulus: #t:limb_t -> #len:BN.meta_len t -> bn_check_modulus_st t len | val bn_check_modulus: #t:limb_t -> #len:BN.meta_len t -> bn_check_modulus_st t len | let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 35,
"start_col": 0,
"start_line": 26
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | Hacl.Bignum.Montgomery.bn_check_modulus_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Amp_Dot",
"Hacl.Bignum.bn_lt_mask",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.uint",
"Hacl.Bignum.bn_is_odd",
"Hacl.Bignum.bn_from_uint",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.create",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let bn_check_modulus #t #len n =
| push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m | false |
Spec.SHA2.Constants.fst | Spec.SHA2.Constants.k384_512_l | val k384_512_l:List.llist uint64 80 | val k384_512_l:List.llist uint64 80 | let k384_512_l: List.llist uint64 80 =
[@inline_let]
let l =
[u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
] in
assert_norm (List.length l = 80);
l | {
"file_name": "specs/Spec.SHA2.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 60,
"start_col": 0,
"start_line": 35
} | module Spec.SHA2.Constants
#set-options "--z3rlimit 100"
open Lib.IntTypes
// K shuffling vectors
[@"opaque_to_smt"]
inline_for_extraction
let k224_256_l: List.llist uint32 64 =
[@inline_let]
let l =
[u32 0x428a2f98; u32 0x71374491; u32 0xb5c0fbcf; u32 0xe9b5dba5;
u32 0x3956c25b; u32 0x59f111f1; u32 0x923f82a4; u32 0xab1c5ed5;
u32 0xd807aa98; u32 0x12835b01; u32 0x243185be; u32 0x550c7dc3;
u32 0x72be5d74; u32 0x80deb1fe; u32 0x9bdc06a7; u32 0xc19bf174;
u32 0xe49b69c1; u32 0xefbe4786; u32 0x0fc19dc6; u32 0x240ca1cc;
u32 0x2de92c6f; u32 0x4a7484aa; u32 0x5cb0a9dc; u32 0x76f988da;
u32 0x983e5152; u32 0xa831c66d; u32 0xb00327c8; u32 0xbf597fc7;
u32 0xc6e00bf3; u32 0xd5a79147; u32 0x06ca6351; u32 0x14292967;
u32 0x27b70a85; u32 0x2e1b2138; u32 0x4d2c6dfc; u32 0x53380d13;
u32 0x650a7354; u32 0x766a0abb; u32 0x81c2c92e; u32 0x92722c85;
u32 0xa2bfe8a1; u32 0xa81a664b; u32 0xc24b8b70; u32 0xc76c51a3;
u32 0xd192e819; u32 0xd6990624; u32 0xf40e3585; u32 0x106aa070;
u32 0x19a4c116; u32 0x1e376c08; u32 0x2748774c; u32 0x34b0bcb5;
u32 0x391c0cb3; u32 0x4ed8aa4a; u32 0x5b9cca4f; u32 0x682e6ff3;
u32 0x748f82ee; u32 0x78a5636f; u32 0x84c87814; u32 0x8cc70208;
u32 0x90befffa; u32 0xa4506ceb; u32 0xbef9a3f7; u32 0xc67178f2] in
assert_norm (List.length l = 64);
l
let k224_256 = Seq.seq_of_list k224_256_l
[@"opaque_to_smt"] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA2.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.List.Tot.Properties.llist (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) 80 | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.list",
"Prims.Cons",
"Lib.IntTypes.u64",
"Prims.Nil"
] | [] | false | false | false | false | false | let k384_512_l:List.llist uint64 80 =
| [@@ inline_let ]let l =
[
u64 0x428a2f98d728ae22; u64 0x7137449123ef65cd; u64 0xb5c0fbcfec4d3b2f; u64 0xe9b5dba58189dbbc;
u64 0x3956c25bf348b538; u64 0x59f111f1b605d019; u64 0x923f82a4af194f9b; u64 0xab1c5ed5da6d8118;
u64 0xd807aa98a3030242; u64 0x12835b0145706fbe; u64 0x243185be4ee4b28c; u64 0x550c7dc3d5ffb4e2;
u64 0x72be5d74f27b896f; u64 0x80deb1fe3b1696b1; u64 0x9bdc06a725c71235; u64 0xc19bf174cf692694;
u64 0xe49b69c19ef14ad2; u64 0xefbe4786384f25e3; u64 0x0fc19dc68b8cd5b5; u64 0x240ca1cc77ac9c65;
u64 0x2de92c6f592b0275; u64 0x4a7484aa6ea6e483; u64 0x5cb0a9dcbd41fbd4; u64 0x76f988da831153b5;
u64 0x983e5152ee66dfab; u64 0xa831c66d2db43210; u64 0xb00327c898fb213f; u64 0xbf597fc7beef0ee4;
u64 0xc6e00bf33da88fc2; u64 0xd5a79147930aa725; u64 0x06ca6351e003826f; u64 0x142929670a0e6e70;
u64 0x27b70a8546d22ffc; u64 0x2e1b21385c26c926; u64 0x4d2c6dfc5ac42aed; u64 0x53380d139d95b3df;
u64 0x650a73548baf63de; u64 0x766a0abb3c77b2a8; u64 0x81c2c92e47edaee6; u64 0x92722c851482353b;
u64 0xa2bfe8a14cf10364; u64 0xa81a664bbc423001; u64 0xc24b8b70d0f89791; u64 0xc76c51a30654be30;
u64 0xd192e819d6ef5218; u64 0xd69906245565a910; u64 0xf40e35855771202a; u64 0x106aa07032bbd1b8;
u64 0x19a4c116b8d2d0c8; u64 0x1e376c085141ab53; u64 0x2748774cdf8eeb99; u64 0x34b0bcb5e19b48a8;
u64 0x391c0cb3c5c95a63; u64 0x4ed8aa4ae3418acb; u64 0x5b9cca4f7763e373; u64 0x682e6ff3d6b2b8a3;
u64 0x748f82ee5defb2fc; u64 0x78a5636f43172f60; u64 0x84c87814a1f0ab72; u64 0x8cc702081a6439ec;
u64 0x90befffa23631e28; u64 0xa4506cebde82bde9; u64 0xbef9a3f7b2c67915; u64 0xc67178f2e372532b;
u64 0xca273eceea26619c; u64 0xd186b8c721c0c207; u64 0xeada7dd6cde0eb1e; u64 0xf57d4f7fee6ed178;
u64 0x06f067aa72176fba; u64 0x0a637dc5a2c898a6; u64 0x113f9804bef90dae; u64 0x1b710b35131c471b;
u64 0x28db77f523047d84; u64 0x32caab7b40c72493; u64 0x3c9ebe0a15c9bebc; u64 0x431d67c49c100d4c;
u64 0x4cc5d4becb3e42b6; u64 0x597f299cfc657e2a; u64 0x5fcb6fab3ad6faec; u64 0x6c44198c4a475817
]
in
assert_norm (List.length l = 80);
l | false |
FStar.UInt64.fst | FStar.UInt64.div | val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c)) | val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c)) | let div a b = Mk (div (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 61,
"start_col": 0,
"start_line": 61
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t{FStar.UInt64.v b <> 0} -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.int",
"FStar.UInt64.v",
"FStar.UInt64.Mk",
"FStar.UInt.div",
"FStar.UInt64.n"
] | [] | false | false | false | false | false | let div a b =
| Mk (div (v a) (v b)) | false |
FStar.UInt64.fst | FStar.UInt64.rem | val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) | val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) | let rem a b = Mk (mod (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 63,
"start_col": 0,
"start_line": 63
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b))
let div a b = Mk (div (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t{FStar.UInt64.v b <> 0} -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.int",
"FStar.UInt64.v",
"FStar.UInt64.Mk",
"FStar.UInt.mod",
"FStar.UInt64.n"
] | [] | false | false | false | false | false | let rem a b =
| Mk (mod (v a) (v b)) | false |
FStar.UInt64.fst | FStar.UInt64.mul_mod | val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) | val mul_mod (a:t) (b:t) : Pure t
(requires True)
(ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) | let mul_mod a b = Mk (mul_mod (v a) (v b)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 59,
"start_col": 0,
"start_line": 59
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.mul_mod",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let mul_mod a b =
| Mk (mul_mod (v a) (v b)) | false |
FStar.UInt64.fst | FStar.UInt64.lognot | val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z)) | val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z)) | let lognot x = Mk (lognot (v x)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 71,
"start_col": 0,
"start_line": 71
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b))
let div a b = Mk (div (v a) (v b))
let rem a b = Mk (mod (v a) (v b))
let logand x y = Mk (logand (v x) (v y))
let logxor x y = Mk (logxor (v x) (v y))
let logor x y = Mk (logor (v x) (v y)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.lognot",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let lognot x =
| Mk (lognot (v x)) | false |
FStar.UInt64.fst | FStar.UInt64.shift_left | val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) | val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) | let shift_left a s = Mk (shift_left (v a) (UInt32.v s)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 55,
"end_line": 77,
"start_col": 0,
"start_line": 77
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b))
let div a b = Mk (div (v a) (v b))
let rem a b = Mk (mod (v a) (v b))
let logand x y = Mk (logand (v x) (v y))
let logxor x y = Mk (logxor (v x) (v y))
let logor x y = Mk (logor (v x) (v y))
let lognot x = Mk (lognot (v x))
let shift_right a s = Mk (shift_right (v a) (UInt32.v s))
#push-options "--z3rlimit 80 --fuel 1" //AR: working around the interleaving semantics of pragmas | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 80,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt32.t",
"FStar.UInt64.Mk",
"FStar.UInt.shift_left",
"FStar.UInt64.n",
"FStar.UInt64.v",
"FStar.UInt32.v"
] | [] | false | false | false | false | false | let shift_left a s =
| Mk (shift_left (v a) (UInt32.v s)) | false |
FStar.UInt64.fst | FStar.UInt64.logxor | val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z)) | val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z)) | let logxor x y = Mk (logxor (v x) (v y)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 67,
"start_col": 0,
"start_line": 67
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b))
let div a b = Mk (div (v a) (v b))
let rem a b = Mk (mod (v a) (v b))
let logand x y = Mk (logand (v x) (v y)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.logxor",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let logxor x y =
| Mk (logxor (v x) (v y)) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_from_mont_u32 | val bn_from_mont_u32 (len: BN.meta_len U32) : bn_from_mont_st U32 len | val bn_from_mont_u32 (len: BN.meta_len U32) : bn_from_mont_st U32 len | let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 69,
"end_line": 190,
"start_col": 0,
"start_line": 189
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U32
-> Hacl.Bignum.Montgomery.bn_from_mont_st Lib.IntTypes.U32 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U32",
"Hacl.Bignum.Montgomery.bn_from_mont",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u32",
"Hacl.Bignum.Montgomery.bn_from_mont_st"
] | [] | false | false | false | false | false | let bn_from_mont_u32 (len: BN.meta_len U32) : bn_from_mont_st U32 len =
| bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | false |
FStar.UInt64.fst | FStar.UInt64.logor | val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z)) | val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z)) | let logor x y = Mk (logor (v x) (v y)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 69,
"start_col": 0,
"start_line": 69
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b))
let div a b = Mk (div (v a) (v b))
let rem a b = Mk (mod (v a) (v b))
let logand x y = Mk (logand (v x) (v y))
let logxor x y = Mk (logxor (v x) (v y)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.logor",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let logor x y =
| Mk (logor (v x) (v y)) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_reduction_u32 | val bn_mont_reduction_u32 (len: BN.meta_len U32) : bn_mont_reduction_st U32 len | val bn_mont_reduction_u32 (len: BN.meta_len U32) : bn_mont_reduction_st U32 len | let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 186,
"start_col": 0,
"start_line": 185
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U32
-> Hacl.Bignum.Montgomery.bn_mont_reduction_st Lib.IntTypes.U32 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U32",
"Hacl.Bignum.Montgomery.bn_mont_reduction",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_st"
] | [] | false | false | false | false | false | let bn_mont_reduction_u32 (len: BN.meta_len U32) : bn_mont_reduction_st U32 len =
| bn_mont_reduction (BN.mk_runtime_bn U32 len) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_sqr_u32 | val bn_mont_sqr_u32 (len: BN.meta_len U32) : bn_mont_sqr_st U32 len | val bn_mont_sqr_u32 (len: BN.meta_len U32) : bn_mont_sqr_st U32 len | let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 194,
"start_col": 0,
"start_line": 193
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U32
-> Hacl.Bignum.Montgomery.bn_mont_sqr_st Lib.IntTypes.U32 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U32",
"Hacl.Bignum.Montgomery.bn_mont_sqr",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u32",
"Hacl.Bignum.Montgomery.bn_mont_sqr_st"
] | [] | false | false | false | false | false | let bn_mont_sqr_u32 (len: BN.meta_len U32) : bn_mont_sqr_st U32 len =
| bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | false |
FStar.UInt64.fst | FStar.UInt64.logand | val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z)) | val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z)) | let logand x y = Mk (logand (v x) (v y)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 65,
"start_col": 0,
"start_line": 65
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b))
let div a b = Mk (div (v a) (v b))
let rem a b = Mk (mod (v a) (v b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt64.Mk",
"FStar.UInt.logand",
"FStar.UInt64.n",
"FStar.UInt64.v"
] | [] | false | false | false | false | false | let logand x y =
| Mk (logand (v x) (v y)) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_to_mont_u32 | val bn_to_mont_u32 (len: BN.meta_len U32) : bn_to_mont_st U32 len | val bn_to_mont_u32 (len: BN.meta_len U32) : bn_to_mont_st U32 len | let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 188,
"start_col": 0,
"start_line": 187
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U32
-> Hacl.Bignum.Montgomery.bn_to_mont_st Lib.IntTypes.U32 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U32",
"Hacl.Bignum.Montgomery.bn_to_mont",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u32",
"Hacl.Bignum.Montgomery.bn_to_mont_st"
] | [] | false | false | false | false | false | let bn_to_mont_u32 (len: BN.meta_len U32) : bn_to_mont_st U32 len =
| bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_u64 | val bn_precomp_r2_mod_n_u64 (len: BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len | val bn_precomp_r2_mod_n_u64 (len: BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len | let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 212,
"start_col": 0,
"start_line": 211
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U64
-> Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st Lib.IntTypes.U64 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U64",
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st"
] | [] | false | false | false | false | false | let bn_precomp_r2_mod_n_u64 (len: BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
| bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_to_mont_u64 | val bn_to_mont_u64 (len: BN.meta_len U64) : bn_to_mont_st U64 len | val bn_to_mont_u64 (len: BN.meta_len U64) : bn_to_mont_st U64 len | let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len =
bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 216,
"start_col": 0,
"start_line": 215
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len
let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len)
let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U64
-> Hacl.Bignum.Montgomery.bn_to_mont_st Lib.IntTypes.U64 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U64",
"Hacl.Bignum.Montgomery.bn_to_mont",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u64",
"Hacl.Bignum.Montgomery.bn_to_mont_st"
] | [] | false | false | false | false | false | let bn_to_mont_u64 (len: BN.meta_len U64) : bn_to_mont_st U64 len =
| bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | false |
FStar.UInt64.fst | FStar.UInt64.shift_right | val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) | val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) | let shift_right a s = Mk (shift_right (v a) (UInt32.v s)) | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 73,
"start_col": 0,
"start_line": 73
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b))
let div a b = Mk (div (v a) (v b))
let rem a b = Mk (mod (v a) (v b))
let logand x y = Mk (logand (v x) (v y))
let logxor x y = Mk (logxor (v x) (v y))
let logor x y = Mk (logor (v x) (v y))
let lognot x = Mk (lognot (v x)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt64.t | Prims.Pure | [] | [] | [
"FStar.UInt64.t",
"FStar.UInt32.t",
"FStar.UInt64.Mk",
"FStar.UInt.shift_right",
"FStar.UInt64.n",
"FStar.UInt64.v",
"FStar.UInt32.v"
] | [] | false | false | false | false | false | let shift_right a s =
| Mk (shift_right (v a) (UInt32.v s)) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_reduction_u64 | val bn_mont_reduction_u64 (len: BN.meta_len U64) : bn_mont_reduction_st U64 len | val bn_mont_reduction_u64 (len: BN.meta_len U64) : bn_mont_reduction_st U64 len | let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len =
bn_mont_reduction (BN.mk_runtime_bn U64 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 214,
"start_col": 0,
"start_line": 213
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len
let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U64
-> Hacl.Bignum.Montgomery.bn_mont_reduction_st Lib.IntTypes.U64 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U64",
"Hacl.Bignum.Montgomery.bn_mont_reduction",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_st"
] | [] | false | false | false | false | false | let bn_mont_reduction_u64 (len: BN.meta_len U64) : bn_mont_reduction_st U64 len =
| bn_mont_reduction (BN.mk_runtime_bn U64 len) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_mul_u32 | val bn_mont_mul_u32 (len: BN.meta_len U32) : bn_mont_mul_st U32 len | val bn_mont_mul_u32 (len: BN.meta_len U32) : bn_mont_mul_st U32 len | let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 192,
"start_col": 0,
"start_line": 191
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U32
-> Hacl.Bignum.Montgomery.bn_mont_mul_st Lib.IntTypes.U32 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U32",
"Hacl.Bignum.Montgomery.bn_mont_mul",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u32",
"Hacl.Bignum.Montgomery.bn_mont_mul_st"
] | [] | false | false | false | false | false | let bn_mont_mul_u32 (len: BN.meta_len U32) : bn_mont_mul_st U32 len =
| bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n | val bn_precomp_r2_mod_n: #t:limb_t -> k:BN.bn t -> bn_precomp_r2_mod_n_st t k.BN.len | val bn_precomp_r2_mod_n: #t:limb_t -> k:BN.bn t -> bn_precomp_r2_mod_n_st t k.BN.len | let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 51,
"start_col": 0,
"start_line": 38
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Bignum.bn t -> Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st t (Mkbn?.len k) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.bn",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Division",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.bits",
"Hacl.Bignum.__proj__Mkbn__item__len",
"Hacl.Bignum.Definitions.lbignum",
"Lib.Buffer.loop1",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.op_Subtraction_Bang",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size",
"Hacl.Bignum.add_mod_n",
"Prims.unit",
"Lib.LoopCombinators.unfold_repeati",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims.nat",
"Hacl.Spec.Bignum.Montgomery.bn_lshift1_mod_n",
"Hacl.Bignum.bn_set_ith_bit",
"Lib.Buffer.memset",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Hacl.Bignum.meta_len"
] | [] | false | false | false | false | false | let bn_precomp_r2_mod_n #t k nBits n res =
| [@@ inline_let ]let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@@ inline_let ]let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0
(2ul *! size (bits t) *! len -! nBits)
res
spec
(fun i ->
Loops.unfold_repeati ((2 * bits t) * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_one | val bn_mont_one:
#t:limb_t
-> len:BN.meta_len t
-> bn_mont_from:bn_from_mont_st t len ->
bn_mont_one_st t len | val bn_mont_one:
#t:limb_t
-> len:BN.meta_len t
-> bn_mont_from:bn_from_mont_st t len ->
bn_mont_one_st t len | let bn_mont_one #t len bn_from_mont n mu r2 oneM =
bn_from_mont n mu r2 oneM | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 245,
"start_col": 0,
"start_line": 244
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len
let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len)
let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len =
bn_mont_reduction (BN.mk_runtime_bn U64 len)
let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len =
bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len =
bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_mont_mul_u64 (len:BN.meta_len U64) : bn_mont_mul_st U64 len =
bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_mont_sqr_u64 (len:BN.meta_len U64) : bn_mont_sqr_st U64 len =
bn_mont_sqr (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
inline_for_extraction noextract
let mk_runtime_mont_u64 (len:BN.meta_len U64) : mont U64 = {
bn = BN.mk_runtime_bn U64 len;
mont_check = bn_check_modulus_u64 len;
precomp = bn_precomp_r2_mod_n_u64 len;
reduction = bn_mont_reduction_u64 len;
to = bn_to_mont_u64 len;
from = bn_from_mont_u64 len;
mul = bn_mont_mul_u64 len;
sqr = bn_mont_sqr_u64 len;
}
let mk_runtime_mont (#t:limb_t) (len:BN.meta_len t) : mont t =
match t with
| U32 -> mk_runtime_mont_u32 len
| U64 -> mk_runtime_mont_u64 len
let mk_runtime_mont_len_lemma #t len = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len t -> bn_mont_from: Hacl.Bignum.Montgomery.bn_from_mont_st t len
-> Hacl.Bignum.Montgomery.bn_mont_one_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Montgomery.bn_from_mont_st",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"Prims.unit"
] | [] | false | false | false | false | false | let bn_mont_one #t len bn_from_mont n mu r2 oneM =
| bn_from_mont n mu r2 oneM | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_from_mont_u64 | val bn_from_mont_u64 (len: BN.meta_len U64) : bn_from_mont_st U64 len | val bn_from_mont_u64 (len: BN.meta_len U64) : bn_from_mont_st U64 len | let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len =
bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 69,
"end_line": 218,
"start_col": 0,
"start_line": 217
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len
let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len)
let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len =
bn_mont_reduction (BN.mk_runtime_bn U64 len)
let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U64
-> Hacl.Bignum.Montgomery.bn_from_mont_st Lib.IntTypes.U64 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U64",
"Hacl.Bignum.Montgomery.bn_from_mont",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u64",
"Hacl.Bignum.Montgomery.bn_from_mont_st"
] | [] | false | false | false | false | false | let bn_from_mont_u64 (len: BN.meta_len U64) : bn_from_mont_st U64 len =
| bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.mk_runtime_mont_u32 | val mk_runtime_mont_u32 (len: BN.meta_len U32) : mont U32 | val mk_runtime_mont_u32 (len: BN.meta_len U32) : mont U32 | let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
} | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 1,
"end_line": 206,
"start_col": 0,
"start_line": 197
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U32 -> Hacl.Bignum.Montgomery.mont Lib.IntTypes.U32 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U32",
"Hacl.Bignum.Montgomery.Mkmont",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_check_modulus_u32",
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_u32",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u32",
"Hacl.Bignum.Montgomery.bn_to_mont_u32",
"Hacl.Bignum.Montgomery.bn_from_mont_u32",
"Hacl.Bignum.Montgomery.bn_mont_mul_u32",
"Hacl.Bignum.Montgomery.bn_mont_sqr_u32",
"Hacl.Bignum.Montgomery.mont"
] | [] | false | false | false | true | false | let mk_runtime_mont_u32 (len: BN.meta_len U32) : mont U32 =
| {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len
} | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_sqr_u64 | val bn_mont_sqr_u64 (len: BN.meta_len U64) : bn_mont_sqr_st U64 len | val bn_mont_sqr_u64 (len: BN.meta_len U64) : bn_mont_sqr_st U64 len | let bn_mont_sqr_u64 (len:BN.meta_len U64) : bn_mont_sqr_st U64 len =
bn_mont_sqr (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 222,
"start_col": 0,
"start_line": 221
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len
let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len)
let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len =
bn_mont_reduction (BN.mk_runtime_bn U64 len)
let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len =
bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len =
bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_mont_mul_u64 (len:BN.meta_len U64) : bn_mont_mul_st U64 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U64
-> Hacl.Bignum.Montgomery.bn_mont_sqr_st Lib.IntTypes.U64 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U64",
"Hacl.Bignum.Montgomery.bn_mont_sqr",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u64",
"Hacl.Bignum.Montgomery.bn_mont_sqr_st"
] | [] | false | false | false | false | false | let bn_mont_sqr_u64 (len: BN.meta_len U64) : bn_mont_sqr_st U64 len =
| bn_mont_sqr (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_reduction | val bn_mont_reduction: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_st t k.BN.len | val bn_mont_reduction: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_st t k.BN.len | let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 135,
"start_col": 0,
"start_line": 132
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Bignum.bn t -> Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.bn",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.__proj__Mkbn__item__len",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.bn_reduce_once",
"Prims.unit",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Montgomery.bn_mont_reduction_loop_div_r",
"Hacl.Bignum.meta_len"
] | [] | false | false | false | false | false | let bn_mont_reduction #t k n nInv c res =
| [@@ inline_let ]let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_mul_u64 | val bn_mont_mul_u64 (len: BN.meta_len U64) : bn_mont_mul_st U64 len | val bn_mont_mul_u64 (len: BN.meta_len U64) : bn_mont_mul_st U64 len | let bn_mont_mul_u64 (len:BN.meta_len U64) : bn_mont_mul_st U64 len =
bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 220,
"start_col": 0,
"start_line": 219
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len
let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len)
let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len =
bn_mont_reduction (BN.mk_runtime_bn U64 len)
let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len =
bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U64
-> Hacl.Bignum.Montgomery.bn_mont_mul_st Lib.IntTypes.U64 len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U64",
"Hacl.Bignum.Montgomery.bn_mont_mul",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u64",
"Hacl.Bignum.Montgomery.bn_mont_mul_st"
] | [] | false | false | false | false | false | let bn_mont_mul_u64 (len: BN.meta_len U64) : bn_mont_mul_st U64 len =
| bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | false |
C.Failure.fst | C.Failure.failwith | val failwith (#a: Type) (s: C.String.t)
: Stack a (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) | val failwith (#a: Type) (s: C.String.t)
: Stack a (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) | let rec failwith (#a: Type) (s: C.String.t): Stack a
(requires (fun _ -> true))
(ensures (fun h0 _ h1 -> h0 == h1)) =
C.String.print s;
// Defeat recursion warnings.
if whatever () then
C.portable_exit 255l;
failwith s | {
"file_name": "krmllib/C.Failure.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 12,
"end_line": 18,
"start_col": 0,
"start_line": 11
} | module C.Failure
open FStar.HyperStack.ST
let whatever (): Stack bool
(requires (fun _ -> true))
(ensures (fun h0 _ h1 -> h0 == h1)) =
true | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked",
"C.fst.checked"
],
"interface_file": false,
"source_file": "C.Failure.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C",
"short_module": null
},
{
"abbrev": false,
"full_module": "C",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: C.String.t -> FStar.HyperStack.ST.Stack a | FStar.HyperStack.ST.Stack | [] | [] | [
"C.String.t",
"C.Failure.failwith",
"Prims.unit",
"C.portable_exit",
"FStar.Int32.__int_to_t",
"Prims.bool",
"C.Failure.whatever",
"C.String.print",
"FStar.Monotonic.HyperStack.mem",
"Prims.b2t",
"Prims.eq2"
] | [
"recursion"
] | false | true | false | false | false | let rec failwith (#a: Type) (s: C.String.t)
: Stack a (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) =
| C.String.print s;
if whatever () then C.portable_exit 255l;
failwith s | false |
FStar.UInt64.fst | FStar.UInt64.lemma_sub_msbs | val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) | val lemma_sub_msbs (a:t) (b:t)
: Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) | let lemma_sub_msbs a b
= from_vec_propriety (to_vec (v a)) 1;
from_vec_propriety (to_vec (v b)) 1;
from_vec_propriety (to_vec (v (sub_mod a b))) 1 | {
"file_name": "ulib/FStar.UInt64.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 53,
"end_line": 82,
"start_col": 0,
"start_line": 79
} | (*
Copyright 2008-2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.UInt64
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
open FStar.UInt
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
type t : eqtype =
| Mk: v:uint_t n -> t
let v x = x.v
irreducible
let uint_to_t x = Mk x
let uv_inv _ = ()
let vu_inv _ = ()
let v_inj _ _ = ()
let zero = uint_to_t 0
let one = uint_to_t 1
let add a b = Mk (add (v a) (v b))
let add_underspec a b = Mk (add_underspec (v a) (v b))
let add_mod a b = Mk (add_mod (v a) (v b))
let sub a b = Mk (sub (v a) (v b))
let sub_underspec a b = Mk (sub_underspec (v a) (v b))
let sub_mod a b = Mk (sub_mod (v a) (v b))
let mul a b = Mk (mul (v a) (v b))
let mul_underspec a b = Mk (mul_underspec (v a) (v b))
let mul_mod a b = Mk (mul_mod (v a) (v b))
let div a b = Mk (div (v a) (v b))
let rem a b = Mk (mod (v a) (v b))
let logand x y = Mk (logand (v x) (v y))
let logxor x y = Mk (logxor (v x) (v y))
let logor x y = Mk (logor (v x) (v y))
let lognot x = Mk (lognot (v x))
let shift_right a s = Mk (shift_right (v a) (UInt32.v s))
#push-options "--z3rlimit 80 --fuel 1" //AR: working around the interleaving semantics of pragmas
let shift_left a s = Mk (shift_left (v a) (UInt32.v s)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "FStar.UInt64.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 80,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt64.t -> b: FStar.UInt64.t
-> FStar.Pervasives.Lemma
(ensures
FStar.UInt.msb (FStar.UInt64.v a) = FStar.UInt.msb (FStar.UInt64.v b) ==>
(FStar.UInt64.v a < FStar.UInt64.v b <==>
FStar.UInt.msb (FStar.UInt64.v (FStar.UInt64.sub_mod a b)))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.UInt64.t",
"FStar.UInt.from_vec_propriety",
"FStar.UInt64.n",
"FStar.UInt.to_vec",
"FStar.UInt64.v",
"FStar.UInt64.sub_mod",
"Prims.unit"
] | [] | true | false | true | false | false | let lemma_sub_msbs a b =
| from_vec_propriety (to_vec (v a)) 1;
from_vec_propriety (to_vec (v b)) 1;
from_vec_propriety (to_vec (v (sub_mod a b))) 1 | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.mk_runtime_mont | val mk_runtime_mont: #t:limb_t -> len:BN.meta_len t -> mont t | val mk_runtime_mont: #t:limb_t -> len:BN.meta_len t -> mont t | let mk_runtime_mont (#t:limb_t) (len:BN.meta_len t) : mont t =
match t with
| U32 -> mk_runtime_mont_u32 len
| U64 -> mk_runtime_mont_u64 len | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 239,
"start_col": 0,
"start_line": 236
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len
let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len)
let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len =
bn_mont_reduction (BN.mk_runtime_bn U64 len)
let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len =
bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len =
bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_mont_mul_u64 (len:BN.meta_len U64) : bn_mont_mul_st U64 len =
bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_mont_sqr_u64 (len:BN.meta_len U64) : bn_mont_sqr_st U64 len =
bn_mont_sqr (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
inline_for_extraction noextract
let mk_runtime_mont_u64 (len:BN.meta_len U64) : mont U64 = {
bn = BN.mk_runtime_bn U64 len;
mont_check = bn_check_modulus_u64 len;
precomp = bn_precomp_r2_mod_n_u64 len;
reduction = bn_mont_reduction_u64 len;
to = bn_to_mont_u64 len;
from = bn_from_mont_u64 len;
mul = bn_mont_mul_u64 len;
sqr = bn_mont_sqr_u64 len;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len t -> Hacl.Bignum.Montgomery.mont t | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Montgomery.mk_runtime_mont_u32",
"Hacl.Bignum.Montgomery.mk_runtime_mont_u64",
"Hacl.Bignum.Montgomery.mont"
] | [] | false | false | false | false | false | let mk_runtime_mont (#t: limb_t) (len: BN.meta_len t) : mont t =
| match t with
| U32 -> mk_runtime_mont_u32 len
| U64 -> mk_runtime_mont_u64 len | false |
C.Failure.fst | C.Failure.whatever | val whatever: Prims.unit
-> Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) | val whatever: Prims.unit
-> Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) | let whatever (): Stack bool
(requires (fun _ -> true))
(ensures (fun h0 _ h1 -> h0 == h1)) =
true | {
"file_name": "krmllib/C.Failure.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 6,
"end_line": 8,
"start_col": 0,
"start_line": 5
} | module C.Failure
open FStar.HyperStack.ST | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked",
"C.fst.checked"
],
"interface_file": false,
"source_file": "C.Failure.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C",
"short_module": null
},
{
"abbrev": false,
"full_module": "C",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Prims.unit",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"Prims.b2t",
"Prims.eq2"
] | [] | false | true | false | false | false | let whatever () : Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) =
| true | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.mk_runtime_mont_u64 | val mk_runtime_mont_u64 (len: BN.meta_len U64) : mont U64 | val mk_runtime_mont_u64 (len: BN.meta_len U64) : mont U64 | let mk_runtime_mont_u64 (len:BN.meta_len U64) : mont U64 = {
bn = BN.mk_runtime_bn U64 len;
mont_check = bn_check_modulus_u64 len;
precomp = bn_precomp_r2_mod_n_u64 len;
reduction = bn_mont_reduction_u64 len;
to = bn_to_mont_u64 len;
from = bn_from_mont_u64 len;
mul = bn_mont_mul_u64 len;
sqr = bn_mont_sqr_u64 len;
} | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 1,
"end_line": 234,
"start_col": 0,
"start_line": 225
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame ()
/// All of the functions above are inline_for_extraction noextract meaning that
/// they're intended to be specialized by clients for a specific value of
/// ``len``. We provide a default implementation that actually keeps ``len`` at
/// runtime, to offer a version of mod_exp where all the parameters are present
/// at run-time.
let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len =
bn_check_modulus #U32 #len
let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len =
bn_mont_reduction (BN.mk_runtime_bn U32 len)
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len =
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len =
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len =
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len =
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
inline_for_extraction noextract
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = {
bn = BN.mk_runtime_bn U32 len;
mont_check = bn_check_modulus_u32 len;
precomp = bn_precomp_r2_mod_n_u32 len;
reduction = bn_mont_reduction_u32 len;
to = bn_to_mont_u32 len;
from = bn_from_mont_u32 len;
mul = bn_mont_mul_u32 len;
sqr = bn_mont_sqr_u32 len;
}
let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len =
bn_check_modulus #U64 #len
let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len =
bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len)
let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len =
bn_mont_reduction (BN.mk_runtime_bn U64 len)
let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len =
bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len =
bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_mont_mul_u64 (len:BN.meta_len U64) : bn_mont_mul_st U64 len =
bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
let bn_mont_sqr_u64 (len:BN.meta_len U64) : bn_mont_sqr_st U64 len =
bn_mont_sqr (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | len: Hacl.Bignum.meta_len Lib.IntTypes.U64 -> Hacl.Bignum.Montgomery.mont Lib.IntTypes.U64 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.meta_len",
"Lib.IntTypes.U64",
"Hacl.Bignum.Montgomery.Mkmont",
"Hacl.Bignum.mk_runtime_bn",
"Hacl.Bignum.Montgomery.bn_check_modulus_u64",
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_u64",
"Hacl.Bignum.Montgomery.bn_mont_reduction_u64",
"Hacl.Bignum.Montgomery.bn_to_mont_u64",
"Hacl.Bignum.Montgomery.bn_from_mont_u64",
"Hacl.Bignum.Montgomery.bn_mont_mul_u64",
"Hacl.Bignum.Montgomery.bn_mont_sqr_u64",
"Hacl.Bignum.Montgomery.mont"
] | [] | false | false | false | true | false | let mk_runtime_mont_u64 (len: BN.meta_len U64) : mont U64 =
| {
bn = BN.mk_runtime_bn U64 len;
mont_check = bn_check_modulus_u64 len;
precomp = bn_precomp_r2_mod_n_u64 len;
reduction = bn_mont_reduction_u64 len;
to = bn_to_mont_u64 len;
from = bn_from_mont_u64 len;
mul = bn_mont_mul_u64 len;
sqr = bn_mont_sqr_u64 len
} | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_from_mont | val bn_from_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_from_mont_st t k.BN.len | val bn_from_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_from_mont_st t k.BN.len | let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame () | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 153,
"start_col": 0,
"start_line": 147
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Bignum.bn t -> mr: Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k)
-> Hacl.Bignum.Montgomery.bn_from_mont_st t (Mkbn?.len k) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_st",
"Hacl.Bignum.__proj__Mkbn__item__len",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Lib.Buffer.update_sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.add",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame",
"Hacl.Bignum.meta_len"
] | [] | false | false | false | false | false | let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
| [@@ inline_let ]let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame () | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_sqr | val bn_mont_sqr: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_sqr_st t k.BN.len | val bn_mont_sqr: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_sqr_st t k.BN.len | let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame () | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 173,
"start_col": 0,
"start_line": 167
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame ()
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Bignum.bn t -> mr: Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k)
-> Hacl.Bignum.Montgomery.bn_mont_sqr_st t (Mkbn?.len k) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_st",
"Hacl.Bignum.__proj__Mkbn__item__len",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Bignum.__proj__Mkbn__item__sqr",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.add",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.create",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame",
"Hacl.Bignum.meta_len"
] | [] | false | false | false | false | false | let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
| [@@ inline_let ]let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.sqr aM c;
mont_reduction n nInv_u64 c resM;
pop_frame () | false |
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_mont_mul | val bn_mont_mul: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_mul_st t k.BN.len | val bn_mont_mul: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_mul_st t k.BN.len | let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
// In case you need to debug the type class projection, this is the explicit
// syntax without referring to the implicitly-defined projector.
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame () | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 164,
"start_col": 0,
"start_line": 156
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res
let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame ()
let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
[@inline_let] let len = k.BN.len in
push_frame ();
let tmp = create (len +! len) (uint #t 0) in
update_sub tmp 0ul len aM;
mont_reduction n nInv_u64 tmp a;
pop_frame () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Bignum.bn t -> mr: Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k)
-> Hacl.Bignum.Montgomery.bn_mont_mul_st t (Mkbn?.len k) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_st",
"Hacl.Bignum.__proj__Mkbn__item__len",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Bignum.__proj__Mkbn__item__mul",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.add",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.create",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame",
"Hacl.Bignum.meta_len"
] | [] | false | false | false | false | false | let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
| [@@ inline_let ]let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
k.BN.mul aM bM c;
mont_reduction n nInv_u64 c resM;
pop_frame () | false |
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.code | val code : Type0 | let code = BS.code | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 12,
"start_col": 7,
"start_line": 12
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.code"
] | [] | false | false | false | true | true | let code =
| BS.code | false |
|
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.ocmp | val ocmp : Prims.eqtype | let ocmp = BS.ocmp | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.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.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.ocmp"
] | [] | false | false | false | true | false | let ocmp =
| BS.ocmp | false |
|
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.codes | val codes : Type0 | let codes = BS.codes | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 13,
"start_col": 7,
"start_line": 13
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.codes"
] | [] | false | false | false | true | true | let codes =
| BS.codes | false |
|
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.cf | val cf (flags: Flags.t) : Flags.flag_val_t | val cf (flags: Flags.t) : Flags.flag_val_t | let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 17,
"start_col": 0,
"start_line": 17
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | flags: Vale.X64.Flags.t -> Vale.X64.Flags.flag_val_t | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Flags.t",
"Vale.X64.Flags.sel",
"Vale.X64.Machine_s.fCarry",
"Vale.X64.Flags.flag_val_t"
] | [] | false | false | false | true | false | let cf (flags: Flags.t) : Flags.flag_val_t =
| Flags.sel fCarry flags | false |
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.fuel | val fuel : Type0 | let fuel = nat | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 15,
"start_col": 7,
"start_line": 15
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat"
] | [] | false | false | false | true | true | let fuel =
| nat | false |
|
Hacl.Bignum.Montgomery.fst | Hacl.Bignum.Montgomery.bn_to_mont | val bn_to_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_to_mont_st t k.BN.len | val bn_to_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_to_mont_st t k.BN.len | let bn_to_mont #t k mont_reduction n nInv r2 a aM =
[@inline_let] let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame () | {
"file_name": "code/bignum/Hacl.Bignum.Montgomery.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 144,
"start_col": 0,
"start_line": 138
} | module Hacl.Bignum.Montgomery
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Montgomery
module SB = Hacl.Spec.Bignum
module BN = Hacl.Bignum
friend Hacl.Spec.Bignum.Montgomery
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let bn_check_modulus #t #len n =
push_frame ();
let one = create len (uint #t 0) in
BN.bn_from_uint len (uint #t 1) one;
let bit0 = BN.bn_is_odd len n in
let m0 = uint #t 0 -. bit0 in
let m1 = BN.bn_lt_mask len one n in
let m = m0 &. m1 in
pop_frame ();
m
let bn_precomp_r2_mod_n #t k nBits n res =
[@inline_let] let len = k.BN.len in
memset res (uint #t 0) len;
BN.bn_set_ith_bit len res nBits;
[@inline_let]
let spec h = S.bn_lshift1_mod_n (as_seq h n) in
let h0 = ST.get () in
loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec
(fun i ->
Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i);
BN.add_mod_n n res res res
)
let bn_mont_precomp #t len precompr2 nBits n r2 =
precompr2 nBits n r2;
mod_inv_limb n.(0ul)
inline_for_extraction noextract
val bn_mont_reduction_f:
#t:limb_t
-> len:size_t{v len + v len <= max_size_t}
-> n:lbignum t len
-> nInv:(limb t)
-> j:size_t{v j < v len}
-> c:lbuffer (carry t) 1ul
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h n /\ live h res /\ live h c /\
disjoint n res /\ disjoint n c /\ disjoint c res)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\
(Seq.index (as_seq h1 c) 0, as_seq h1 res) ==
S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
let bn_mont_reduction_f #t len n nInv j c res =
let qj = nInv *. res.(j) in
// Keeping the inline_for_extraction version here.
let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in
let h0 = ST.get () in
let resb = sub res (len +! j) 1ul in
let res_j = res.(len +! j) in
c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb;
let h1 = ST.get () in
let tmp = sub res (len +! j) 1ul in
B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1;
assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len));
B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1;
LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res);
LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
inline_for_extraction noextract
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) =
n:lbignum t len
-> mu:limb t
-> c:lbignum t (len +! len)
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h n /\ live h c /\ live h res /\
disjoint res n /\ disjoint res c /\ disjoint n c)
(ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\
(c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
inline_for_extraction noextract
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
let bn_mont_reduction_loop_div_r #t k n nInv c res =
[@inline_let] let len = k.BN.len in
push_frame ();
let c0 = create 1ul (uint #t 0) in
[@inline_let]
let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in
[@inline_let]
let footprint i = loc c0 |+| loc c in
[@ inline_let]
let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in
let h0 = ST.get () in
loop h0 len S.bn_mont_reduction_t refl footprint spec
(fun j ->
Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j);
bn_mont_reduction_f len n nInv j c0 c
);
BN.bn_rshift (len +! len) c len res;
let c0 = c0.(0ul) in
pop_frame ();
c0
let bn_mont_reduction #t k n nInv c res =
[@inline_let] let len = k.BN.len in
let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in
BN.bn_reduce_once len n c0 res | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Bignum.Montgomery.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.ModInvLimb",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k: Hacl.Bignum.bn t -> mr: Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k)
-> Hacl.Bignum.Montgomery.bn_to_mont_st t (Mkbn?.len k) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.bn",
"Hacl.Bignum.Montgomery.bn_mont_reduction_st",
"Hacl.Bignum.__proj__Mkbn__item__len",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Bignum.mul",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.add",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.create",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame",
"Hacl.Bignum.meta_len"
] | [] | false | false | false | false | false | let bn_to_mont #t k mont_reduction n nInv r2 a aM =
| [@@ inline_let ]let len = k.BN.len in
push_frame ();
let c = create (len +! len) (uint #t 0) in
BN.mul a r2 c;
mont_reduction n nInv c aM;
pop_frame () | false |
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.machine_state | val machine_state : Type | let machine_state = BS.machine_state | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 22,
"start_col": 7,
"start_line": 22
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat
let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags
let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags
let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags
let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.machine_state"
] | [] | false | false | false | true | true | let machine_state =
| BS.machine_state | false |
|
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.overflow | val overflow (flags: Flags.t) : Flags.flag_val_t | val overflow (flags: Flags.t) : Flags.flag_val_t | let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 75,
"end_line": 18,
"start_col": 0,
"start_line": 18
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | flags: Vale.X64.Flags.t -> Vale.X64.Flags.flag_val_t | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Flags.t",
"Vale.X64.Flags.sel",
"Vale.X64.Machine_s.fOverflow",
"Vale.X64.Flags.flag_val_t"
] | [] | false | false | false | true | false | let overflow (flags: Flags.t) : Flags.flag_val_t =
| Flags.sel fOverflow flags | false |
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.machine_eval_code | val machine_eval_code : c: Vale.X64.Machine_Semantics_s.code ->
fuel: Prims.nat ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state) | let machine_eval_code = BS.machine_eval_code | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 23,
"start_col": 7,
"start_line": 23
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat
let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags
let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags
let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags
let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Vale.X64.Machine_Semantics_s.code ->
fuel: Prims.nat ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state) | Prims.Tot | [
"total",
""
] | [] | [
"Vale.X64.Machine_Semantics_s.machine_eval_code"
] | [] | false | false | false | true | false | let machine_eval_code =
| BS.machine_eval_code | false |
|
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.state_eq_opt | val state_eq_opt : ignore_ghost: Prims.bool ->
s1: FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state ->
s2: FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state
-> Prims.logical | let state_eq_opt (ignore_ghost:bool) (s1 s2:option BS.machine_state) =
match (s1, s2) with
| (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2
| _ -> s1 == s2 | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 49,
"start_col": 0,
"start_line": 46
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat
let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags
let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags
let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags
let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags
unfold let machine_state = BS.machine_state
unfold let machine_eval_code = BS.machine_eval_code
let rec code_modifies_ghost (c:code) : bool =
match c with
| Ins (Instr _ _ (BS.AnnotateGhost _)) -> true
| Ins _ -> false
| Block cs -> codes_modifies_ghost cs
| IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2
| While _ c -> code_modifies_ghost c
and codes_modifies_ghost (cs:codes) : bool =
match cs with
| [] -> false
| c::cs -> code_modifies_ghost c || codes_modifies_ghost cs
let core_state (ignore_ghost:bool) (s:machine_state) : machine_state =
{s with
BS.ms_trace = [];
BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap;
}
let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) =
machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ignore_ghost: Prims.bool ->
s1: FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state ->
s2: FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"FStar.Pervasives.Native.option",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Lemmas.state_eq_S",
"FStar.Pervasives.Native.tuple2",
"Prims.eq2",
"Prims.logical"
] | [] | false | false | false | true | true | let state_eq_opt (ignore_ghost: bool) (s1 s2: option BS.machine_state) =
| match (s1, s2) with
| Some s1, Some s2 -> state_eq_S ignore_ghost s1 s2
| _ -> s1 == s2 | false |
|
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.update_cf | val update_cf : flags: Vale.X64.Flags.t -> new_cf: Prims.bool -> Vale.X64.Flags.t | let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 82,
"end_line": 19,
"start_col": 0,
"start_line": 19
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat
let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | flags: Vale.X64.Flags.t -> new_cf: Prims.bool -> Vale.X64.Flags.t | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Flags.t",
"Prims.bool",
"Vale.X64.Flags.upd",
"Vale.X64.Machine_s.fCarry",
"FStar.Pervasives.Native.Some"
] | [] | false | false | false | true | false | let update_cf (flags: Flags.t) (new_cf: bool) =
| Flags.upd fCarry (Some new_cf) flags | false |
|
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.core_state | val core_state (ignore_ghost: bool) (s: machine_state) : machine_state | val core_state (ignore_ghost: bool) (s: machine_state) : machine_state | let core_state (ignore_ghost:bool) (s:machine_state) : machine_state =
{s with
BS.ms_trace = [];
BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap;
} | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"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": 37
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat
let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags
let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags
let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags
let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags
unfold let machine_state = BS.machine_state
unfold let machine_eval_code = BS.machine_eval_code
let rec code_modifies_ghost (c:code) : bool =
match c with
| Ins (Instr _ _ (BS.AnnotateGhost _)) -> true
| Ins _ -> false
| Block cs -> codes_modifies_ghost cs
| IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2
| While _ c -> code_modifies_ghost c
and codes_modifies_ghost (cs:codes) : bool =
match cs with
| [] -> false
| c::cs -> code_modifies_ghost c || codes_modifies_ghost cs | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ignore_ghost: Prims.bool -> s: Vale.X64.Lemmas.machine_state -> Vale.X64.Lemmas.machine_state | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Vale.X64.Lemmas.machine_state",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags",
"Vale.Arch.HeapLemmas.heap_ignore_ghost_machine",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap",
"Vale.Arch.Heap.heap_impl",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint",
"Prims.Nil",
"Vale.X64.Machine_s.observation"
] | [] | false | false | false | true | false | let core_state (ignore_ghost: bool) (s: machine_state) : machine_state =
| {
s with
BS.ms_trace = [];
BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap
} | false |
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.update_of | val update_of : flags: Vale.X64.Flags.t -> new_of: Prims.bool -> Vale.X64.Flags.t | let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 85,
"end_line": 20,
"start_col": 0,
"start_line": 20
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat
let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags
let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | flags: Vale.X64.Flags.t -> new_of: Prims.bool -> Vale.X64.Flags.t | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Flags.t",
"Prims.bool",
"Vale.X64.Flags.upd",
"Vale.X64.Machine_s.fOverflow",
"FStar.Pervasives.Native.Some"
] | [] | false | false | false | true | false | let update_of (flags: Flags.t) (new_of: bool) =
| Flags.upd fOverflow (Some new_of) flags | false |
|
Hacl.Impl.Exponentiation.Definitions.fst | Hacl.Impl.Exponentiation.Definitions.inttype_a | val inttype_a : Type0 | let inttype_a = t:inttype{t = U32 \/ t = U64} | {
"file_name": "code/bignum/Hacl.Impl.Exponentiation.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 17,
"start_col": 0,
"start_line": 17
} | module Hacl.Impl.Exponentiation.Definitions
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Lib.Exponentiation.Definition
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Exponentiation.Definitions.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64"
] | [] | false | false | false | true | true | let inttype_a =
| t: inttype{t = U32 \/ t = U64} | false |
|
Vale.X64.Lemmas.fsti | Vale.X64.Lemmas.state_eq_S | val state_eq_S : ignore_ghost: Prims.bool -> s1: Vale.X64.Lemmas.machine_state -> s2: Vale.X64.Lemmas.machine_state
-> Prims.logical | let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) =
machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) | {
"file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 76,
"end_line": 44,
"start_col": 0,
"start_line": 43
} | module Vale.X64.Lemmas
open FStar.Mul
open Vale.Arch.Heap
open Vale.Arch.HeapImpl
open Vale.Arch.HeapLemmas
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Bytes_Code_s
module BS = Vale.X64.Machine_Semantics_s
module Map16 = Vale.Lib.Map16
unfold let code = BS.code
unfold let codes = BS.codes
unfold let ocmp = BS.ocmp
unfold let fuel = nat
let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags
let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags
let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags
let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags
unfold let machine_state = BS.machine_state
unfold let machine_eval_code = BS.machine_eval_code
let rec code_modifies_ghost (c:code) : bool =
match c with
| Ins (Instr _ _ (BS.AnnotateGhost _)) -> true
| Ins _ -> false
| Block cs -> codes_modifies_ghost cs
| IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2
| While _ c -> code_modifies_ghost c
and codes_modifies_ghost (cs:codes) : bool =
match cs with
| [] -> false
| c::cs -> code_modifies_ghost c || codes_modifies_ghost cs
let core_state (ignore_ghost:bool) (s:machine_state) : machine_state =
{s with
BS.ms_trace = [];
BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap;
} | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Arch.HeapLemmas.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Lemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ignore_ghost: Prims.bool -> s1: Vale.X64.Lemmas.machine_state -> s2: Vale.X64.Lemmas.machine_state
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Vale.X64.Lemmas.machine_state",
"Vale.X64.StateLemmas.machine_state_eq",
"Vale.X64.Lemmas.core_state",
"Prims.logical"
] | [] | false | false | false | true | true | let state_eq_S (ignore_ghost: bool) (s1 s2: machine_state) =
| machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.